gh-119180: Add annotationlib module to support PEP 649 (#119891)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Jelle Zijlstra 2024-07-23 14:16:50 -07:00 committed by GitHub
parent 64e221d7ad
commit 7b7b90d1ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 1815 additions and 510 deletions

View file

@ -3,6 +3,7 @@
from test.support import check_syntax_error
from test.support import import_helper
import annotationlib
import inspect
import unittest
import sys
@ -459,7 +460,7 @@ class GrammarTests(unittest.TestCase):
gns = {}; lns = {}
exec("'docstring'\n"
"x: int = 5\n", gns, lns)
self.assertEqual(lns["__annotate__"](1), {'x': int})
self.assertEqual(lns["__annotate__"](annotationlib.Format.VALUE), {'x': int})
with self.assertRaises(KeyError):
gns['__annotate__']