Invoked with: python3.6 -m mypy --warn-no-return --strict-optional test_or_shortcut.py
from typing import Optional, Any
def test_or_shortcut(value: Optional[Any]) -> None:
if not value:
pass
if not value or value.get('foo') == 'hello':
pass
Fails with:
test_or_shortcut.py:7: error: Item "None" of "Optional[Any]" has no attribute "get"
Oddly if I remove the first branch things typecheck fine:
from typing import Optional, Any
def test_or_shortcut(value: Optional[Any]) -> None:
if not value or value.get('foo') == 'hello':
pass