-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Handle interactions between recursive aliases and recursive instances #13328
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
Conversation
This comment has been minimized.
This comment has been minimized.
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.
Looks great. Yeah, that is curious, but it makes sense (pyright also does the same thing)
I will add couple more cases with a bit more principled inference recursion detection. Btw there is a thing that complicates things that is not specific to recursive types (see e.g. #11149), when mypy sees things like EDIT: fixed the direction when this causes problems |
I actually added a bit of special-casing to handle the above problem specifically for recursive types. It should handle most of simple cases. I don't want to add this in general, as constraints inference is a very sensitive place. |
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
This is a follow-up for #13297
The fix for infinite recursion is kind of simple, but it is hard to make inference infer something useful. Currently we handle all most common cases, but it is quite fragile (I however have few tricks left if people will complain about inference).
Btw a curious thing: it looks like
"hm..."
is a valid value forNested = Sequence[Union[int, Nested]]
.cc @JukkaL