@@ -4872,6 +4872,18 @@ class NontotalMovie(TypedDict, total=False):
4872
4872
title : Required [str ]
4873
4873
year : int
4874
4874
4875
+ class ParentNontotalMovie (TypedDict , total = False ):
4876
+ title : Required [str ]
4877
+
4878
+ class ChildTotalMovie (ParentNontotalMovie ):
4879
+ year : NotRequired [int ]
4880
+
4881
+ class ParentDeeplyAnnotatedMovie (TypedDict ):
4882
+ title : Annotated [Annotated [Required [str ], "foobar" ], "another level" ]
4883
+
4884
+ class ChildDeeplyAnnotatedMovie (ParentDeeplyAnnotatedMovie ):
4885
+ year : NotRequired [Annotated [int , 2000 ]]
4886
+
4875
4887
class AnnotatedMovie (TypedDict ):
4876
4888
title : Annotated [Required [str ], "foobar" ]
4877
4889
year : NotRequired [Annotated [int , 2000 ]]
@@ -5201,6 +5213,17 @@ def test_get_type_hints_typeddict(self):
5201
5213
'a' : Annotated [Required [int ], "a" , "b" , "c" ]
5202
5214
})
5203
5215
5216
+ self .assertEqual (get_type_hints (ChildTotalMovie ), {"title" : str , "year" : int })
5217
+ self .assertEqual (get_type_hints (ChildTotalMovie , include_extras = True ), {
5218
+ "title" : Required [str ], "year" : NotRequired [int ]
5219
+ })
5220
+
5221
+ self .assertEqual (get_type_hints (ChildDeeplyAnnotatedMovie ), {"title" : str , "year" : int })
5222
+ self .assertEqual (get_type_hints (ChildDeeplyAnnotatedMovie , include_extras = True ), {
5223
+ "title" : Annotated [Required [str ], "foobar" , "another level" ],
5224
+ "year" : NotRequired [Annotated [int , 2000 ]]
5225
+ })
5226
+
5204
5227
def test_get_type_hints_collections_abc_callable (self ):
5205
5228
# https://github.com/python/cpython/issues/91621
5206
5229
P = ParamSpec ('P' )
@@ -6340,6 +6363,16 @@ def test_required_notrequired_keys(self):
6340
6363
self .assertEqual (WeirdlyQuotedMovie .__optional_keys__ ,
6341
6364
frozenset ({"year" }))
6342
6365
6366
+ self .assertEqual (ChildTotalMovie .__required_keys__ ,
6367
+ frozenset ({"title" }))
6368
+ self .assertEqual (ChildTotalMovie .__optional_keys__ ,
6369
+ frozenset ({"year" }))
6370
+
6371
+ self .assertEqual (ChildDeeplyAnnotatedMovie .__required_keys__ ,
6372
+ frozenset ({"title" }))
6373
+ self .assertEqual (ChildDeeplyAnnotatedMovie .__optional_keys__ ,
6374
+ frozenset ({"year" }))
6375
+
6343
6376
def test_multiple_inheritance (self ):
6344
6377
class One (TypedDict ):
6345
6378
one : int
0 commit comments