Skip to content

Always re-process annotations refering to an alias on update #13759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2022

Conversation

ilevkivskyi
Copy link
Member

This should fix a crash discovered by mypy_primer in #13516

The logic here is that when type aliases have placeholders they are updated in place (the node gets a new resolved target type). But this means that some variables annotated with type aliases may not get stored types, unless we defer targets where they are defined.

This didn't cause troubles before, because we waited for type alias to be complete before putting it into symbol table. Now it is not possible, we need to put something into symbol table for partially complete aliases to support recursive aliases (similar to recursive classes).

Also, it was tricky to come up with a repro for this issue, because when it happens, the variable gets a "silent" Any type, and only when it appears in a dataclass, it causes a crash.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@ilevkivskyi ilevkivskyi merged commit 0f4e0fb into python:master Sep 29, 2022
@ilevkivskyi ilevkivskyi deleted the fix-annot-alias branch September 29, 2022 12:23
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