You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve the support for promotions inside unions. (#19245)
Fixes#14987
I was puzzled as to why my previous attempts to avoid false
`unreachable` warnings for loops failed for issue #14987. After some
debugging, I realised that the underlying problem is that type narrowing
does not work with promotions if both the declared type and the
constraining type are unions:
```python
x: float | None
y: int | None
x = y
reveal_type(x) # None !!!
```
The fix seems straightforward (but let's see what the Mypy primer says)
and is checked by the test cases `testNarrowPromotionsInsideUnions1` and
`testNarrowPromotionsInsideUnions2`.
---------
Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
0 commit comments