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

For example, InitVar[list[int]].
(cherry picked from commit 1fd4de5bdd)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-12-05 13:02:47 -08:00 committed by GitHub
parent beb834292d
commit f1dd5ed1f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View file

@ -229,7 +229,7 @@ class InitVar:
self.type = type
def __repr__(self):
if isinstance(self.type, type):
if isinstance(self.type, type) and not isinstance(self.type, GenericAlias):
type_name = self.type.__name__
else:
# typing objects, e.g. List[int]