-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fix crash on unimported Any
with Required
/NotRequired
#17609
Conversation
f8d9715
to
0e12293
Compare
Fixes python#17604; fixes python#17608. (To reproduce the crash without mypyc, replace `cast(ProperType, typ)` with an assertion in `get_proper_type`.) Signed-off-by: Anders Kaseorg <[email protected]>
0e12293
to
071f0f3
Compare
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
self.msg.unimported_type_becomes_any("Type of variable", s.type, s) | ||
self.msg.unimported_type_becomes_any( | ||
"Type of variable", | ||
s.type.item if isinstance(s.type, RequiredType) else s.type, |
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.
Maybe it would be better to use some existing function to covert RequiredType
to ProperType
? Like get_proper_type
? Or maybe something similar. Right now it feels too specific.
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.
get_proper_type
is already being called—that’s where it’s crashing. It doesn’t convert RequiredType
. Should it? That seems like a much bigger change though.
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.
I am not sure about it :)
cc @JukkaL and @ilevkivskyi
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 PR is not a fix, but a horrible dirty hack. I am actually going to revert another recent crash "fix" by @andersk and replace it with a proper one when I will have time.
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.
Sorry to have offended you!
Superseded by #17640 |
--html-report
#17604.(To reproduce the crash without mypyc, replace
cast(ProperType, typ)
with an assertion inget_proper_type
.)