/ lib / setuptools / _vendor / typing_extensions.pyc
typing_extensions.pyc
  1  o

  2  6�HcmT�@sn
  3  ddlZddlZddlZddlZddlZddlZejdd�dkZer&eZ	nddlm	Z	m
  4  Z
  5  dd�Zdd�Zgd	�Z
erCe
�gd
  6  ��eed�rLejZnGdd
�d
ejdd�Zedd�Ze�d�Ze�d�Ze�d�Zejddd�Zejddd�ZejZeed�r�ejdd�dkr�ejZn+ejdd�dkr�Gdd�dejdd�Zeddd�ZnGdd�dejdd�Zedd�Zeed �r�ejZnd!d �Zd"d#�Zeed$�r�ej Z n+ejdd�dkr�Gd%d&�d&ejdd�Z!e!d$d'd�Z nGd(d)�d)ejdd�Z"e"dd�Z ej#Z#ej$Z$ej%Z%Gd*d+�d+e	�Z&ej'Z'ej(Z(ej)Z)ej*Z*eed,��r%ej+Z+nGd-d,�d,ej,ej-ee&ej,d.�Z+ej.Z.eed/��rCej/Z/ndd0l0m1Z2Gd1d/�d/ej3e�Z/ej4Z4eed2��raej5Z5n0dejdd�k�rrd3k�r~nn
  7  e�6ej5eef�Z5nGd4d2�d2ej5ej7eefe&ej5d.�Z5eed5��r�ej8Z8nGd6d5�d5ej8ej9ee:fe&ej8d.�Z8eed7��r�ej;Z;need7��r�Gd8d7�d7ej;ej7eefe&ej;d.�Z;eed9��r�ej<Z<nGd:d9�d9e*eej3eefe&ejj<d.�Z<ej=Z=ej>Z>ej?Z?d;d<�Z@gd=�ZAd>d?�ZBd@dA�ZCeedB��rejDZDn=e�r3ddClmEZEdDdE�ZFGdFdG�dGejG�ZHGdHdB�dBeHdI�ZDnddJlmIZImJZJdKdE�ZFGdLdG�dGe	�ZHGdMdB�dBeHdI�ZDeedN��rZejKZKndOdN�ZKeKZLeedP��rjejMZMn
  8  eKGdQdP�dPeD��ZMejdRk�r~ejNZNn*dSdT�ZOdUdV�ZPdWeP_QddX�dYdZ�ZRd[eR_QGd\d]�d]e�ZSeSd^eTfi�ZNeUeN_Vd_eN_Weed`��r�ejXZXejYZYejZZZn5e�r�Gdadb�dbej[dd�ZZGdcd`�d`�ZXddde�Z\d�dgdh�ZYndidj�Z]Gdkdl�dlej	�Z^Gdmd`�d`e^dI�ZXejdd�dnk�r�ej_Z_ej`Z`n7e�r5zddolmaZaWn
eb�yej[ZaYnwzddplmcZcWn
eb�y,ej[ZcYnwdqdr�Z_dsdt�Z`eedu��r?ejdZdnRejdd�dvk�r[Gdwdx�dxejdd�Zeeedydu��Zdn6ejdd�dk�rwGdzdx�dxejdd�Zeeedud{d�ZdnGd|d}�d}ejf�ZgGd~d�dejegdd��Zhehdd�Zdeed���r�ejiZiejjZjnGd�d��d��ZkGd�d��d�ek�ZiGd�d��d�ek�Zjeed���r�ejlZlnGd�d��d�em�Zleed���s�Gd�d��d�em�Znejod�d���Zpeed���r�ejqZqejnZnnGejdd�dvk�r�eed�d���Zqn6ejdd�dk�rGd�d��d�ejdd�Zrerd�d�d�ZqnGd�d��d�ejf�ZsGd�d��d�ejesdd��Ztetdd�Zqeed���r:ejuZunHejdd�dvk�rVGd�d��d�ejdd�Zvevd�d���Zun,ejdd�dk�rrGd�d��d�ejdd�Zvevd�d�d�ZunGd�d��d�ejdd�Zwewdd�Zueed���r�ejxZxn,ejdd�dk�r�Gd�d��d�ejdd�Zed�d���ZxnGd�d��d�ejdd�Zyeydd�Zxeed���r�ejzZzej{Z{dSejdd�dvk�r�Gd�d��d�ejdd�Z|e|d�d���Zze|d�d���Z{dSejdd�dk�rGd�d��d�ejdd�Z}e}d�d�d�Zze}d�d�d�Z{dSGd�d��d�ejdd�Z~Gd�d��d�e~dd�ZGd�d��d�e~dd�Z�edd�Zze�dd�Z{dS)��N�)r�r)�GenericMeta�
  9  _type_varscCs.t|�}d|vr|dD]}|�|d�q|S)N�	__slots__)�dict�pop)�dctZ	dict_copy�slot�r��C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\site-packages\setuptools\_vendor\typing_extensions.py�_no_slots_copys
 10  r
c	Cs^|js
 11  t|�d���t|�}t|j�}||kr-td||krdnd�d|�d|�d|����dS)Nz is not a generic classzToo �many�fewz arguments for z	; actual z, expected )�__parameters__�	TypeError�len)�cls�
 12  parameters�alen�elenrrr�_check_generics
 13  ���r)!�ClassVar�Concatenate�Final�	ParamSpec�Self�Type�	Awaitable�
AsyncIterator�
AsyncIterable�	Coroutine�AsyncGenerator�AsyncContextManager�ChainMap�ContextManager�Counter�Deque�DefaultDict�OrderedDict�	TypedDict�
SupportsIndex�	Annotated�final�IntVar�Literal�NewType�overload�Protocol�runtime�runtime_checkable�Text�	TypeAlias�	TypeGuard�
TYPE_CHECKING)�get_args�
 14  get_origin�get_type_hints�NoReturnc@�$eZdZdZdZdd�Zdd�ZdS)�	_NoReturna7Special type indicating functions that never return.
 15          Example::
 16  
 17            from typing import NoReturn
 18  
 19            def stop() -> NoReturn:
 20                raise Exception('no way')
 21  
 22          This type is invalid in other positions, e.g., ``List[NoReturn]``
 23          will fail in static type checkers.
 24          rcC�td��)Nz*NoReturn cannot be used with isinstance().�r��self�objrrr�__instancecheck__m�z_NoReturn.__instancecheck__cCr?)Nz*NoReturn cannot be used with issubclass().r@�rBrrrr�__subclasscheck__prEz_NoReturn.__subclasscheck__N��__name__�
 25  __module__�__qualname__�__doc__rrDrGrrrrr>_s
 26  r>T��_root�T�KT�VT�T_co)�	covariant�T_contra)�
contravariantr�)rrc@�eZdZdd�Zdd�ZdS)�
 27  _FinalFormcC�
 28  d|jS�Nztyping_extensions.��_name�rBrrr�__repr__��
 29  z_FinalForm.__repr__cC�"t�||j�d��}t�||f�S)N� accepts only single type��typing�_type_checkr\�
_GenericAlias�rBr�itemrrr�__getitem__��
 30  �z_FinalForm.__getitem__N�rIrJrKr^rhrrrrrX��rXaWA special typing construct to indicate that a name
 31                         cannot be re-assigned or overridden in a subclass.
 32                         For example:
 33  
 34                             MAX_SIZE: Final = 9000
 35                             MAX_SIZE += 1  # Error reported by type checker
 36  
 37                             class Connection:
 38                                 TIMEOUT: Final[int] = 10
 39                             class FastConnector(Connection):
 40                                 TIMEOUT = 1  # Error reported by type checker
 41  
 42                         There is no runtime checking of these properties.)�docc�NeZdZdZdZddd�Zdd�Zdd	�Z�fd
 43  d�Zdd
