-
-
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
Retain None (unreachable) when typemap is None with type(x) is Foo
check
#18486
Retain None (unreachable) when typemap is None with type(x) is Foo
check
#18486
Conversation
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
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 good! One nit that might be a little faster
if all(m is None for m in list_maps): | ||
return None | ||
result_map = {} | ||
for d in list_maps: | ||
if d is not None: |
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.
if all(m is None for m in list_maps): | |
return None | |
result_map = {} | |
for d in list_maps: | |
if d is not None: | |
result_map = None | |
for d in list_maps: | |
if d is not None: | |
if result_map is None: | |
result_map = {} |
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'd keep my version if you don't mind: this part isn't hot (only reachable when we actually have some type(x) <op> Something
checks), and I find it more explicit/slightly easier to follow. This shouldn't have any measurable performance impact.
…check (python#18486) Fixes python#18428. Prevents rewriting `None` ("unreachable") typemaps as empty dicts ("nothing to infer")
Fixes #18428.
Prevents rewriting
None
("unreachable") typemaps as empty dicts ("nothing to infer")