Open
Description
Apologies if this was already reported. I could not find an existing issue.
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=7b4923efe4d5bad055733ce5e8f9a2f7
def fn(x: int | None) -> None:
pass
def test(n: int) -> None:
x = None
for _ in range(n):
fn(x)
x = "123"
Expected Behavior
This should give an error because the type of x
in test
is str | None
, but fn
requires int | None
.
Actual Behavior
No errors.
Your Environment
- Mypy version used: 1.5.1
- Python version used: 3.11