Handle interactions between recursive aliases and recursive instances#13328
Handle interactions between recursive aliases and recursive instances#13328ilevkivskyi merged 7 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
hauntsaninja
left a comment
There was a problem hiding this comment.
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