mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.12] gh-109818: reprlib.recursive_repr
copies __type_params__
(… (#109999)
[3.12] gh-109818: `reprlib.recursive_repr` copies `__type_params__` (GH-109819).
(cherry picked from commit f65f9e80fe
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
dd67e59bb1
commit
9be6a11199
3 changed files with 14 additions and 0 deletions
|
@ -765,5 +765,16 @@ class TestRecursiveRepr(unittest.TestCase):
|
|||
for name in assigned:
|
||||
self.assertIs(getattr(wrapper, name), getattr(wrapped, name))
|
||||
|
||||
def test__type_params__(self):
|
||||
class My:
|
||||
@recursive_repr()
|
||||
def __repr__[T: str](self, default: T = '') -> str:
|
||||
return default
|
||||
|
||||
type_params = My().__repr__.__type_params__
|
||||
self.assertEqual(len(type_params), 1)
|
||||
self.assertEqual(type_params[0].__name__, 'T')
|
||||
self.assertEqual(type_params[0].__bound__, str)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue