-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Prevent crash on generic NamedTuple with unresolved typevar bound #18585
base: master
Are you sure you want to change the base?
Prevent crash on generic NamedTuple with unresolved typevar bound #18585
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.
Thanks for taking a look, this makes sense. Let's merge this and try and get it into the release, since it's been reported multiple times.
I'm not sure about TypeQuery / BoolTypeQuery, probably makes sense to try? Would also be good to try and get a regression test working.
Nice catch! Yes, I think fixing this in For more context, |
This comment has been minimized.
This comment has been minimized.
Both primer hits appear to reveal a different problem, reproducible as follows:
The inferred type is:
nothing suspicious, but...
So when inferring list expr type as a constructor call, we synthetize a fully defined tuple with a partially unknown fallback (union of all initial values). I think it's fine to keep for now and investigate separately? And I'm still unable to write a testcase for the original problem, any suggestions are welcome! |
Alternatively, we can exclude fallback in |
This looks like a good short-term solution. Long term we may actually want to completely erase the fallback argument in Could you please skip fallback for now, and add a TODO there? (And maybe make a follow up PR if you have time) |
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Fixes #18582. Fixes #17396. Supersedes #18351.
cc @hauntsaninja - see my comments on your original PR, maybe this change should be lifted to BoolTypeQuery and TypeQuery instead? (opening a separate PR to see CI results)