@@ -453,7 +453,7 @@ class Starship:
453453 be used with isinstance() or issubclass().
454454 """
455455 item = _type_check (parameters , f'{ self } accepts only single type.' )
456- return _GenericAlias (self , (item ,), name = "ClassVar" )
456+ return _GenericAlias (self , (item ,))
457457
458458@_SpecialForm
459459def Final (self , parameters ):
@@ -474,7 +474,7 @@ class FastConnector(Connection):
474474 There is no runtime checking of these properties.
475475 """
476476 item = _type_check (parameters , f'{ self } accepts only single type.' )
477- return _GenericAlias (self , (item ,), name = "Final" )
477+ return _GenericAlias (self , (item ,))
478478
479479@_SpecialForm
480480def Union (self , parameters ):
@@ -512,12 +512,9 @@ def Union(self, parameters):
512512 parameters = _remove_dups_flatten (parameters )
513513 if len (parameters ) == 1 :
514514 return parameters [0 ]
515-
516515 if len (parameters ) == 2 and type (None ) in parameters :
517- name = "Optional"
518- else :
519- name = "Union"
520- return _UnionGenericAlias (self , parameters , name = name )
516+ return _UnionGenericAlias (self , parameters , name = "Optional" )
517+ return _UnionGenericAlias (self , parameters )
521518
522519@_SpecialForm
523520def Optional (self , parameters ):
@@ -562,7 +559,7 @@ def open_helper(file: str, mode: MODE) -> str:
562559 except TypeError : # unhashable parameters
563560 pass
564561
565- return _LiteralGenericAlias (self , parameters , name = "Literal" )
562+ return _LiteralGenericAlias (self , parameters )
566563
567564
568565@_SpecialForm
@@ -601,7 +598,7 @@ def Concatenate(self, parameters):
601598 "ParamSpec variable." )
602599 msg = "Concatenate[arg, ...]: each arg must be a type."
603600 parameters = tuple (_type_check (p , msg ) for p in parameters )
604- return _ConcatenateGenericAlias (self , parameters , name = "Concatenate" )
601+ return _ConcatenateGenericAlias (self , parameters )
605602
606603
607604@_SpecialForm
@@ -649,7 +646,7 @@ def is_str(val: Union[str, float]):
649646 PEP 647 (User-Defined Type Guards).
650647 """
651648 item = _type_check (parameters , f'{ self } accepts only single type.' )
652- return _GenericAlias (self , (item ,), name = "TypeGuard" )
649+ return _GenericAlias (self , (item ,))
653650
654651
655652class ForwardRef (_Final , _root = True ):
@@ -960,7 +957,7 @@ def __mro_entries__(self, bases):
960957
961958 def __getattr__ (self , attr ):
962959 if attr in {'__name__' , '__qualname__' }:
963- return self ._name
960+ return self ._name or self . __origin__ . __name__
964961
965962 # We are careful for copy and pickle.
966963 # Also for simplicity we just don't relay all dunder names
0 commit comments