Commit 8b6d213
authored
Fix partially defined in the case of missing type maps (#15995)
Thanks AlexWaygood for sending me on this adventure. This took me a
while for me to debug!
When we don't need to warn about unreachable code, we don't end up
calling `self.is_noop_for_reachability(s)` (which is meant to tell us
whether the code should be warned about or is `raise AssertionError` or
`typing.assert_never(never)` or something).
https://github.com/python/mypy/blob/6f650cff9ab21f81069e0ae30c92eae94219ea63/mypy/checker.py#L2748
This innocuous check has a side effect that turns out to be important
for the partially undefined checks. These checks work by reaching into
the type map populated by the checker. But if we never actually ended up
analysing the code, we never populate the type map.
This therefore changes things to assume that if we couldn't find the
expression in the type map, it's probably because it was unreachable.1 parent e87b62f commit 8b6d213
File tree
2 files changed
+18
-1
lines changed- mypy
- test-data/unit
2 files changed
+18
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
509 | | - | |
| 509 | + | |
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1026 | 1026 | | |
1027 | 1027 | | |
1028 | 1028 | | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
0 commit comments