Skip to content

馃悰 fix(annotations): defer alias expansion - #766

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
flying-sheep:defer
Sep 8, 2026
Merged

馃悰 fix(annotations): defer alias expansion#766
gaborbernat merged 2 commits into
tox-dev:mainfrom
flying-sheep:defer

Conversation

@flying-sheep

@flying-sheep flying-sheep commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Get rid of the order dependency of the alias expansion.

Now a type alias gets expanded when it鈥檚 not documented and not expanded when it鈥檚 documented.

After this PR (or as part of this PR), the code base could be simplified a bit by always deferring and resolving everything in the end, instead of opportunistically resolving things that can be resolved and deferring the rest.

@flying-sheep flying-sheep changed the title fix: defer alias expansion 馃悰 fix(annotations): defer alias expansion Sep 4, 2026
@flying-sheep
flying-sheep marked this pull request as ready for review September 4, 2026 10:10
Comment on lines +42 to +44
def unescape(escaped: str) -> str:
escaped = escaped.replace("\x00", "")
return _UNESCAPE_RE.sub(r"\1", escaped)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved this over here to prevent circular imports, and I think it fits here pretty well anyway.

Comment thread tests/test_pep695.py
Comment on lines -574 to +575
assert '"int" | "list"["RecType"]' in result
# documented further down the same document, which only the resolve phase can know
assert '**some_param** ("RecType")' in result

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test changed because we鈥檙e now better at not expanding things that are documented.

@gaborbernat
gaborbernat merged commit 31598c2 into tox-dev:main Sep 8, 2026
10 checks passed
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.

2 participants