bpo-46655: allow stringized TypeAlias with get_type_hints (GH-31156)

This commit is contained in:
Gregory Beauregard 2022-02-06 15:16:22 -08:00 committed by GitHub
parent 06b8f1615b
commit 77b025be4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View file

@ -4866,6 +4866,11 @@ class TypeAliasTests(BaseTestCase):
with self.assertRaises(TypeError):
isinstance(42, TypeAlias)
def test_stringized_usage(self):
class A:
a: "TypeAlias"
self.assertEqual(get_type_hints(A), {'a': TypeAlias})
def test_no_issubclass(self):
with self.assertRaises(TypeError):
issubclass(Employee, TypeAlias)