@@ -5553,25 +5553,6 @@ def foobar(x: List['X']): ...
55535553 get_type_hints (foobar , globals (), locals (), include_extras = True ),
55545554 {'x' : List [Annotated [int , (1 , 10 )]]}
55555555 )
5556- def foobar2 (x : list ['X' ]): ...
5557- if sys .version_info >= (3 , 11 ):
5558- self .assertEqual (
5559- get_type_hints (foobar2 , globals (), locals ()),
5560- {'x' : list [int ]}
5561- )
5562- self .assertEqual (
5563- get_type_hints (foobar2 , globals (), locals (), include_extras = True ),
5564- {'x' : list [Annotated [int , (1 , 10 )]]}
5565- )
5566- else : # TODO: evaluate nested forward refs in Python < 3.11
5567- self .assertEqual (
5568- get_type_hints (foobar2 , globals (), locals ()),
5569- {'x' : list ['X' ]}
5570- )
5571- self .assertEqual (
5572- get_type_hints (foobar2 , globals (), locals (), include_extras = True ),
5573- {'x' : list ['X' ]}
5574- )
55755556 BA = Tuple [Annotated [T , (1 , 0 )], ...]
55765557 def barfoo (x : BA ): ...
55775558 self .assertEqual (get_type_hints (barfoo , globals (), locals ())['x' ], Tuple [T , ...])
@@ -5592,6 +5573,19 @@ def barfoo3(x: BA2): ...
55925573 BA2
55935574 )
55945575
5576+ @skipUnless (sys .version_info >= (3 , 11 ), "TODO: evaluate nested forward refs in Python < 3.11" )
5577+ def test_get_type_hints_genericalias (self ):
5578+ def foobar (x : list ['X' ]): ...
5579+ X = Annotated [int , (1 , 10 )]
5580+ self .assertEqual (
5581+ get_type_hints (foobar , globals (), locals ()),
5582+ {'x' : list [int ]}
5583+ )
5584+ self .assertEqual (
5585+ get_type_hints (foobar , globals (), locals (), include_extras = True ),
5586+ {'x' : list [Annotated [int , (1 , 10 )]]}
5587+ )
5588+
55955589 def test_get_type_hints_refs (self ):
55965590
55975591 Const = Annotated [T , "Const" ]
0 commit comments