Skip to content

Commit 7ccaafa

Browse files
committed
typeddicts - reading not required keys
1 parent 29d155a commit 7ccaafa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

conformance/tests/typeddicts_operations.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ class MovieOptional(TypedDict, total=False):
6969

7070
movie_optional: MovieOptional = {}
7171

72+
# > Type checkers may allow reading an item using d['x']
73+
# even if the key 'x' is not required.
74+
movie_optional["name"] # E?
7275
assert_type(movie_optional.get("name"), str | None)
7376

77+
# > Type checkers may allow 'x' in d even if the key 'x' is not required.
78+
reveal_type("name" in movie_optional) # E?
79+
7480
movie_optional.clear() # E: clear not allowed
7581
movie_optional.popitem() # E: popitem not allowed
7682

0 commit comments

Comments
 (0)