bpo-45662: Fix the repr of InitVar with a type alias to the built-in class (GH-29291)

For example, InitVar[list[int]].
This commit is contained in:
Serhiy Storchaka 2021-12-05 22:41:58 +02:00 committed by GitHub
parent 60c320c38e
commit 1fd4de5bdd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View file

@ -1126,6 +1126,10 @@ def test_init_var_preserve_type(self):
self.assertEqual(repr(InitVar[int]), 'dataclasses.InitVar[int]')
self.assertEqual(repr(InitVar[List[int]]),
'dataclasses.InitVar[typing.List[int]]')
self.assertEqual(repr(InitVar[list[int]]),
'dataclasses.InitVar[list[int]]')
self.assertEqual(repr(InitVar[int|str]),
'dataclasses.InitVar[int | str]')
def test_init_var_inheritance(self):
# Note that this deliberately tests that a dataclass need not