@@ -2388,52 +2388,53 @@ def _get_type_vars(self, tvars):
23882388 tvars .append (self )
23892389
23902390
2391- # Inherits from list as a workaround for Callable checks in Python < 3.9.2.
2392- class _ConcatenateGenericAlias (list ):
2393-
2394- # Trick Generic into looking into this for __parameters__.
2395- if PEP_560 :
2396- __class__ = typing ._GenericAlias
2397- elif sys .version_info [:3 ] == (3 , 5 , 2 ):
2398- __class__ = typing .TypingMeta
2399- else :
2400- __class__ = typing ._TypingBase
2391+ if not hasattr (typing , 'Concatenate' ):
2392+ # Inherits from list as a workaround for Callable checks in Python < 3.9.2.
2393+ class _ConcatenateGenericAlias (list ):
24012394
2402- # Flag in 3.8 .
2403- _special = False
2404- # Attribute in 3.6 and earlier.
2405- if sys .version_info [:3 ] == (3 , 5 , 2 ):
2406- _gorg = typing .GenericMeta
2407- else :
2408- _gorg = typing .Generic
2395+ # Trick Generic into looking into this for __parameters__ .
2396+ if PEP_560 :
2397+ __class__ = typing . _GenericAlias
2398+ elif sys .version_info [:3 ] == (3 , 5 , 2 ):
2399+ __class__ = typing .TypingMeta
2400+ else :
2401+ __class__ = typing ._TypingBase
24092402
2410- def __init__ (self , origin , args ):
2411- super ().__init__ (args )
2412- self .__origin__ = origin
2413- self .__args__ = args
2403+ # Flag in 3.8.
2404+ _special = False
2405+ # Attribute in 3.6 and earlier.
2406+ if sys .version_info [:3 ] == (3 , 5 , 2 ):
2407+ _gorg = typing .GenericMeta
2408+ else :
2409+ _gorg = typing .Generic
24142410
2415- def __repr__ (self ):
2416- _type_repr = typing ._type_repr
2417- return '{origin}[{args}]' \
2418- .format (origin = _type_repr (self .__origin__ ),
2419- args = ', ' .join (_type_repr (arg ) for arg in self .__args__ ))
2411+ def __init__ (self , origin , args ):
2412+ super ().__init__ (args )
2413+ self .__origin__ = origin
2414+ self .__args__ = args
24202415
2421- def __hash__ (self ):
2422- return hash ((self .__origin__ , self .__args__ ))
2416+ def __repr__ (self ):
2417+ _type_repr = typing ._type_repr
2418+ return '{origin}[{args}]' \
2419+ .format (origin = _type_repr (self .__origin__ ),
2420+ args = ', ' .join (_type_repr (arg ) for arg in self .__args__ ))
24232421
2424- # Hack to get typing._type_check to pass in Generic.
2425- def __call__ (self , * args , ** kwargs ):
2426- pass
2422+ def __hash__ (self ):
2423+ return hash ((self .__origin__ , self .__args__ ))
24272424
2428- @ property
2429- def __parameters__ (self ):
2430- return tuple ( tp for tp in self . __args__ if isinstance ( tp , ( TypeVar , ParamSpec )))
2425+ # Hack to get typing._type_check to pass in Generic.
2426+ def __call__ (self , * args , ** kwargs ):
2427+ pass
24312428
2432- if not PEP_560 :
2433- # Only required in 3.6 and lower.
2434- def _get_type_vars (self , tvars ):
2435- if self .__origin__ and self .__parameters__ :
2436- typing ._get_type_vars (self .__parameters__ , tvars )
2429+ @property
2430+ def __parameters__ (self ):
2431+ return tuple (tp for tp in self .__args__ if isinstance (tp , (TypeVar , ParamSpec )))
2432+
2433+ if not PEP_560 :
2434+ # Only required in 3.6 and lower.
2435+ def _get_type_vars (self , tvars ):
2436+ if self .__origin__ and self .__parameters__ :
2437+ typing ._get_type_vars (self .__parameters__ , tvars )
24372438
24382439
24392440@_tp_cache
0 commit comments