-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[red-knot] PEP 695 type aliases #14357
Conversation
ceb5916
to
f56e867
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to do a VC call next week if anything remains unclear about how this is all supposed to work!
9f827d6
to
b9d931c
Compare
|
e8c92e3
to
06e615d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated type inference structure looks great!
// fails with salsa cycle panic: | ||
("crates/ruff_python_parser/resources/inline/err/type_alias_invalid_value_expr.py", true, true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting. I suspect it might go away if we stop trying to infer the type of .value()
on a type alias anytime we encounter it. If not I'll want to take a closer look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It happens for self-referential type aliases like type NestedInt = int | list[NestedInt]
. We form a genuine cycle when inferring the annotation type on the RHS and look up the name NestedInt
.
06e615d
to
2a7070d
Compare
Summary
Add support for (non-generic) type aliases. The main motivation behind this was to get rid of panics involving expressions in (generic) type aliases. But it turned out the best way to fix it was to implement (partial) support for type aliases.
Test Plan
type_alias.md
)