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
$ mypy --warn-unreachable scratch.py
scratch.py:9: note: Revealed type is 'None'
scratch.py:13: error: Right operand of 'and' is never evaluated
scratch.py:14: error: Statement is unreachable
scratch.py:17: note: Revealed type is 'builtins.int*'
scratch.py:18: note: Revealed type is 'Union[builtins.int*, None]'
This is clearly false -- it is possible for the prev != 999 to actually run. The reveal_types indicate that this has something to do with type inference: although mypy successfully infers that prev is Optional[int] after the for loop, it does not combine the int and None types during the for loop.
The text was updated successfully, but these errors were encountered:
Using
mypy 0.761
on Python 3.6, the following code, runningmypy --warn-unreachable
on the following code fails:with
This is clearly false -- it is possible for the
prev != 999
to actually run. Thereveal_type
s indicate that this has something to do with type inference: althoughmypy
successfully infers thatprev
isOptional[int]
after the for loop, it does not combine theint
andNone
types during the for loop.The text was updated successfully, but these errors were encountered: