We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ec4ccb0 commit ac89577Copy full SHA for ac89577
test-data/unit/check-isinstance.test
@@ -2917,3 +2917,18 @@ if hasattr(mod, "y"):
2917
[file mod.py]
2918
def __getattr__(attr: str) -> str: ...
2919
[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
2934
+[builtins fixtures/isinstance.pyi]
0 commit comments