Fix crash on unimported Any with Required/NotRequired#17609
Fix crash on unimported Any with Required/NotRequired#17609andersk wants to merge 1 commit intopython:masterfrom
Any with Required/NotRequired#17609Conversation
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 <andersk@mit.edu>
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.
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.
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.
I am not sure about it :)
cc @JukkaL and @ilevkivskyi
There was a problem hiding this comment.
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.
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.)