Commit dc409ce
committed
fix: do not narrow expression type to TypeVar on equality comparison
When a variable is compared with == against a TypeVar operand, mypy was
narrowing its type to the TypeVar, causing false errors on subsequent
operations. The regression was introduced in #20602.
Skip narrowing in narrow_type_by_identity_equality when the target type
is a TypeVarLikeType. Fixes #211991 parent f315c8a commit dc409ce
2 files changed
+37
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6787 | 6787 | | |
6788 | 6788 | | |
6789 | 6789 | | |
| 6790 | + | |
| 6791 | + | |
| 6792 | + | |
| 6793 | + | |
| 6794 | + | |
| 6795 | + | |
| 6796 | + | |
6790 | 6797 | | |
6791 | 6798 | | |
6792 | 6799 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3993 | 3993 | | |
3994 | 3994 | | |
3995 | 3995 | | |
| 3996 | + | |
| 3997 | + | |
| 3998 | + | |
| 3999 | + | |
| 4000 | + | |
| 4001 | + | |
| 4002 | + | |
| 4003 | + | |
| 4004 | + | |
| 4005 | + | |
| 4006 | + | |
| 4007 | + | |
| 4008 | + | |
| 4009 | + | |
| 4010 | + | |
| 4011 | + | |
| 4012 | + | |
| 4013 | + | |
| 4014 | + | |
| 4015 | + | |
| 4016 | + | |
| 4017 | + | |
| 4018 | + | |
| 4019 | + | |
| 4020 | + | |
| 4021 | + | |
| 4022 | + | |
| 4023 | + | |
| 4024 | + | |
| 4025 | + | |
0 commit comments