mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-105486: Change the repr of ParamSpec list of args in GenericAlias (#105488)
This commit is contained in:
parent
e212618baf
commit
eb7d6e7ad8
4 changed files with 62 additions and 1 deletions
|
|
@ -209,6 +209,9 @@ class BaseTest(unittest.TestCase):
|
|||
def test_repr(self):
|
||||
class MyList(list):
|
||||
pass
|
||||
class MyGeneric:
|
||||
__class_getitem__ = classmethod(GenericAlias)
|
||||
|
||||
self.assertEqual(repr(list[str]), 'list[str]')
|
||||
self.assertEqual(repr(list[()]), 'list[()]')
|
||||
self.assertEqual(repr(tuple[int, ...]), 'tuple[int, ...]')
|
||||
|
|
@ -221,6 +224,11 @@ class BaseTest(unittest.TestCase):
|
|||
self.assertTrue(repr(MyList[int]).endswith('.BaseTest.test_repr.<locals>.MyList[int]'))
|
||||
self.assertEqual(repr(list[str]()), '[]') # instances should keep their normal repr
|
||||
|
||||
# gh-105488
|
||||
self.assertTrue(repr(MyGeneric[int]).endswith('MyGeneric[int]'))
|
||||
self.assertTrue(repr(MyGeneric[[]]).endswith('MyGeneric[[]]'))
|
||||
self.assertTrue(repr(MyGeneric[[int, str]]).endswith('MyGeneric[[int, str]]'))
|
||||
|
||||
def test_exposed_type(self):
|
||||
import types
|
||||
a = types.GenericAlias(list, int)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue