mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
gh-124498: Fix TypeAliasType not to be generic, when type_params=() (#124499)
This commit is contained in:
parent
cf2418076d
commit
abe5f799e6
3 changed files with 25 additions and 1 deletions
|
|
@ -211,6 +211,19 @@ class TypeAliasConstructorTest(unittest.TestCase):
|
|||
self.assertEqual(TA.__value__, list[T])
|
||||
self.assertEqual(TA.__type_params__, (T,))
|
||||
self.assertEqual(TA.__module__, __name__)
|
||||
self.assertIs(type(TA[int]), types.GenericAlias)
|
||||
|
||||
def test_not_generic(self):
|
||||
TA = TypeAliasType("TA", list[int], type_params=())
|
||||
self.assertEqual(TA.__name__, "TA")
|
||||
self.assertEqual(TA.__value__, list[int])
|
||||
self.assertEqual(TA.__type_params__, ())
|
||||
self.assertEqual(TA.__module__, __name__)
|
||||
with self.assertRaisesRegex(
|
||||
TypeError,
|
||||
"Only generic type aliases are subscriptable",
|
||||
):
|
||||
TA[int]
|
||||
|
||||
def test_keywords(self):
|
||||
TA = TypeAliasType(name="TA", value=int)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue