There was an error while loading. Please reload this page.
typing.get_type_hints
1 parent ea39c8b commit 43ac9f5Copy full SHA for 43ac9f5
1 file changed
Lib/test/test_typing.py
@@ -7152,6 +7152,25 @@ class C:
7152
self.assertEqual(get_type_hints(C, format=annotationlib.Format.STRING),
7153
{'x': 'undefined'})
7154
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
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
7174
7175
class GetUtilitiesTestCase(TestCase):
7176
def test_get_origin(self):
0 commit comments