Commit dbea92a
committed
Fix value-in-container narrowing widening to non-subtypes (#21512)
When narrowing `x` in `x in container`, mypy used __eq__-based
narrowing which could widen `x` to the container's item type even when
that type is not a proper subtype of `x`'s declared type. Discard the
if-branch narrowing result when it is not a proper subtype of the
original type.1 parent 5e0c274 commit dbea92a
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6831 | 6831 | | |
6832 | 6832 | | |
6833 | 6833 | | |
| 6834 | + | |
| 6835 | + | |
| 6836 | + | |
| 6837 | + | |
| 6838 | + | |
| 6839 | + | |
| 6840 | + | |
| 6841 | + | |
| 6842 | + | |
| 6843 | + | |
6834 | 6844 | | |
6835 | 6845 | | |
6836 | 6846 | | |
| |||
0 commit comments