File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -7152,6 +7152,25 @@ class C:
71527152 self .assertEqual (get_type_hints (C , format = annotationlib .Format .STRING ),
71537153 {'x' : 'undefined' })
71547154
7155+ def test_get_type_hints_format_function (self ):
7156+ def func (x : undefined ) -> undefined : ...
7157+
7158+ # VALUE
7159+ with self .assertRaises (NameError ):
7160+ get_type_hints (func )
7161+ with self .assertRaises (NameError ):
7162+ get_type_hints (func , format = annotationlib .Format .VALUE )
7163+
7164+ # FORWARDREF
7165+ self .assertEqual (
7166+ get_type_hints (func , format = annotationlib .Format .FORWARDREF ),
7167+ {'x' : ForwardRef ('undefined' ), 'return' : ForwardRef ('undefined' )},
7168+ )
7169+
7170+ # STRING
7171+ self .assertEqual (get_type_hints (func , format = annotationlib .Format .STRING ),
7172+ {'x' : 'undefined' , 'return' : 'undefined' })
7173+
71557174
71567175class GetUtilitiesTestCase (TestCase ):
71577176 def test_get_origin (self ):
You can’t perform that action at this time.
0 commit comments