Skip to content

Resolve forward references in generated init annotations - #1619

Open
Nikhi00718 wants to merge 2 commits into
python-attrs:mainfrom
Nikhi00718:codex/attrs-1596
Open

Resolve forward references in generated init annotations#1619
Nikhi00718 wants to merge 2 commits into
python-attrs:mainfrom
Nikhi00718:codex/attrs-1596

Conversation

@Nikhi00718

Copy link
Copy Markdown

Fixes #1596.

On Python 3.14, generated attrs initializers can lose access to forward references declared later in the defining module because their private globals dictionary is copied during decoration. This adds a lazy annotation provider that resolves generated initializer annotations against the defining module while preserving unresolved forward references. A regression test covers inspect.signature(..., eval_str=True) and typing.get_type_hints().

Tests: python -m pytest tests -q (1,408 passed, 4 skipped, 2 xfailed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect annotation for forward reference in generated constructor

1 participant