fromtypingimportAny, Optionaldeffoo() ->Optional[int]:
return42raz: Anydefbar() ->int:
x=foo()
ifisinstance(x, int):
reveal_type(x)
x=raz()
reveal_type(x)
x=x+42return0
$ python3.6 -m mypy --strict-optional test_optional_assign.py
test_optional_assign.py:11: error: Revealed type is 'builtins.int'
test_optional_assign.py:13: error: Revealed type is 'Union[builtins.int, builtins.None]'
test_optional_assign.py:14: error: Unsupported operand types for + ("Optional[int]" and "int")I would have expected the revealed type at like 13 to be Any.
I would have expected the revealed type at like 13 to be
Any.