Closed
Description
union_any.py
:
from typing import Any, Union
def func(v):
# type: (Union[int, Any]) -> str
if isinstance(v, int):
s = hex(v)
else:
s = str(v).lower()
return "key:" + s
mypy union_any.py
:
union_any.py: note: In function "func":
union_any.py:8: error: No overload variant of "str" matches argument types [Union[<ERROR>, void]]
mypy --py2 union_any.py
:
union_any.py: note: In function "func":
union_any.py:8: error: Argument 1 to "str" has incompatible type "Union[object, None]"; expected "object"
I discovered this when I used a class which was defined in some library which did not have stubs and I was using --silent-imports
.