mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-138151: Fix annotationlib handling of multiple nonlocals (#138164)
This commit is contained in:
parent
d590685297
commit
b1027d4762
3 changed files with 45 additions and 13 deletions
|
|
@ -1194,6 +1194,21 @@ class RaisesAttributeError:
|
|||
},
|
||||
)
|
||||
|
||||
def test_nonlocal_in_annotation_scope(self):
|
||||
class Demo:
|
||||
nonlocal sequence_b
|
||||
x: sequence_b
|
||||
y: sequence_b[int]
|
||||
|
||||
fwdrefs = get_annotations(Demo, format=Format.FORWARDREF)
|
||||
|
||||
self.assertIsInstance(fwdrefs["x"], ForwardRef)
|
||||
self.assertIsInstance(fwdrefs["y"], ForwardRef)
|
||||
|
||||
sequence_b = list
|
||||
self.assertIs(fwdrefs["x"].evaluate(), list)
|
||||
self.assertEqual(fwdrefs["y"].evaluate(), list[int])
|
||||
|
||||
def test_raises_error_from_value(self):
|
||||
# test that if VALUE is the only supported format, but raises an error
|
||||
# that error is propagated from get_annotations
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue