Skip to content

Commit 4710651

Browse files
committed
Merge remote-tracking branch 'upstream/master' into bugfix/st-multiple-inheritance-compat
2 parents 94bc355 + ac89577 commit 4710651

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test-data/unit/check-isinstance.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,3 +2917,18 @@ if hasattr(mod, "y"):
29172917
[file mod.py]
29182918
def __getattr__(attr: str) -> str: ...
29192919
[builtins fixtures/module.pyi]
2920+
2921+
[case testTypeIsntLostAfterNarrowing]
2922+
from typing import Any
2923+
2924+
var: Any
2925+
reveal_type(var) # N: Revealed type is "Any"
2926+
assert isinstance(var, (bool, str))
2927+
reveal_type(var) # N: Revealed type is "Union[builtins.bool, builtins.str]"
2928+
2929+
if isinstance(var, bool):
2930+
reveal_type(var) # N: Revealed type is "builtins.bool"
2931+
2932+
# Type of var shouldn't fall back to Any
2933+
reveal_type(var) # N: Revealed type is "Union[builtins.bool, builtins.str]"
2934+
[builtins fixtures/isinstance.pyi]

0 commit comments

Comments
 (0)