�Z	dd�Z
 44  �ZS)�_Finala�A special typing construct to indicate that a name
 45          cannot be re-assigned or overridden in a subclass.
 46          For example:
 47  
 48              MAX_SIZE: Final = 9000
 49              MAX_SIZE += 1  # Error reported by type checker
 50  
 51              class Connection:
 52                  TIMEOUT: Final[int] = 10
 53              class FastConnector(Connection):
 54                  TIMEOUT = 1  # Error reported by type checker
 55  
 56          There is no runtime checking of these properties.
 57          ��__type__NcK�
 58  ||_dS�Nro�rB�tp�kwdsrrr�__init__�r_z_Final.__init__cC�Nt|�}|jdur|t�||jdd��d��dd�St|jdd��d���)N�� accepts only single type.TrM� cannot be further subscripted��typerprcrdrIr�rBrgrrrrrh��
 59  ��z_Final.__getitem__cC�.t�|j||�}||jkr|St|�|dd�S�NTrM�rc�
 60  _eval_typerpr|�rB�globalns�localnsZnew_tprrrr���
 61  z_Final._eval_typec�0t���}|jdur|dt�|j��d�7}|S�N�[�]��superr^rprc�
 62  _type_repr�rB�r��	__class__rrr^��
 63  
 64  z_Final.__repr__cC�tt|�j|jf�Srr��hashr|rIrpr]rrr�__hash__��z_Final.__hash__cC�,t|t�stS|jdur|j|jkS||uSrr)�
 65  isinstancern�NotImplementedrp�rB�otherrrr�__eq__��
 66  
 67  
 68  z
_Final.__eq__rr�rIrJrKrLrrvrhr�r^r�r��
__classcell__rrr�rrn�s
 69  rnr-cC�|S)auThis decorator can be used to indicate to type checkers that
 70          the decorated method cannot be overridden, and decorated class
 71          cannot be subclassed. For example:
 72  
 73              class Base:
 74                  @final
 75                  def done(self) -> None:
 76                      ...
 77              class Sub(Base):
 78                  def done(self) -> None:  # Error reported by type checker
 79                      ...
 80              @final
 81              class Leaf:
 82                  ...
 83              class Other(Leaf):  # Error reported by type checker
 84                  ...
 85  
 86          There is no runtime checking of these properties.
 87          r)�frrrr-�scC�
 88  t�|�Srr)rc�TypeVar��namerrrr.�r_r.r/c@rW)�_LiteralFormcCrYrZr[r]rrrr^�r_z_LiteralForm.__repr__cCst�||�Srr)rcre�rBrrrrrh��z_LiteralForm.__getitem__Nrjrrrrr��rkr�aoA type that can be used to indicate to type checkers
 89                             that the corresponding value has a value literally equivalent
 90                             to the provided parameter. For example:
 91  
 92                                 var: Literal[4] = 4
 93  
 94                             The type checker understands that 'var' is literally equal to
 95                             the value 4 and no other value.
 96  
 97                             Literal[...] cannot be subclassed. There is no runtime
 98                             checking verifying that the parameter is actually a value
 99                             instead of a type.crm)�_Literala�A type that can be used to indicate to type checkers that the
