You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(stdlib): @generative stub signature corrupted under from __future__ import annotations #1503
describe_function() and get_argument() in mellea/stdlib/components/genstub.py call inspect.signature(func) without eval_str=True. When the caller's module has from __future__ import annotations (PEP 563), every annotation on func is a string rather than a real type object, which corrupts the @generative stub prompt in two independent ways:
describe_function() renders the raw annotation strings straight into the prompt, e.g. def extract_requirements(product_description: 'str') -> 'list[Requirement]': instead of the resolved def extract_requirements(product_description: str) -> list[Requirement]:. The quote characters leak into the LLM-facing template verbatim.
get_argument() checks param.annotation is str to decide whether to quote a value for the prompt. Under PEP 563 the annotation is the string "str", not the str type, so the check silently fails and string arguments are rendered unquoted.
Reproduction
from __future__ importannotationsfromdataclassesimportdataclassfrommellea.stdlib.components.genstubimportdescribe_function@dataclassclassRequirement:
id: strtext: strdefextract_requirements(product_description: str) ->list[Requirement]:
"""Extract requirements from a product description."""print(describe_function(extract_requirements)["signature"])
# def extract_requirements(product_description: 'str') -> 'list[Requirement]':
Impact
Only templates that render function.signature directly are exposed to point 1 (e.g. mellea/templates/prompts/default/GenerativeStub.jinja2); templates that never render the raw signature are unaffected. This means any prompt-template A/B comparison built on PEP 563-style fixture modules is asymmetrically biased against signature-rendering templates, independent of the templates' actual quality. Point 2 affects every template, since it corrupts argument values rather than the signature.
Activity
fix(stdlib): drop stale issue ref and guard PEP 563 test preconditions
fix(stdlib): resolve postponed annotations in generative stub signatu…
fix(stdlib): resolve genstub annotations without failing on TYPE_CHEC…
fix(stdlib): resolve genstub annotations without failing on TYPE_CHEC…
fix: resolve postponed annotations without failing on TYPE_CHECKING r…