diff options
author | Gregory Beauregard <greg@greg.red> | 2022-01-28 16:58:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-28 16:58:39 (GMT) |
commit | 5445e173e76ec792358082caf660fbdc846c64b2 (patch) | |
tree | 3def2baf86fec5a64b0f5e234c94da3b2e1afe73 /Lib/test/test_typing.py | |
parent | 45faf151c693b6f13f78926761caea6df7242024 (diff) | |
download | cpython-5445e173e76ec792358082caf660fbdc846c64b2.zip cpython-5445e173e76ec792358082caf660fbdc846c64b2.tar.gz cpython-5445e173e76ec792358082caf660fbdc846c64b2.tar.bz2 |
bpo-46553: allow bare typing.ClassVar annotations (#30983)
These are used in the wild and covered by dataclasses unit tests.
Several static type checkers support this pattern.
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r-- | Lib/test/test_typing.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 3069331..8449aff 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -2071,7 +2071,7 @@ class GenericTests(BaseTestCase): with self.assertRaises(TypeError): Tuple[Optional] with self.assertRaises(TypeError): - ClassVar[ClassVar] + ClassVar[ClassVar[int]] with self.assertRaises(TypeError): List[ClassVar[int]] @@ -2896,12 +2896,16 @@ class ForwardRefTests(BaseTestCase): class C: a: Annotated['ClassVar[int]', (3, 5)] = 4 b: Annotated['Final[int]', "const"] = 4 + x: 'ClassVar' = 4 + y: 'Final' = 4 class CF: b: List['Final[int]'] = 4 self.assertEqual(get_type_hints(C, globals())['a'], ClassVar[int]) self.assertEqual(get_type_hints(C, globals())['b'], Final[int]) + self.assertEqual(get_type_hints(C, globals())['x'], ClassVar) + self.assertEqual(get_type_hints(C, globals())['y'], Final) with self.assertRaises(TypeError): get_type_hints(CF, globals()), |