100          corresponding value has a value literally equivalent to the
101          provided parameter. For example:
102  
103              var: Literal[4] = 4
104  
105          The type checker understands that 'var' is literally equal to the
106          value 4 and no other value.
107  
108          Literal[...] cannot be subclassed. There is no runtime checking
109          verifying that the parameter is actually a value instead of a type.
110          ��
111  __values__NcKrqrrr�)rB�valuesrurrrrv!r_z_Literal.__init__cCsFt|�}|jdurt|t�s|f}||dd�St|jdd��d���)NTrMrxrz)r|r�r��tuplerrI)rBr�rrrrrh$s
112  
113  z_Literal.__getitem__cCr�rrr)rBr�r�rrrr�,�z_Literal._eval_typecs8t���}|jdur|dd�ttj|j���d�7}|S)Nr��, r�)r�r^r��join�maprcr�r�r�rrr^/s
114  
115   z_Literal.__repr__cCr�rr)r�r|rIr�r]rrrr�5r�z_Literal.__hash__cCr�rr)r�r�r�r�r�rrrr�8r�z_Literal.__eq__rrr�rrr�rr�s
116  r�c�eZdZ�fdd�Z�ZS)�_ExtensionsGenericMetacs�|jdurt�d�jddvrtd��dS|jst��|�S|j�|�}|t	ur*|S|j|j
117  vr2dS|j��D]}t|t
�r?q7t||�rGdSq7dS)a*This mimics a more modern GenericMeta.__subclasscheck__() logic
118          (that does not have problems with recursion) to work around interactions
119          between collections, typing, and typing_extensions on older
120          versions of Python, see https://github.com/python/typing/issues/501.
121          NrxrI��abc�	functools�CParameterized generics cannot be used with class or instance checksFT)�
122  __origin__�sys�	_getframe�	f_globalsr�	__extra__r�rG�__subclasshook__r��__mro__�__subclasses__r�r�
123  issubclass)rB�subclass�res�sclsr�rrrGNs$
124  
125  
126  �z(_ExtensionsGenericMeta.__subclasscheck__)rIrJrKrGr�rrr�rr�Msr�r'c@�eZdZdZdd�ZdS)r'rcOs6|jtur
tj|i|��Stjtj|g|�Ri|��Srr)�_gorgr'�collections�dequerc�_generic_new�r�argsrurrr�__new__w�
127  z
Deque.__new__N�rIrJrKrr�rrrrr'rs)�	metaclass�extrar#)�_check_methodsc@s2eZdZdZdd�Zejdd��Zedd��Z	dS)	r#rc�s�|Srrrr]rrr�
128  __aenter__�s�zAsyncContextManager.__aenter__c�s�dSrrr)rB�exc_type�	exc_value�	tracebackrrr�	__aexit__�s�zAsyncContextManager.__aexit__cCs|tur
129  t|dd�StS)Nr�r�)r#�_check_methods_in_mror�)r�Crrrr��sz$AsyncContextManager.__subclasshook__N)
130  rIrJrKrr�r��abstractmethodr��classmethodr�rrrrr#�s
131  r))rrrVc@r�)r)rcO�6|jtur
tj|i|��Stjtj|g|�Ri|��Srr)r�r)r�rcr�r�rrrr��r�zOrderedDict.__new__Nr�rrrrr)��r&c@r�)r&rcOr�rr)r�r&r�rcr�r�rrrr��r�zCounter.__new__Nr�rrrrr&�r�r$c@r�)r$rcOr�rr)r�r$r�rcr�r�rrrr��r�zChainMap.__new__Nr�rrrrr$�r�r"c@�eZdZdZdS)r"rN)rIrJrKrrrrrr"�scCs<t|t�sJ�t|d�r|jS|jdur|j}|jdus|S)z@This function exists for compatibility with old typing versions.r�N)r�r�hasattrr�r��rrrrr��s
132  
133  
134  �r�)
�Callabler�Iterable�Iteratorr r�Hashable�Sized�	Container�
135  Collection�
136  Reversibler%r#cCsrt�}|jdd�D],}|jdvrq
137  t|di�}t|j���t|���D]}|�d�s5|dvr5|�|�q%q
138  |S)N�����)r2�Generic�__annotations__�_abc_)�__abstractmethods__r��__weakref__�_is_protocol�_is_runtime_protocol�__dict__�__args__r�__next_in_mro__rr��__orig_bases__r��
__tree_hash__rLr�rvr�rJ�_MutableMapping__markerr�)	�setr�rI�getattr�listr��keys�
139  startswith�add)r�attrs�base�annotations�attrrrr�_get_protocol_attrs�s
140  
141  ��
142  rcst�fdd�t��D��S)Nc3s �|]}tt�|d��VqdSrr)�callabler���.0r�r�rr�	<genexpr>���z,_is_callable_members_only.<locals>.<genexpr>)�allrr�rr�r�_is_callable_members_only�srr2)�_collect_type_varscO�t|�jr	td��dS�Nz Protocols cannot be instantiated�r|r�r�rBr��kwargsrrr�_no_init�
143  �rcr�)�
_ProtocolMetacsVt�dd�r
144  t��rt�j��rdS�jr%t��fdd�t��D��r%dSt����S)Nr�FTc3s:�|]}t�|�ott�|d��pt�|�duVqdSrr�r�rr�r�r�instancerrr��
145  �
146  ��2_ProtocolMeta.__instancecheck__.<locals>.<genexpr>)	r�rr�r�r�rrr�rDrr�rrrDs�
147  ���_ProtocolMeta.__instancecheck__)rIrJrKrDr�rrr�rr	srcs>eZdZdZdZdZ�fdd�Zejdd��Z	dd	�Z
148  �ZS)
149  r2a�Base class for protocol classes. Protocol classes are defined as::
150  
151              class Proto(Protocol):
152                  def meth(self) -> int:
153                      ...
154  
155          Such classes are primarily used with static type checkers that recognize
156          structural subtyping (static duck-typing), for example::
157  
158              class C:
159                  def meth(self) -> int:
160                      return 0
161  
162              def func(x: Proto) -> int:
163                  return x.meth()
164  
165              func(C())  # Passes static type check
166  
167          See PEP 544 for details. Protocol classes decorated with
168          @typing_extensions.runtime act as simple-minded runtime protocol that checks
169          only the presence of given attributes, ignoring their type signatures.
170  
171          Protocol classes can be generic, they are defined as::
172  
173              class GenProto(Protocol[T]):
174                  def meth(self) -> T:
175                      ...
176          rTcs|turtd��t��|�S)NzIType Protocol cannot be instantiated; it can only be used as a base class)r2rr�r�r�r�rrr�>s�Protocol.__new__cs�t|t�s|f}|s|tjurtd|j�d���d�t�fdd�|D��}|turetdd�|D��sVd}t||tj�rH|d7}t||tj�s<td	|d�d
177  ||����t	t
178  |��t	|�krdtd��nt||�t�||�S)N�Parameter list to �[...] cannot be empty�*Parameters to generic types must be types.c3��|]	}t�|��VqdSrr�rcrd�r�p��msgrrrL��z-Protocol.__class_getitem__.<locals>.<genexpr>cs��|]	}t|tj�VqdSrr�r�rcr�rrrrrOr!rrxzBParameters to Protocol[...] must all be type variables. Parameter z is z.Parameters to Protocol[...] must all be unique)
r�r�rc�TuplerrKr2rr�rr�rre)r�params�irrr�__class_getitem__Ds8
179  �������
180  zProtocol.__class_getitem__cs�g}d�jvrtj�jv}ntj�jv}|rtd��d�jvr�t�j�}d}�jD]}t|tj�rH|j	tjt
181  fvrH|j	j}|durEtd��|j}q)|durP|}n2t
|�}t
|��|�ks�d��fdd�|D��}	d�dd�|D��}
182  td|	�d	|�d
183  |
184  �d���|}t|��_�j�dd�s�td
d��jD���_�fdd�}d�jvr�|�_�js�dS�jD]$}|ttjfvs�|jdkr�|jtvs�t|t�r�|js�tdt|�����q�t�_dS)Nr��!Cannot inherit from plain GenericzECannot inherit from Generic[...] and/or Protocol[...] multiple types.r�c3� �|]}|�vrt|�VqdSrr��str�r�t��gvarsetrrr~rz-Protocol.__init_subclass__.<locals>.<genexpr>cs��|]}t|�VqdSrrr*�r�grrrr���Some type variables (�) are not listed in r�r�r�css�|]}|tuVqdSrr)r2�r�brrrr�r3cs��j�dd�s	tSt�dd�st�d�jddvrtStd��t��s3t�d�jddvr/tStd��t	|t
185  �s<td	��t��D]:}|jD]0}||jvr[|j|durYtSnt|d
186  i�}t	|t
j�ru||vrut	|t�ru|jrunqEtSq@dS)Nr�r�FrVrIr��BInstance and class checks can only be used with @runtime protocols�<Protocols with non-method members don't support issubclass()�"issubclass() arg 1 must be a classr�T)r��getr�r�r�r�r�rrr�r|rr�rc�Mappingrr��r�r�r�r�r�rr�_proto_hook�s<
187  
188  
189  ����z/Protocol.__init_subclass__.<locals>._proto_hookr��collections.abc�5Protocols can only inherit from other protocols, got )r�rcr�r��	__bases__rrr�rer�r2rIrr�r�r�r;�anyr�r��objectrJ�_PROTO_WHITELISTr�reprrrv)rr�r
�tvars�error�gvarsr�Zthe_base�tvarset�s_vars�s_argsr>r)rr/r�__init_subclass__^sj
190  
191  
192  
193  ��
194  �
195  �
196  
197  
198  
199  
200  ����
201  zProtocol.__init_subclass__)rIrJrKrLrr�r�rc�	_tp_cacher'rLr�rrr�rr2s
202  )r�)�_next_in_mrordcOr	r
203  rrrrrr�rcsVeZdZdZ	d
�fdd�	Z�fdd�Z�fdd�Z�fd	d
204  �Zej	dd��Z
205  �ZS)rz�Internal metaclass for Protocol.
206  
207          This exists so Protocol classes can be generic without deriving
208          from Generic.
209          Nc	sT|dusJ�|dur|dusJ�tdd�|D��sJ|��nrt|�}d}	|D]#}
210  |
211  tjur1td��t|
212  t�rI|
213  jtjtfvrI|	durFtd��|
214  j	}	q&|	durQ|}	n?t
215  |�}t
216  |	��|�ks�d��fdd�|D��}d�dd�|	D��}
tdd�|D��r~d	nd
217  }td|�d|�d
|
�d���|	}|}|dur�t
|�tjur�||vr�|f|}tdd�|D��}tdd�|D��r�tdd�|D��}|�||d��tt|�j||||dd�}tt|��d|s�|nt|��||_	|r�tdd�|D��nd|_t|�|_|du�r||_n
|du�r|j|_|j|_t|d��r(|�r t|���ntt|���|_ |S)Ncsr"rrr#r,rrrr�r!z(_ProtocolMeta.__new__.<locals>.<genexpr>r(zACannot inherit from Generic[...] or Protocol[...] multiple times.r�c3r)rrr*r,r.rrr�rcsr0rrr*r1rrrr�r3css�|]	}|jtjuVqdSrr)r�rcr�r6rrrr�s��r�r2r4r5r�r�css&�|]}t|t�r
t|�n|VqdSrr)r�rr�r6rrrr�s��css$�|]
}t|t�o
|tjuVqdSrr)r�rrcr�r6rrrr�s�"css�|]
218  }|tjur|VqdSrr)rcr�r6rrrr�s�)r�r�TrMr�css0�|]}|tjurdn|tjurdn|VqdS).rN)rc�_TypingEllipsis�_TypingEmpty�r�arrrr�s��
219  ��
220  _subs_tree)!rrrcr�rr�rr�r2rr�r�rBr|r��ABCMetar��updater�r��__setattr__r�r�rNr�r��
_abc_registry�
221  _abc_cacher�r�rSr�r�)rr��bases�	namespacerFr��originr��
222  orig_basesrHr�rIrJrK�cls_nameZ
initial_basesrBr�r.rr��s�
223  
224  ����
225  �
226  �
227  ���
228  ���
229  
230  
231  �z_ProtocolMeta.__new__cs�t�j|i|���j�dd�stdd��jD���_�jrY�jdd�D]0}|tt	j
232  fvsU|jdkr8|jt
vsUt|t	j�rA|jsUt|t�rL|jt	j
233  usUtdt|�����q%t�_�fdd�}d	�jvri|�_dSdS)
234  Nr�css,�|]}|tupt|t�o|jtuVqdSrr)r2r�rr�r6rrrr
235  s��
236  
237  �z)_ProtocolMeta.__init__.<locals>.<genexpr>rxr?r@cs��j�dd�s	tSt|t�std��t��D]:}|jD]0}||jvr1|j|dur/tSnt|di�}t|t	j
238  �rK||vrKt|t�rK|jrKnqtSqdS)Nr�r:r�T)
r�r;r�r�r|rrr�r�rcr<rr�r=r�rrr>s,
239  
240  
241  ����z+_ProtocolMeta.__init__.<locals>._proto_hookr�)r�rvr�r;rBrAr�r�rCrcr�rJrIrDr��
242  TypingMetarr�rrErr�)rr�r
r�r>r�r�rrvs4
243  �
244  
245  
246  �����
247  
248  �z_ProtocolMeta.__init__csZt�dd�r
249  t��rt�j��rdS�jr%t��fdd�t��D��r%dStt���	��S)Nr�FTc3s:�|]}t�|�ott�|d��pt�|�duVqdSrrrr�rrBrrr;rr)
250  r�rr�r�r�rrr�rrD)rBrr�r_rrD3s�
251  ��rcs�|jdurt�d�jddvrtd��dS|j�dd�r3|j�dd�s3t�d�jddvr/dStd	��|j�dd�rTt|�sTt�d�jddvrPtt	|��
252  |�Std
253  ��tt	|��
254  |�S)NrxrIr�r�Fr�r��r�r�rcr8r9)r�r�r�r�rr�r;rr�rrGrFr�rrrGBs"
255  ��z_ProtocolMeta.__subclasscheck__c
256  sJt|t�s|f}|st|�tjurtd|j�d���d�t�fdd�|D��}|tjtfvrZt	dd�|D��sAtdt
257  |��d���tt|��t|�krUtdt
258  |��d	���|}|}n+|tjtj
fvrit|�}|}n|jtjtfvrztd
259  t
260  |�����t||�t|�}|}|jdur�|fnd}|j|j||jt|j�||||j|jd�S)
Nrrrc3s�|]}t|��VqdSrr)rdrrrrrds�z,_ProtocolMeta.__getitem__.<locals>.<genexpr>csr"rrr#rrrrrfr!zParameters to z [...] must all be type variablesz[...] must all be uniquez%Cannot subscript already-subscripted r)rFr�r[r�r\)r�r�r�rcr$rrKr�r2rrErr�r�rr�rr�rIrAr
r�r�r�)rBr%rFr��prependrrrrhZsJ
261  ���
262  �z_ProtocolMeta.__getitem__)NNNNN)rIrJrKrLr�rvrDrGrcrMrhr�rrr�rr�s�@,c@s eZdZdZdZdZdd�ZdS)r2a�Base class for protocol classes. Protocol classes are defined as::
263  
264            class Proto(Protocol):
265                def meth(self) -> int:
266                    ...
267  
268          Such classes are primarily used with static type checkers that recognize
269          structural subtyping (static duck-typing), for example::
270  
271            class C:
272                def meth(self) -> int:
273                    return 0
274  
275            def func(x: Proto) -> int:
276                return x.meth()
277  
278            func(C())  # Passes static type check
279  
280          See PEP 544 for details. Protocol classes decorated with
281          @typing_extensions.runtime act as simple-minded runtime protocol that checks
282          only the presence of given attributes, ignoring their type signatures.
283  
284          Protocol classes can be generic, they are defined as::
285  
286            class GenProto(Protocol[T]):
287                def meth(self) -> T:
288                    ...
289          rTcOs0t|�tur
290  td��tj|j|g|�Ri|��S)NzIType Protocol cannot be instantiated; it can be used only as a base class)r�r2rrcr�r�r�rrrr��srN)rIrJrKrLrr�r�rrrrr2�s
291  r4cCs(t|t�r|jstd|����d|_|S)a4Mark a protocol class as a runtime protocol, so that it
292          can be used with isinstance() and issubclass(). Raise TypeError
293          if applied to a non-protocol class.
294  
295          This allows a simple-minded structural check very similar to the
296          one-offs in collections.abc such as Hashable.
297          z@@runtime_checkable can be only applied to protocol classes, got T)r�rr�rr�r�rrrr4�s�r+c@s$eZdZdZejdefdd��ZdS)r+r�returncC�dSrrrr]rrr�	__index__�szSupportsIndex.__index__N)rIrJrKrr�r��intrdrrrrr+�s)r�	rVc	Cs<zt�d�jddvrtd��WdSttfyYdSw)NrxrIr`z4TypedDict does not support instance and class checksF)r�r�r�r�AttributeError�
298  ValueError)rr�rrr�_check_fails�s���ricOs0|std��|d|dd�}}t|i|��S)N�)TypedDict.__new__(): not enough argumentsrrx)rr)r�r
�_rrr�	_dict_new�srlz,($cls, _typename, _fields=None, /, **kwargs)��totalc	OsN|std��|d|dd�}}|r|d|dd�}}nd|vr5|�d�}ddl}|jdtdd�ntd��|rTz|\}Wn1tyStd	t|�d�d
299  ���wd|vrpt|�dkrp|�d�}ddl}|jdtdd�nd}|dury|}n|rtd
��dt|�i}zt�	d�j
300  �dd�|d<Wnttfy�Ynwt
|d||d�S)NrjrrxZ	_typenamez5Passing '_typename' as keyword argument is deprecatedrV)�
301  stacklevelzGTypedDict.__new__() missing 1 required positional argument: '_typename'z?TypedDict.__new__() takes from 2 to 3 positional arguments but z were given�_fieldsz3Passing '_fields' as keyword argument is deprecatedz@TypedDict takes either a dict or keyword arguments, but not bothr�rI�__main__rJrrm)rr�warnings�warn�DeprecationWarningrhrrr�r�r�r;rg�_TypedDictMeta)rnr�r
rk�typenamerr�fields�nsrrr�_typeddict_new�sL
302  �
303  
304  
305  ��
306  ��ryz;($cls, _typename, _fields=None, /, *, total=True, **kwargs)cs4eZdZd�fdd�	Zd�fdd�	ZeZZ�ZS)ruTcst��|||�dSrr)r�rv)rr�rYrxrnr�rrrvr�z_TypedDictMeta.__init__cs|dkrtnt|d<t��||tf|�}i}|�di�}t|���}d��fdd�|��D�}t�}	t�}
307  |D] }|�	|j
308  �di��|	�	|j
309  �dd��|
310  �	|j
311  �d	d��q7|�	|�|re|	�	|�n|
312  �	|�||_t|	�|_
t|
313  �|_t|d
314  �s||_|S)Nr*r�r�z?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typecsi|]\}}|t�|���qSrr)r�nrtrrr�
315  <dictcomp>*s�z*_TypedDictMeta.__new__.<locals>.<dictcomp>�__required_keys__r�__optional_keys__�	__total__)ryrlr�r�rr;r�r��itemsrUr�r��	frozensetr|r}r�r~)rr�rYrxrn�tp_dictr��own_annotations�own_annotation_keys�
required_keys�
optional_keysr�r�rrr�s2
316  �
317  
318  
319  
320  
321  z_TypedDictMeta.__new__)T)	rIrJrKrvr�rirDrGr�rrr�rrus&rur*a�A simple typed name space. At runtime it is equivalent to a plain dict.
322  
323          TypedDict creates a dictionary type that expects all of its
324          instances to have a certain set of keys, with each key
325          associated with a value of a consistent type. This expectation
326          is not checked at runtime but is only enforced by type checkers.
327          Usage::
328  
329              class Point2D(TypedDict):
330                  x: int
331                  y: int
332                  label: str
333  
334              a: Point2D = {'x': 1, 'y': 2, 'label': 'good'}  # OK
335              b: Point2D = {'z': 3, 'label': 'bad'}           # Fails type check
336  
337              assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')
338  
339          The type info can be accessed via the Point2D.__annotations__ dict, and
340          the Point2D.__required_keys__ and Point2D.__optional_keys__ frozensets.
341          TypedDict supports two additional equivalent forms::
342  
343              Point2D = TypedDict('Point2D', x=int, y=int, label=str)
344              Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})
345  
346          The class syntax is only supported in Python 3.6+, while two other
347          syntax forms work for Python 2.7 and 3.2+
348          r,csHeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
349  d�Zdd
�Z	�Z
350  S)�_AnnotatedAliasaKRuntime representation of an annotated type.
351  
352          At its core 'Annotated[t, dec1, dec2, ...]' is an alias for the type 't'
353          with extra annotations. The alias behaves like a normal typing alias,
354          instantiating is the same as instantiating the underlying type, binding
355          it to types is also the same.
356          cs2t|t�r
|j|}|j}t��||�||_dSrr)r�r��__metadata__r�r�rv)rBr[�metadatar�rrrvvs
357  
358  
359  
360  z_AnnotatedAlias.__init__cCs$t|�dksJ�|d}t||j�S)Nrxr)rr�r�)rBr%�new_typerrr�	copy_with}sz_AnnotatedAlias.copy_withcCs,dt�|j��dd�dd�|jD���d�S)Nztyping_extensions.Annotated[r�csr0rr�rErQrrrr�r3z+_AnnotatedAlias.__repr__.<locals>.<genexpr>r�)rcr�r�r�r�r]rrrr^�s�z_AnnotatedAlias.__repr__cCstjt|jf|jffSrr)�operator�getitemr,r�r�r]rrr�
361  __reduce__�s�z_AnnotatedAlias.__reduce__cCs*t|t�stS|j|jkrdS|j|jkS)NF)r�r�r�r�r�r�rrrr��s
362  
363  z_AnnotatedAlias.__eq__cC�t|j|jf�Srr)r�r�r�r]rrrr���z_AnnotatedAlias.__hash__)rIrJrKrLrvr�r^r�r�r�r�rrr�rr�nsr�c@s2eZdZdZdZdd�Zejdd��Zdd�Z	d	S)
364  r,a�Add context specific metadata to a type.
365  
366          Example: Annotated[int, runtime_check.Unsigned] indicates to the
367          hypothetical runtime_check module that this type is an unsigned int.
368          Every other consumer of this type can ignore this metadata and treat
369          this type as int.
370  
371          The first argument to Annotated must be a valid type (and will be in
372          the __origin__ field), the remaining arguments are kept as a tuple in
373          the __extra__ field.
374  
375          Details:
376  
377          - It's an error to call `Annotated` with less than two arguments.
378          - Nested Annotated are flattened::
379  
380              Annotated[Annotated[T, Ann1, Ann2], Ann3] == Annotated[T, Ann1, Ann2, Ann3]
381  
382          - Instantiating an annotated type is equivalent to instantiating the
383          underlying type::
384  
385              Annotated[C, Ann1](5) == C(5)
386  
387          - Annotated can be used as a generic type alias::
388  
389              Optimized = Annotated[T, runtime.Optimize()]
390              Optimized[int] == Annotated[int, runtime.Optimize()]
391  
392              OptimizedList = Annotated[List[T], runtime.Optimize()]
393              OptimizedList[int] == Annotated[List[int], runtime.Optimize()]
394          rcOr?)Nz&Type Annotated cannot be instantiated.r@�rr�r
rrrr��rEzAnnotated.__new__cCsLt|t�rt|�dkrtd��d}t�|d|�}t|dd��}t||�S)NrVzUAnnotated[...] should be used with at least two arguments (a type and an annotation).�$Annotated[t, ...]: t must be a type.rrx)r�r�rrrcrdr�)rr%r r[r�rrrr'�s
395  zAnnotated.__class_getitem__cOstd|j�d���)N�Cannot subclass z
396  .Annotated)rrJr�rrrrL�s�zAnnotated.__init_subclass__N)
397  rIrJrKrLrr�rcrMr'rLrrrrr,�s 
398  
399  cCs\t|t�r
400  t|j�St|tj�r,tdd�|jD��}||jkr!|S|�|�}|j	|_	|S|S)z2Strips the annotations from a given type.
401          csr0rr��_strip_annotationsrQrrrr�r3z%_strip_annotations.<locals>.<genexpr>)
402  r�r�r�r�rcrer�r�r��_special)r-�
stripped_argsr�rrrr��s
403  
404  
405  
406  r�FcCs*tj|||d�}|r|Sdd�|��D�S)a]Return type hints for an object.
407  
408          This is often the same as obj.__annotations__, but it handles
409          forward references encoded as string literals, adds Optional[t] if a
410          default value equal to None is set and recursively replaces all
411          'Annotated[T, ...]' with 'T' (unless 'include_extras=True').
412  
413          The argument may be a module, class, method, or function. The annotations
414          are returned as a dictionary. For classes, annotations include also
415          inherited members.
416  
417          TypeError is raised if the argument is not of a type that can contain
418          annotations, and an empty dictionary is returned if no annotations are
419          present.
420  
421          BEWARE -- the behavior of globalns and localns is counterintuitive
422          (unless you are familiar with how eval() and exec() work).  The
423          search order is locals first, then globals.
424  
425          - If no dict arguments are passed, an attempt is made to use the
426            globals from obj (or the respective module's globals for classes),
427            and these are also used as the locals.  If the object does not appear
428            to have globals, an empty dictionary is used.
429  
430          - If one dict argument is passed, it is used for both globals and
431            locals.
432  
433          - If two dict arguments are passed, they specify globals and
434            locals, respectively.
435          )r�r�cSsi|]	\}}|t|��qSrr�)r�kr-rrrr{�sz"get_type_hints.<locals>.<dictcomp>)rcr;r)rCr�r��include_extras�hintrrrr;�sr;cCs t|�dko|�d�o|�d�S)z3Returns True if name is a __dunder_variable_name__.��__)rr��endswithr�rrr�
436  _is_dunder�s r�cs�eZdZdZ�fdd�Zedd��Zdd�Zd�fd	d
437  �	Zdd�Z	e
438  j�fd
d��Zdd�Z
dd�Z�fdd�Zdd�Zdd�Z�ZS)�
AnnotatedMetazMetaclass for Annotatedcs<tdd�|D��rtdtt���t�j||||fi|��S)Ncss�|]}|tuVqdSrr)rCr6rrrrr3z(AnnotatedMeta.__new__.<locals>.<genexpr>r�)rBrr+r,r�r�)rr�rYrZr
r�rrr�
439  szAnnotatedMeta.__new__cCs|��dS)NrV)rSr]rrrr��zAnnotatedMeta.__metadata__cCsX|\}}}t|t�st�|�}n|d�|�}d�dd�|D��}|�d|�d|�d�S)Nrr�csr0rrr��r�argrrrrr3z+AnnotatedMeta._tree_repr.<locals>.<genexpr>r�r�)r�r�rcr��
440  _tree_reprr�)rB�treerr[r�Ztp_reprZmetadata_reprsrrrr�s
441  
442  zAnnotatedMeta._tree_reprNcsh|turtSt�j||d�}t|dt�r2|ddtur2|dd}|dd}t|||dfS|S)N)rFr�rxrrV)r,r�rSr�r�)rBrFr�r�Zsub_tpZ	sub_annotr�rrrSszAnnotatedMeta._subs_treecCsd|jdur	td��|��}t|t�r'|dtur'|d}t|t�r'|dtust|t�r0|dS|S)z6Return the class used to create instance of this type.NzCCannot get the underlying type of a non-specialized Annotated type.rrx)r�rrSr�r�r,)rBr�rrr�	_get_cons's
443  �
444  zAnnotatedMeta._get_conscs�t|t�s|f}|jdurt��|�St|t�rt|�dkr"td��d}t�|d|�}t|dd��}|j	|j
445  |jt|j
�t|f�||f|d�S)NrVz]Annotated[...] should be instantiated with at least two arguments (a type and an annotation).r�rrx)rFr�r[)r�r�r�r�rhrrrcrdr�rIrAr
r�r)rBr%r rtr�r�rrrh4s"
446  
447  �zAnnotatedMeta.__getitem__cOs8|��}||i|��}z||_W|StyY|Swrr)r��__orig_class__rg)rBr�r
�cons�resultrrr�__call__Ls��zAnnotatedMeta.__call__cCs(|jdurt|�st|��|�St|��rr)r�r�r�r�rg)rBr�rrr�__getattr__UszAnnotatedMeta.__getattr__csJt|�s	|�d�rt��||�dS|jdurt|��t|��||�dS)Nr�)r�r�r�rVr�rg�setattrr�)rBr��valuer�rrrV[s
448  
449  zAnnotatedMeta.__setattr__cCr?)Nz+Annotated cannot be used with isinstance().r@rArrrrDcrEzAnnotatedMeta.__instancecheck__cCr?)Nz+Annotated cannot be used with issubclass().r@rFrrrrGfrEzAnnotatedMeta.__subclasscheck__)NN)rIrJrKrLr��propertyr�r�rSr�rcrMrhr�r�rVrDrGr�rrr�rr�s
450  	
	r�c@r�)r,avAdd context specific metadata to a type.
451  
452          Example: Annotated[int, runtime_check.Unsigned] indicates to the
453          hypothetical runtime_check module that this type is an unsigned int.
454          Every other consumer of this type can ignore this metadata and treat
455          this type as int.
456  
457          The first argument to Annotated must be a valid type, the remaining
458          arguments are kept as a tuple in the __metadata__ field.
459  
460          Details:
461  
462          - It's an error to call `Annotated` with less than two arguments.
463          - Nested Annotated are flattened::
464  
465              Annotated[Annotated[T, Ann1, Ann2], Ann3] == Annotated[T, Ann1, Ann2, Ann3]
466  
467          - Instantiating an annotated type is equivalent to instantiating the
468          underlying type::
469  
470              Annotated[C, Ann1](5) == C(5)
471  
472          - Annotated can be used as a generic type alias::
473  
474              Optimized = Annotated[T, runtime.Optimize()]
475              Optimized[int] == Annotated[int, runtime.Optimize()]
476  
477              OptimizedList = Annotated[List[T], runtime.Optimize()]
478              OptimizedList[int] == Annotated[List[int], runtime.Optimize()]
479          N�rIrJrKrLrrrrr,i�)r�
480  )�_BaseGenericAlias)�GenericAliascCs>t|t�rtSt|tjttttf�r|j	S|tj
481  urtj
482  SdS)a6Get the unsubscripted version of a type.
483  
484          This supports generic types, Callable, Tuple, Union, Literal, Final, ClassVar
485          and Annotated. Return None for unsupported types. Examples::
486  
487              get_origin(Literal[42]) is Literal
488              get_origin(int) is None
489              get_origin(ClassVar[int]) is ClassVar
490              get_origin(Generic) is Generic
491              get_origin(Generic[T]) is Generic
492              get_origin(Union[T, int]) is Union
493              get_origin(List[Tuple[T, T]][int]) == list
494              get_origin(P.args) is P
495          N)r�r�r,rcrer�r��
ParamSpecArgs�ParamSpecKwargsr�r�)rtrrrr:�s
496  �
497  r:cCszt|t�r|jf|jSt|tjtf�r;t|dd�rdS|j}t	|�t
498  jjur9|dt
ur9t|dd��|df}|SdS)a�Get type arguments with all substitutions performed.
499  
500          For unions, basic simplifications used by Union constructor are performed.
501          Examples::
502              get_args(Dict[str, int]) == (str, int)
503              get_args(int) == ()
504              get_args(Union[int, Union[T, int], str][int]) == (int, str)
505              get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int])
506              get_args(Callable[[], T][int]) == ([], int)
507          r�FrrNr�)r�r�r�r�rcrer�r�r�r:r�r�r��Ellipsisr�)rtr�rrrr9�s
508  r9r6)rrfc@�eZdZdd�ZdS)�_TypeAliasFormcCrYrZr[r]rrrr^�r_�_TypeAliasForm.__repr__N�rIrJrKr^rrrrr���r�cC�t|�d���)�&Special marker indicating that an assignment should
509          be recognized as a proper type alias definition by type
510          checkers.
511  
512          For example::
513  
514              Predicate: TypeAlias = Callable[..., bool]
515  
516          It's invalid when used anywhere except as in the example above.
517          � is not subscriptabler@r�rrrr6�sc@r�)r�cCrYrZr[r]rrrr^�r_r�Nr�rrrrr��r�a�Special marker indicating that an assignment should
518                                 be recognized as a proper type alias definition by type
519                                 checkers.
520  
521                                 For example::
522  
523                                     Predicate: TypeAlias = Callable[..., bool]
524  
525                                 It's invalid when used anywhere except as in the example
526                                 above.c@r�)�_TypeAliasMetazMetaclass for TypeAliascC�dS�Nztyping_extensions.TypeAliasrr]rrrr^�r�z_TypeAliasMeta.__repr__N�rIrJrKrLr^rrrrr���r�c@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
527  �_TypeAliasBaser�rcCr?)Nz+TypeAlias cannot be used with isinstance().r@rArrrrDrEz _TypeAliasBase.__instancecheck__cCr?)Nz+TypeAlias cannot be used with issubclass().r@rFrrrrG
528  rEz _TypeAliasBase.__subclasscheck__cCr�r�rr]rrrr^
r�z_TypeAliasBase.__repr__N)rIrJrKrLrrDrGr^rrrrr��s
529  r�)r�rNr�c@r=)�
530  _Immutablez3Mixin to indicate that object should not be copied.rcCr�rrrr]rrr�__copy__r�z_Immutable.__copy__cCr�rrr)rB�memorrr�__deepcopy__ r�z_Immutable.__deepcopy__N)rIrJrKrLrr�r�rrrrr�s
531  r�c@� eZdZdZdd�Zdd�ZdS)r�aQThe args for a ParamSpec object.
532  
533          Given a ParamSpec object P, P.args is an instance of ParamSpecArgs.
534  
535          ParamSpecArgs objects have a reference back to their ParamSpec:
536  
537          P.args.__origin__ is P
538  
539          This type is meant for runtime introspection and has no special meaning to
540          static type checkers.
541          cCrqrr�r��rBr[rrrrv/r_zParamSpecArgs.__init__cC�|jj�d�S)Nz.args�r�rIr]rrrr^2�zParamSpecArgs.__repr__N�rIrJrKrLrvr^rrrrr�#�c@r�)r�a[The kwargs for a ParamSpec object.
542  
543          Given a ParamSpec object P, P.kwargs is an instance of ParamSpecKwargs.
544  
545          ParamSpecKwargs objects have a reference back to their ParamSpec:
546  
547          P.kwargs.__origin__ is P
548  
549          This type is meant for runtime introspection and has no special meaning to
550          static type checkers.
551          cCrqrrr�r�rrrrvAr_zParamSpecKwargs.__init__cCr�)Nz.kwargsr�r]rrrr^Dr�zParamSpecKwargs.__repr__Nr�rrrrr�5r�r�rcs�eZdZdZejZedd��Zedd��Z	dddd��fd	d
552553  Z
554  dd�Zd
d�Zdd�Z
dd�Zdd�Zes>dd�Z�ZS�ZS)ra'Parameter specification variable.
555  
556          Usage::
557  
558             P = ParamSpec('P')
559  
560          Parameter specification variables exist primarily for the benefit of static
561          type checkers.  They are used to forward the parameter types of one
562          callable to another callable, a pattern commonly found in higher order
563          functions and decorators.  They are only valid when used in ``Concatenate``,
564          or s the first argument to ``Callable``. In Python 3.10 and higher,
565          they are also supported in user-defined Generics at runtime.
566          See class Generic for more information on generic types.  An
567          example for annotating a decorator::
568  
569             T = TypeVar('T')
570             P = ParamSpec('P')
571  
572             def add_logging(f: Callable[P, T]) -> Callable[P, T]:
573                 '''A type-safe decorator to add logging to a function.'''
574                 def inner(*args: P.args, **kwargs: P.kwargs) -> T:
575                     logging.info(f'{f.__name__} was called')
576                     return f(*args, **kwargs)
577                 return inner
578  
579             @add_logging
580             def add_two(x: float, y: float) -> float:
581                 '''Add two numbers together.'''
582                 return x + y
583  
584          Parameter specification variables defined with covariant=True or
585          contravariant=True can be used to declare covariant or contravariant
586          generic types.  These keyword arguments are valid, but their actual semantics
587          are yet to be decided.  See PEP 612 for details.
588  
589          Parameter specification variables can be introspected. e.g.:
590  
591             P.__name__ == 'T'
592             P.__bound__ == None
593             P.__covariant__ == False
594             P.__contravariant__ == False
595  
596          Note that only parameter specification variables defined in global scope can
597          be pickled.
598          cC�t|�Srr)r�r]rrrr���zParamSpec.argscCr�rr)r�r]rrrr
�r�zParamSpec.kwargsNF)�boundrSrUc	s�t��|g�||_t|�|_t|�|_|rt�|d�|_nd|_zt	�
599  d�j�dd�}Wn
t
tfy:d}Ynw|dkrD||_dSdS)NzBound must be a type.rxrIrq�typing_extensions)r�rvrI�bool�
__covariant__�__contravariant__rcrd�	__bound__r�r�r�r;rgrhrJ)rBr�r�rSrU�def_modr�rrrv�s
600  
601  �
602  �zParamSpec.__init__cCs&|jrd}n|jrd}nd}||jS)N�+�-�~)r�r�rI)rB�prefixrrrr^�s
603  zParamSpec.__repr__cCr�rr)rCr�r]rrrr��r_zParamSpec.__hash__cCs||uSrrrr�rrrr��rEzParamSpec.__eq__cC�|jSrr)rIr]rrrr���zParamSpec.__reduce__cOrcrrrrrrrr��r�zParamSpec.__call__cCs||vr|�|�dSdSrr)�append�rBrFrrr�_get_type_vars�s�zParamSpec._get_type_vars)rIrJrKrLrcr�r�r�r�r
rvr^r�r�r�r��PEP_560r�r�rrr�rrNs /
604  
605  	�rcspeZdZer
606  ejZnejZdZej	Z
607  �fdd�Zdd�Zdd�Z
dd	�Zed
608  d��Zes4dd
�Z�ZS�ZS)�_ConcatenateGenericAliasFcst��|�||_||_dSrr)r�rvr�r�)rBr[r�r�rrrv�s
609  z!_ConcatenateGenericAlias.__init__cs2tj��|j��dd��fdd�|jD���d�S)Nr�r�c3s�|]}�|�VqdSrrrr��r�rrr�r3z4_ConcatenateGenericAlias.__repr__.<locals>.<genexpr>r�)rcr�r�r�r�r]rr�rr^�s�z!_ConcatenateGenericAlias.__repr__cCr�rr)r�r�r�r]rrrr��r�z!_ConcatenateGenericAlias.__hash__cOrcrrrrrrrr��r�z!_ConcatenateGenericAlias.__call__cCstdd�|jD��S)Ncss$�|]
}t|tjtf�r|VqdSrr)r�rcr�r)rrtrrrr�s��
610  �z:_ConcatenateGenericAlias.__parameters__.<locals>.<genexpr>)r�r�r]rrrr�s�z'_ConcatenateGenericAlias.__parameters__cCs&|jr|jrt�|j|�dSdSdSrr)r�rrcr�r�rrrr��s�z'_ConcatenateGenericAlias._get_type_vars)rIrJrKr�rcrer�Z_TypingBaser�r�r�rvr^r�r�r�rr�r�rrr�rr��s
611  �r�csZ|dkrtd��t|t�s|f}t|dt�std��d�t�fdd�|D��}t||�S)Nrz&Cannot take a Concatenate of no types.r�zAThe last parameter to Concatenate should be a ParamSpec variable.z/Concatenate[arg, ...]: each arg must be a type.c3rrrrrrrrr�r!z'_concatenate_getitem.<locals>.<genexpr>)rr�r�rr�r�rrr�_concatenate_getitem�s
612  
613  r�cC�
614  t||�S)�&Used in conjunction with ``ParamSpec`` and ``Callable`` to represent a
615          higher order function which adds, removes or transforms parameters of a
616          callable.
617  
618          For example::
619  
620             Callable[Concatenate[int, P], int]
621  
622          See PEP 612 for detailed information.
623          �r�r�rrrr�s
624  c@rW)�_ConcatenateFormcCrYrZr[r]rrrr^
625  r_z_ConcatenateForm.__repr__cCr�rrr�r�rrrrh
r_z_ConcatenateForm.__getitem__Nrjrrrrr�	�r�r�c@r�)�_ConcatenateAliasMetazMetaclass for Concatenate.cCr��Nztyping_extensions.Concatenaterr]rrrr^!r�z_ConcatenateAliasMeta.__repr__Nr�rrrrr�r�r�c@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
626  �ZdS)�_ConcatenateAliasBaser�rcCr?)Nz-Concatenate cannot be used with isinstance().r@rArrrrD3rEz'_ConcatenateAliasBase.__instancecheck__cCr?)Nz-Concatenate cannot be used with issubclass().r@rFrrrrG6rEz'_ConcatenateAliasBase.__subclasscheck__cCr�r�rr]rrrr^9r�z_ConcatenateAliasBase.__repr__cCr�rrr�r�rrrrh<r_z!_ConcatenateAliasBase.__getitem__N)	rIrJrKrLrrDrGr^rhrrrrr�$s
627  r�r7c@r�)�_TypeGuardFormcCrYrZr[r]rrrr^Gr_�_TypeGuardForm.__repr__Nr�rrrrr�Fr�r�cCs t�||�d��}t�||f�S)�	Special typing form used to annotate the return type of a user-defined
628          type guard function.  ``TypeGuard`` only accepts a single type argument.
629          At runtime, functions marked this way should return a boolean.
630  
631          ``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static
632          type checkers to determine a more precise type of an expression within a
633          program's code flow.  Usually type narrowing is done by analyzing
634          conditional code flow and applying the narrowing to a block of code.  The
635          conditional expression here is sometimes referred to as a "type guard".
636  
637          Sometimes it would be convenient to use a user-defined boolean function
638          as a type guard.  Such a function should use ``TypeGuard[...]`` as its
639          return type to alert static type checkers to this intention.
640  
641          Using  ``-> TypeGuard`` tells the static type checker that for a given
642          function:
643  
644          1. The return value is a boolean.
645          2. If the return value is ``True``, the type of its argument
646          is the type inside ``TypeGuard``.
647  
648          For example::
649  
650              def is_str(val: Union[str, float]):
651                  # "isinstance" type guard
652                  if isinstance(val, str):
653                      # Type of ``val`` is narrowed to ``str``
654                      ...
655                  else:
656                      # Else, type of ``val`` is narrowed to ``float``.
657                      ...
658  
659          Strict type narrowing is not enforced -- ``TypeB`` need not be a narrower
660          form of ``TypeA`` (it can even be a wider form) and this may lead to
661          type-unsafe results.  The main reason is to allow for things like
662          narrowing ``List[object]`` to ``List[str]`` even though the latter is not
663          a subtype of the former, since ``List`` is invariant.  The responsibility of
664          writing type-safe type guards is left to the user.
665  
666          ``TypeGuard`` also works with type variables.  For more information, see
667          PEP 647 (User-Defined Type Guards).
668          ry)rcrdrerfrrrr7Js,c@rW)r�cCrYrZr[r]rrrr^|r_r�cCr`)Nz accepts only a single typerbrfrrrrhriz_TypeGuardForm.__getitem__Nrjrrrrr�zrkr�crm)�
669  _TypeGuardr�roNcKrqrrrorsrrrrv�r_z_TypeGuard.__init__cCrw)Nrxz accepts only a single type.TrMrzr{r}rrrrh�r~z_TypeGuard.__getitem__cCrr�r�r�rrrr��r�z_TypeGuard._eval_typecr�r�r�r�r�rrr^�r�z_TypeGuard.__repr__cCr�rrr�r]rrrr��r�z_TypeGuard.__hash__cCr�rr)r�r�r�rpr�rrrr��r�z_TypeGuard.__eq__rrr�rrr�rr��s+
670  r�rc@sneZdZdZdd�Zdd�Zdd�Zdd	�Zd
671  d�Zdd
�Z	dd�Z
672  dd�Zdd�Zdd�Z
ejdd��ZdS)�_SpecialForm)r\rL�_getitemcCs||_|j|_|j|_dSrr)r�rIr\rL)rBr�rrrrv
673  sz_SpecialForm.__init__cCs|dvr|jSt|��)N>rIrK)r\rg)rBrgrrrr�sz_SpecialForm.__getattr__cC�td|����)Nr�r@)rBrYrrr�__mro_entries__r�z_SpecialForm.__mro_entries__cCsd|j��SrZr[r]rrrr^r�z_SpecialForm.__repr__cCr�rrr[r]rrrr�r�z_SpecialForm.__reduce__cOr�)NzCannot instantiate r@)rBr�rurrrr�r�z_SpecialForm.__call__cCstj||fSrr�rc�Unionr�rrr�__or__!r�z_SpecialForm.__or__cCstj||fSrrr�r�rrr�__ror__$r�z_SpecialForm.__ror__cCr�)Nz! cannot be used with isinstance()r@rArrrrD'r�z_SpecialForm.__instancecheck__cCr�)Nz! cannot be used with issubclass()r@rFrrrrG*r�z_SpecialForm.__subclasscheck__cCs|�||�Srr)r�r�rrrrh-r�z_SpecialForm.__getitem__N)rIrJrKrrvr�r�r^r�r�r�r�rDrGrcrMrhrrrrr�sr�cCr�)��Used to spell the type of "self" in classes.
674  
675          Example::
676  
677            from typing import Self
678  
679            class ReturnsSelf:
680                def parse(self, data: bytes) -> Self:
681                    ...
682                    return self
683  
684          r�r@)rBr%rrrr1sc@r=)�_Selfr�rcCr�)Nz" cannot be used with isinstance().r@rArrrrDRr�z_Self.__instancecheck__cCr�)Nz" cannot be used with issubclass().r@rFrrrrGUr�z_Self.__subclasscheck__NrHrrrrr�Bs
685  
r��Requiredc@r�)�_ExtensionsSpecialFormcCrYrZr[r]rrrr^`r_z_ExtensionsSpecialForm.__repr__Nr�rrrrr�_r�r�cCr`)��A special typing construct to mark a key of a total=False TypedDict
686          as required. For example:
687  
688              class Movie(TypedDict, total=False):
689                  title: Required[str]
690                  year: int
691  
692              m = Movie(
693                  title='The Matrix',  # typechecker error if key is omitted
694                  year=1999,
695              )
696  
697          There is no runtime checking that a required key is actually provided
698          when instantiating a related TypedDict.
699          rarbrfrrrr�cscCr`)�`A special typing construct to mark a key of a TypedDict as
700          potentially missing. For example:
701  
702              class Movie(TypedDict):
703                  title: str
704                  year: NotRequired[int]
705  
706              m = Movie(
707                  title='The Matrix',  # typechecker error if key is omitted
708                  year=1999,
709              )
710          rarbrfrrr�NotRequiredwsrc@rW)�
_RequiredFormcCrYrZr[r]rrrr^�r_z_RequiredForm.__repr__cCs"t�|d�|j��}t�||f�S)Nz{} accepts only single type)rcrd�formatr\rerfrrrrh�riz_RequiredForm.__getitem__Nrjrrrrr�r�rr�r�csJeZdZdZddd�Zdd�Zdd�Z�fd	d
711  �Zdd�Zd
d�Z	�Z
712  S)�_MaybeRequiredroNcKrqrrrorsrrrrv�r_z_MaybeRequired.__init__c	CsNt|�}|jdur|t�|d�|jdd���dd�Std�|jdd����)Nz{} accepts only single type.rxTrMz {} cannot be further subscripted)r|rprcrdrrIrr}rrrrh�s
713  ���z_MaybeRequired.__getitem__cCrr�r�r�rrrr��r�z_MaybeRequired._eval_typecs.t���}|jdur|d�t�|j��7}|S)Nz[{}])r�r^rprrcr�r�r�rrr^�s
714  
715  z_MaybeRequired.__repr__cCr�rrr�r]rrrr��r�z_MaybeRequired.__hash__cCs0t|t|��s	tS|jdur|j|jkS||uSrr)r�r|r�rpr�rrrr��s
716  
717  z_MaybeRequired.__eq__rr)rIrJrKrrvrhr�r^r�r�r�rrr�rr�s
718  	rc@r�)�	_Requiredr�Nr�rrrrr�r�rc@r�)�_NotRequiredr�Nr�rrrrr�r�r)NNF)�r�r��collections.abcr�r�rc�version_infor�r|rrr
r�__all__�extendr�r<Z_FinalTypingBaser>r�rOrPrQrRrTrrr�rXrnr-r.r/r�r��_overload_dummyr1rr�rr!r rr'r��MutableSequencer%r#�_collections_abcr�r�r�r(r)�_alias�MutableMappingr&�Dictrer$r"r0r5r8r�rDrrr2rrrTrrNrdr4r3r+r*rirl�__text_signature__ryrurrIrJrLr,r;r�rer�r�r�r:r9r��ImportErrorr�r6r�r^r�r�r�r�r�rr�r�rMr�rr�r�r�r7r�r�rr�r�rr�rrrrrrrr�<module>s�-
719  
720  
721  
722  
723  
724  �
725  3
726  
727  �
728  .�
729  &����
730  !B(,,� '6&b#
731  �
732  �
�

733  
734  j,
735  
��
736  .
737  �.
738  O*
739  
740  
741  	�
742  �%
743