Skip to content
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

[PEP 695] Support recursive type aliases #17268

Merged
merged 5 commits into from
May 30, 2024

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented May 20, 2024

The implementation follows the approach used for old-style type aliases.

Work on #15238.

@JukkaL JukkaL requested a review from ilevkivskyi May 20, 2024 11:12

This comment has been minimized.

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

One question, otherwise LGTM

mypy/semanal.py Outdated
# for a TypeInfo _in place_ if there are nested placeholders.
existing.node.target = res
existing.node.alias_tvars = alias_tvars
# existing.node.no_args = no_args
Copy link
Member

Choose a reason for hiding this comment

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

Why is this commented out? IIRC this is to support prehistoric edge case where you have

A = B
B = C
C = D

and D is generic class. In such cases A[int] is allowed and equivalent to D[int]. If this works without this line then just delete it. (Or maybe this use case is explicitly prohibited with the new syntax, then I guess this is not needed either). For context, IIRC this was initially allowed for aliases like List = list + forward references.

Copy link
Collaborator Author

@JukkaL JukkaL May 30, 2024

Choose a reason for hiding this comment

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

This is not supported by the new syntax. Type parameters need to be explicit. I will delete the line.

Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@JukkaL JukkaL merged commit 0820e95 into master May 30, 2024
18 checks passed
@JukkaL JukkaL deleted the type-var-syntax-3-recursive-alias branch May 30, 2024 14:48
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