@@ -461,7 +461,7 @@ class Starship:
461461 be used with isinstance() or issubclass().
462462 """
463463 item = _type_check (parameters , f'{ self } accepts only single type.' )
464- return _GenericAlias (self , (item ,), name = "ClassVar" )
464+ return _GenericAlias (self , (item ,))
465465
466466@_SpecialForm
467467def Final (self , parameters ):
@@ -482,7 +482,7 @@ class FastConnector(Connection):
482482 There is no runtime checking of these properties.
483483 """
484484 item = _type_check (parameters , f'{ self } accepts only single type.' )
485- return _GenericAlias (self , (item ,), name = "Final" )
485+ return _GenericAlias (self , (item ,))
486486
487487@_SpecialForm
488488def Union (self , parameters ):
@@ -520,12 +520,9 @@ def Union(self, parameters):
520520 parameters = _remove_dups_flatten (parameters )
521521 if len (parameters ) == 1 :
522522 return parameters [0 ]
523-
524523 if len (parameters ) == 2 and type (None ) in parameters :
525- name = "Optional"
526- else :
527- name = "Union"
528- return _UnionGenericAlias (self , parameters , name = name )
524+ return _UnionGenericAlias (self , parameters , name = "Optional" )
525+ return _UnionGenericAlias (self , parameters )
529526
530527@_SpecialForm
531528def Optional (self , parameters ):
@@ -570,7 +567,7 @@ def open_helper(file: str, mode: MODE) -> str:
570567 except TypeError : # unhashable parameters
571568 pass
572569
573- return _LiteralGenericAlias (self , parameters , name = "Literal" )
570+ return _LiteralGenericAlias (self , parameters )
574571
575572
576573@_SpecialForm
@@ -609,7 +606,7 @@ def Concatenate(self, parameters):
609606 "ParamSpec variable." )
610607 msg = "Concatenate[arg, ...]: each arg must be a type."
611608 parameters = tuple (_type_check (p , msg ) for p in parameters )
612- return _ConcatenateGenericAlias (self , parameters , name = "Concatenate" )
609+ return _ConcatenateGenericAlias (self , parameters )
613610
614611
615612@_SpecialForm
@@ -657,7 +654,7 @@ def is_str(val: Union[str, float]):
657654 PEP 647 (User-Defined Type Guards).
658655 """
659656 item = _type_check (parameters , f'{ self } accepts only single type.' )
660- return _GenericAlias (self , (item ,), name = "TypeGuard" )
657+ return _GenericAlias (self , (item ,))
661658
662659
663660class ForwardRef (_Final , _root = True ):
@@ -962,7 +959,7 @@ def __mro_entries__(self, bases):
962959
963960 def __getattr__ (self , attr ):
964961 if attr in {'__name__' , '__qualname__' }:
965- return self ._name
962+ return self ._name or self . __origin__ . __name__
966963
967964 # We are careful for copy and pickle.
968965 # Also for simplicity we just don't relay all dunder names
0 commit comments