mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-41341: Recursive evaluation of ForwardRef in get_type_hints (#21553)
The issue raised by recursive evaluation is infinite recursion with recursive types. In that case, only the first recursive ForwardRef is evaluated.
This commit is contained in:
parent
bf2f76ec09
commit
653f420b53
3 changed files with 21 additions and 6 deletions
|
|
@ -2456,6 +2456,12 @@ class ForwardRefTests(BaseTestCase):
|
|||
self.assertEqual(get_type_hints(foo, globals(), locals()),
|
||||
{'a': tuple[T]})
|
||||
|
||||
def test_double_forward(self):
|
||||
def foo(a: 'List[\'int\']'):
|
||||
pass
|
||||
self.assertEqual(get_type_hints(foo, globals(), locals()),
|
||||
{'a': List[int]})
|
||||
|
||||
def test_forward_recursion_actually(self):
|
||||
def namespace1():
|
||||
a = typing.ForwardRef('A')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue