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
File "/Users/someone/code/pytype/test.py", line 15, in<module>: Optional[int] [reveal-type]
File "/Users/someone/code/pytype/test.py", line 18, in<module>: Optional[int] [reveal-type]
File "/Users/someone/code/pytype/test.py", line 21, in<module>: int [reveal-type]
It is surprising to me that y is not inferred as int while x at the end is.
Mypy 0.790 gives as expected:
test.py:15: note: Revealed type is 'Union[builtins.int, None]'
test.py:18: note: Revealed type is 'builtins.int*'
test.py:21: note: Revealed type is 'builtins.int'
The text was updated successfully, but these errors were encountered:
). In matching against Optional[T], once a value matches None, we should return a successful match, rather than going on and matching the value to T as well.
(See python/typing#645 for a related discussion.)
Consider the following file
test.py
:PyType
2020.12.2
gives:It is surprising to me that
y
is not inferred asint
whilex
at the end is.Mypy
0.790
gives as expected:The text was updated successfully, but these errors were encountered: