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
My expectation is that in func2-func4, the Union type of x will always narrow down to support b as well as a when y is not supplied and x must be assigned to y/y2.
Actual Behavior
mypy==0.910:
$ mypy --show-error-codes _scratch.py
_scratch.py:20: error: Incompatible types in assignment (expression has type "Union[Callable[[str], int], Callable[[int], int]]", variable has type "Optional[Callable[[str], int]]") [assignment]
_scratch.py:21: error: "None" not callable [misc]
_scratch.py:42: error: Incompatible types in assignment (expression has type "Union[Callable[[int], int], Callable[[Union[int, str]], int]]", variable has type "Callable[[str], int]") [assignment]
_scratch.py:64: error: Incompatible types in assignment (expression has type "Union[List[int], List[Union[int, str]]]", variable has type "List[str]") [assignment]
mypy==0.920.dev:
_scratch.py:20: error: Incompatible types in assignment (expression has type "Union[Callable[[str], int], Callable[[int], int]]", variable has type "Optional[Callable[[str], int]]") [assignment]
_scratch.py:21: error: "None" not callable [misc]
_scratch.py:42: error: Incompatible types in assignment (expression has type "Union[Callable[[int], int], Callable[[Union[int, str]], int]]", variable has type "Callable[[str], int]") [assignment]
_scratch.py:64: error: Incompatible types in assignment (expression has type "Union[List[int], List[Union[int, str]]]", variable has type "List[str]") [assignment]
_scratch.py:72: error: Cannot call function of unknown type [operator]
Instead, no narrowing occurs and mypy declares the types incompatible, both when Callable is used and when a standard collection is used.
Your Environment
Mypy version used: 0.910 and 0.920+dev.cee5d3e9a29f43a10a8eeca760976657bf1689c9
Mypy command-line flags: --show-error-codes
Python version used: Python 3.8.0
Operating system and version: Microsoft Windows 10 [Version 10.0.19043.1348]
The text was updated successfully, but these errors were encountered:
Bug Report
Mypy fails to find type narrowings that use a combination of overloading and null checks.
To Reproduce
Expected Behavior
My expectation is that in func2-func4, the Union type of
x
will always narrow down to supportb
as well asa
wheny
is not supplied andx
must be assigned toy
/y2
.Actual Behavior
mypy==0.910:
mypy==0.920.dev:
Instead, no narrowing occurs and mypy declares the types incompatible, both when Callable is used and when a standard collection is used.
Your Environment
0.910
and0.920+dev.cee5d3e9a29f43a10a8eeca760976657bf1689c9
--show-error-codes
The text was updated successfully, but these errors were encountered: