Skip to content

Commit b5050c0

Browse files
fixup! Add type inference for dict.keys membership
1 parent 903b0c8 commit b5050c0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test-data/unit/check-isinstance.test

+4-3
Original file line numberDiff line numberDiff line change
@@ -2072,9 +2072,10 @@ from typing import Dict, Optional
20722072
def f() -> None:
20732073
d: Dict[str, str] = {}
20742074
key: Optional[str]
2075-
if key not in d.keys():
2076-
return
2077-
reveal_type(key) # N: Revealed type is "builtins.str"
2075+
if key in d.keys():
2076+
reveal_type(key) # N: Revealed type is "builtins.str"
2077+
else:
2078+
reveal_type(key) # N: Revealed type is "Union[builtins.str, None]"
20782079
[builtins fixtures/dict.pyi]
20792080

20802081
[case testIsinstanceWidensWithAnyArg]

0 commit comments

Comments
 (0)