Closed
Description
Bug Report
Mypy seems to assume that for loop body executes at least once when inferring index variable types.
To Reproduce
x: int | str
x = "abc"
for x in list[int]():
pass
reveal_type(x) # int
Expected Behavior
Revealed type is int | str
.
Actual Behavior
Revealed type is int
.
Your Environment
Latest master.