-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongdocumentationtopic-reachabilityDetecting unreachable codeDetecting unreachable code
Description
Given this code:
from typing import reveal_type
x: complex = 1
reveal_type(x)
if isinstance(x, int):
reveal_type(x)
mypy 0.990:
% mypy --strict --warn-unreachable ~/py/tmp/compl.py
/Users/jelle/py/tmp/compl.py:3: note: Revealed type is "builtins.complex"
/Users/jelle/py/tmp/compl.py:4: error: Subclass of "complex" and "int" cannot exist: would have incompatible method signatures [unreachable]
/Users/jelle/py/tmp/compl.py:5: error: Statement is unreachable [unreachable]
Found 2 errors in 1 file (checked 1 source file)
mypy 0.982:
% mypy --strict --warn-unreachable ~/py/tmp/compl.py
/Users/jelle/py/tmp/compl.py:3: note: Revealed type is "builtins.complex"
/Users/jelle/py/tmp/compl.py:5: note: Revealed type is "builtins.int"
Success: no issues found in 1 source file
The 0.982 behavior is correct, since int
is a subclass of complex
in the static type system.
AlexWaygood
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongdocumentationtopic-reachabilityDetecting unreachable codeDetecting unreachable code