@@ -4892,6 +4892,18 @@ class NontotalMovie(TypedDict, total=False):
4892
4892
title : Required [str ]
4893
4893
year : int
4894
4894
4895
+ class ParentNontotalMovie (TypedDict , total = False ):
4896
+ title : Required [str ]
4897
+
4898
+ class ChildTotalMovie (ParentNontotalMovie ):
4899
+ year : NotRequired [int ]
4900
+
4901
+ class ParentDeeplyAnnotatedMovie (TypedDict ):
4902
+ title : Annotated [Annotated [Required [str ], "foobar" ], "another level" ]
4903
+
4904
+ class ChildDeeplyAnnotatedMovie (ParentDeeplyAnnotatedMovie ):
4905
+ year : NotRequired [Annotated [int , 2000 ]]
4906
+
4895
4907
class AnnotatedMovie (TypedDict ):
4896
4908
title : Annotated [Required [str ], "foobar" ]
4897
4909
year : NotRequired [Annotated [int , 2000 ]]
@@ -5221,6 +5233,17 @@ def test_get_type_hints_typeddict(self):
5221
5233
'a' : Annotated [Required [int ], "a" , "b" , "c" ]
5222
5234
})
5223
5235
5236
+ self .assertEqual (get_type_hints (ChildTotalMovie ), {"title" : str , "year" : int })
5237
+ self .assertEqual (get_type_hints (ChildTotalMovie , include_extras = True ), {
5238
+ "title" : Required [str ], "year" : NotRequired [int ]
5239
+ })
5240
+
5241
+ self .assertEqual (get_type_hints (ChildDeeplyAnnotatedMovie ), {"title" : str , "year" : int })
5242
+ self .assertEqual (get_type_hints (ChildDeeplyAnnotatedMovie , include_extras = True ), {
5243
+ "title" : Annotated [Required [str ], "foobar" , "another level" ],
5244
+ "year" : NotRequired [Annotated [int , 2000 ]]
5245
+ })
5246
+
5224
5247
def test_get_type_hints_collections_abc_callable (self ):
5225
5248
# https://github.com/python/cpython/issues/91621
5226
5249
P = ParamSpec ('P' )
@@ -6381,6 +6404,16 @@ def test_required_notrequired_keys(self):
6381
6404
self .assertEqual (WeirdlyQuotedMovie .__optional_keys__ ,
6382
6405
frozenset ({"year" }))
6383
6406
6407
+ self .assertEqual (ChildTotalMovie .__required_keys__ ,
6408
+ frozenset ({"title" }))
6409
+ self .assertEqual (ChildTotalMovie .__optional_keys__ ,
6410
+ frozenset ({"year" }))
6411
+
6412
+ self .assertEqual (ChildDeeplyAnnotatedMovie .__required_keys__ ,
6413
+ frozenset ({"title" }))
6414
+ self .assertEqual (ChildDeeplyAnnotatedMovie .__optional_keys__ ,
6415
+ frozenset ({"year" }))
6416
+
6384
6417
def test_multiple_inheritance (self ):
6385
6418
class One (TypedDict ):
6386
6419
one : int
0 commit comments