o
     JAfi                    @   s  	 d dl mZmZ d dlZd dlZd dlZd dlZd dlZd dlZ	d dl
Z
d dlZd dlmZmZmZmZ g dZdddddZdddd
dZdd Zdd ZdddZdd Zdd Zdd Zdd Zdd Zg ZdddddZe fdd ZG d!d" d"ZG d#d$ d$Z G d%d& d&ed	d'Z!G d(d) d)e!d	d'Z"e!d*d+ Z#e!d,d- Z$e!d.d/ Z%e!d0d1 Z&e!d2d3 Z'e!d4d5 Z(e"ed	dd6d7 Z)e!d8d9 Z*e!d:d; Z+e!d<d= Z,G d>d? d?ed	d'Z-G d@dA dAZ.G dBdC dCee e.d	d'Z/G dDdE dEee d	d'Z0G dFdG dGee d	d'Z1G dHdI dIee e.d	d'Z2dJdK Z3G dLdM dMed	d'Z4G dNdO dOe4d	d'Z5G dPdQ dQe4d	d'Z6G dRdS dSe5d	d'Z7G dTdU dUe6d	d'Z8G dVdW dWe6d	d'Z9G dXdY dYe5d	d'Z:dZd[ Z;G d\d] d]e5d	d'Z<G d^d_ d_e5d	d'Z=G d`da daZ>G dbdc dcZ?G ddde deZ@g dfZAg dgZBeAeB dhg ZCdidj ZDdkdl ZEdmdn ZFddqdrZGddtduZHg dvdwdxgdyZIG dzd{ d{eZJG d|d} d}e>eJd~ZKG dd de5d	d'ZLG dd dZMdd ZNdd ZOdd ZPejQejRejSejTeeefZUdddZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_e/dZ`e/dZae/dZbe/dd	dZce/dd	dZde/dd	dZee/dd	dZfe/dd	egdZhe/deiejZke6Zlelej jmd Zmelej jndoZnelej jodsZoelej jpdoZpelej jqdoZqelej jrdoZrelej jsdoZselej jtdoZtelej jud Zuelej jvdoZvelej jwdoZwe8ej jxdZxdex_yelej jzdoddZ{elej j|doZ|elej j}dZ}elej j~dZ~elej jdoZelej jdoZelej jd Ze9eddddZde_yeledodddZelejdoddZeledodddZzeledodddZelej jdoZelej jdoZelej jdZelej jdoZelejdoddZelejdoddZeleddddZelejdddZelejdZelejdoZelejdZelej jdsZelej jdZelegdodddZde_yeNG dd deKZeNG dd deKZeNG dd deKZeNG dd deKZeNG ddĄ deKZeNG ddƄ deKec ZeNG ddȄ deKec Zddd˄Zeh ḍZeh dͣZG ddτ degZdddфZegeddi Zddӄ Zee_G ddՄ degZdd	d֜dd؄Zegeddi Zddڄ e_G dd܄ d܃ZejZdZG ddބ de>ek ZG dd deei ZG dd deej ZG dd dZed e_ee
jej< ele	jdoZele	jdoZG dd dZed e_ee
jej< dS )    )abstractmethodABCMetaN)WrapperDescriptorTypeMethodWrapperTypeMethodDescriptorTypeGenericAlias)T	AnnotatedAnyCallableClassVarConcatenateFinal
ForwardRefGenericLiteralOptional	ParamSpecProtocolTupleTypeTypeVarUnionAbstractSet
ByteString	ContainerContextManagerHashable	ItemsViewIterableIteratorKeysViewMappingMappingViewMutableMappingMutableSequence
MutableSetSequenceSized
ValuesView	AwaitableAsyncIteratorAsyncIterable	Coroutine
CollectionAsyncGeneratorAsyncContextManager
ReversibleSupportsAbsSupportsBytesSupportsComplexSupportsFloatSupportsIndexSupportsIntSupportsRoundChainMapCounterDequeDictDefaultDictListOrderedDictSet	FrozenSet
NamedTuple	TypedDict	GeneratorBinaryIOIOMatchPatternTextIOAnyStrcastfinalget_args
get_originget_type_hintsis_typeddictNewTypeno_type_checkno_type_check_decoratorNoReturnoverloadParamSpecArgsParamSpecKwargsruntime_checkableTextTYPE_CHECKING	TypeAlias	TypeGuardFallow_special_formsc                C   s.   	 | d u r	t d S t| trt| ||dS | S )N)moduleis_class)type
isinstancestrr   )argr^   r]    rd   /usr/lib/python3.10/typing.py_type_convert   s   
rf   Tc             	   C   s   	 t tf}|s|tf7 }|r|tf7 }t| ||d} t| tr+| j|v r+t|  d| t	t
ttfv r5| S t| ts@| t tfv rHtd|  dt| ttttjtttfrW| S t| sft| d| dd| S )N)r^   r]   z is not valid as type argumentzPlain z Got z.100.)r   r   r   r   rf   ra   _GenericAlias
__origin__	TypeErrorr	   rS   rZ   _SpecialFormr`   r   r   types	UnionTyper   rU   rV   callable)rc   msgis_argumentr^   r]   Zinvalid_generic_formsrd   rd   re   _type_check   s*   



rq   c                 C   s   | du pt | ttttfS )N.)ra   tuplelistr   _ConcatenateGenericAlias)rc   rd   rd   re   _is_param_expr   s   
ru   c                 C   sh   	 t | tjrt| S t | tr!| jdkr| jS | j d| j S | du r'dS t | tjr0| jS t| S )Nbuiltinsrg   .z...)	ra   rl   r   reprr`   
__module____qualname__FunctionType__name__)objrd   rd   re   
_type_repr   s   

r}   c                    sl   	 |d u rt }g  | D ]&}t||r| vr | t|tttjfr1  fdd|jD  qt	 S )Nc                    s   g | ]}| vr|qS rd   rd   .0ttvarsrd   re   
<listcomp>       z&_collect_type_vars.<locals>.<listcomp>)
r   ra   appendrh   r   rl   rm   extend__parameters__rr   )Ztypes_typevar_typesr   rd   r   re   _collect_type_vars   s   
r   c              	   C   sT   	 |s
t |  dt|}||kr(t d||krdnd d|  d| d| d S )Nz is not a generic classzToo manyfewz arguments for z	; actual z, expected )rj   len)cls
parametersZelenZalenrd   rd   re   _check_generic   s   r   c                 C   s   	 t | jdkr|rt|d s|fS t| |t | j g }t|| jD ]\}}t|tr6t|tr6t|}|	| q$t|S N   r   )
r   r   ru   r   zipra   r   rs   rr   r   )r   paramsZ_paramspZtvarrd   rd   re   _prepare_paramspec_params   s   
r   c                 C   sJ   t | }t|t| k r#g }| D ]}||v r || || q|} | S N)setr   r   remove)r   Z
all_paramsZ
new_paramsr   rd   rd   re   _deduplicate   s   

r   c                 C   sz   	 g }| D ]1}t |ttjfr||j qt |tr1t|dkr1|d tu r1||dd   q|	| qtt
|S )Nr   r   )ra   _UnionGenericAliasrl   rm   r   __args__rr   r   r   r   r   r   r   r   rd   rd   re   _remove_dups_flatten  s   "r   c                 C   s:   	 g }| D ]}t |tr||j q|| qt|S r   )ra   _LiteralGenericAliasr   r   r   rr   r   rd   rd   re   _flatten_literal_params  s   
r   typedc                  s"   	  fdd}| d ur|| S |S )Nc                    s8   t jd t j t  fdd}|S )Nr   c                     s2   z | i |W S  t y   Y nw | i |S r   rj   argskwdscachedfuncrd   re   inner2  s   z+_tp_cache.<locals>.decorator.<locals>.inner)	functools	lru_cache	_cleanupsr   cache_clearwraps)r   r   r   r   re   	decorator.  s
   z_tp_cache.<locals>.decoratorrd   )r   r   r   rd   r   re   	_tp_cache*  s
   r   c                    s   	 t | tr|  S t | tttjfrHt fdd| jD }|| jkr+| S t | tr6t| j	|S t | tjrCt
tj|S | |S | S )Nc                 3   s    | ]
}t | V  qd S r   )
_eval_typer   aglobalnslocalnsrecursive_guardrd   re   	<genexpr>I      z_eval_type.<locals>.<genexpr>)ra   r   	_evaluaterh   r   rl   rm   rr   r   ri   r   reduceoperatoror_	copy_with)r   r   r   r   Zev_argsrd   r   re   r   @  s   



r   c                   @   s   e Zd Z	 dZdd ZdS )_Final)__weakref__c                O   s   d|vrt dd S )N_rootz&Cannot subclass special typing classesr   selfr   r   rd   rd   re   __init_subclass__Z  s   z_Final.__init_subclass__N)r{   rx   ry   	__slots__r   rd   rd   rd   re   r   U  s    r   c                   @   s"   e Zd Z	 dZdd Zdd ZdS )
_Immutablerd   c                 C      | S r   rd   r   rd   rd   re   __copy__b     z_Immutable.__copy__c                 C   r   r   rd   )r   memord   rd   re   __deepcopy__e  r   z_Immutable.__deepcopy__N)r{   rx   ry   r   r   r   rd   rd   rd   re   r   ^  s
    r   c                   @   sl   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zedd ZdS )rk   )_name__doc___getitemc                 C   s   || _ |j| _|j| _d S r   )r   r{   r   r   )r   getitemrd   rd   re   __init__n  s   z_SpecialForm.__init__c                 C   s   |dv r| j S t|)N>   r{   ry   )r   AttributeError)r   itemrd   rd   re   __getattr__s  s   z_SpecialForm.__getattr__c                 C      t d| )NCannot subclass r   )r   basesrd   rd   re   __mro_entries__y     z_SpecialForm.__mro_entries__c                 C   
   d| j  S Ntyping.r   r   rd   rd   re   __repr__|     
z_SpecialForm.__repr__c                 C      | j S r   r   r   rd   rd   re   
__reduce__     z_SpecialForm.__reduce__c                 O   r   )NzCannot instantiate r   r   rd   rd   re   __call__  r   z_SpecialForm.__call__c                 C      t | |f S r   r   r   otherrd   rd   re   __or__     z_SpecialForm.__or__c                 C      t || f S r   r   r   rd   rd   re   __ror__  r   z_SpecialForm.__ror__c                 C      t |  d)Nz! cannot be used with isinstance()r   r   r|   rd   rd   re   __instancecheck__  r   z_SpecialForm.__instancecheck__c                 C   r   )Nz! cannot be used with issubclass()r   r   r   rd   rd   re   __subclasscheck__  r   z_SpecialForm.__subclasscheck__c                 C   s   |  | |S r   )r   r   r   rd   rd   re   __getitem__  s   z_SpecialForm.__getitem__N)r{   rx   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   rd   rd   rd   re   rk   k  s    rk   )r   c                   @      e Zd Zdd ZdS )_LiteralSpecialFormc                 C   s"   t |ts|f}| j| g|R  S r   )ra   rr   r   r   rd   rd   re   r     s   
z_LiteralSpecialForm.__getitem__N)r{   rx   ry   r   rd   rd   rd   re   r     s    r   c                 C      	 t |  dNz is not subscriptabler   r   rd   rd   re   r	        
r	   c                 C   r   r   r   r   rd   rd   re   rS     s   rS   c                 C      	 t ||  d}t| |fS Nz accepts only single type.rq   rh   r   r   r   rd   rd   re   r     s   r   c                 C   r   r   r   r   rd   rd   re   r     s   r   c                    s   	 |dkr	t dt|ts|f}d t fdd|D }t|}t|dkr,|d S t|dkr?td |v r?t| |d	d
S t| |S )Nrd   z Cannot take a Union of no types.z)Union[arg, ...]: each arg must be a type.c                 3       | ]}t | V  qd S r   rq   r   r   ro   rd   re   r         zUnion.<locals>.<genexpr>r   r      r   name)rj   ra   rr   r   r   r`   r   r   rd   r   re   r     s   

r   c                 C   s"   	 t ||  d}t|td f S )Nz requires a single type.)rq   r   r`   )r   r   rc   rd   rd   re   r     s   r   c                 G   sJ   	 t |}ztdd ttt|D }W n	 ty   Y nw t| |S )Nc                 s   s    | ]\}}|V  qd S r   rd   )r   r   _rd   rd   re   r   0      zLiteral.<locals>.<genexpr>)r   rr   r   rs   _value_and_type_iterrj   r   r   rd   rd   re   r     s   "
r   c                 C   r   r   r   r   rd   rd   re   rZ   7  r   rZ   c                    sx   	 |dkr	t dt|ts|f}t|d tst dd g  fdd|d d D |d R }t| |ttfdd	S )
Nrd   z&Cannot take a Concatenate of no types.AThe last parameter to Concatenate should be a ParamSpec variable.z/Concatenate[arg, ...]: each arg must be a type.c                 3   r   r   r   r   r   rd   re   r   Z  r   zConcatenate.<locals>.<genexpr>T_typevar_types_paramspec_tvars)rj   ra   rr   r   rt   r   r   rd   r   re   r   F  s   

(r   c                 C   r   r   r   r   rd   rd   re   r[   `  s   *r[   c                   @   sB   e Zd Z	 dZdddddZdd	 Zd
d Zdd Zdd ZdS )r   )__forward_arg____forward_code____forward_evaluated____forward_value____forward_is_argument____forward_is_class____forward_module__TNF)r_   c                C   st   t |tstd|zt|dd}W n ty"   td|w || _|| _d| _d | _|| _	|| _
|| _d S )Nz*Forward reference must be a string -- got z<string>evalz/Forward reference must be an expression -- got F)ra   rb   rj   compileSyntaxErrorr  r  r  r  r  r  r  )r   rc   rp   r^   r_   coderd   rd   re   r     s   

zForwardRef.__init__c                 C   s   | j |v r| S | jr||urW|d u r|d u ri  }}n|d u r"|}n|d u r(|}| jd ur9ttj| jd d|}tt| j	||d| j
| jd}t||||| j hB | _d| _| jS )N__dict__z*Forward references must evaluate to types.)rp   r]   T)r  r  r  getattrsysmodulesgetrq   r  r  r  r  r   r  )r   r   r   r   Ztype_rd   rd   re   r     s0   


zForwardRef._evaluatec                 C   sJ   t |tstS | jr|jr| j|jko| j|jkS | j|jko$| j|jkS r   )ra   r   NotImplementedr  r  r  r  r   rd   rd   re   __eq__  s   


zForwardRef.__eq__c                 C      t | j| jfS r   )hashr  r  r   rd   rd   re   __hash__     zForwardRef.__hash__c                 C   s   d| j dS )NzForwardRef())r  r   rd   rd   re   r     r   zForwardRef.__repr__TN)	r{   rx   ry   r   r   r   r  r   r   rd   rd   rd   re   r     s    	r   c                   @   s6   e Zd Z	 dd Zdd Zdd Zdd Zd	d
 ZdS )_TypeVarLikec                 C   sD   	 |r	|r	t dt|| _t|| _|rt|d| _d S d | _d S )Nz"Bivariant types are not supported.zBound must be a type.)
ValueErrorbool__covariant____contravariant__rq   	__bound__)r   bound	covariantcontravariantrd   rd   re   r     s   


z_TypeVarLike.__init__c                 C   r   r   r   r   rightrd   rd   re   r     r   z_TypeVarLike.__or__c                 C   r   r   r   r   leftrd   rd   re   r     r   z_TypeVarLike.__ror__c                 C   s&   | j rd}n| jrd}nd}|| j S )N+-~)r'  r(  r{   )r   prefixrd   rd   re   r     s   
z_TypeVarLike.__repr__c                 C   r   r   )r{   r   rd   rd   re   r     r   z_TypeVarLike.__reduce__N)r{   rx   ry   r   r   r   r   r   rd   rd   rd   re   r$    s    	r$  c                       s,   e Zd Z	 dZdddd fdd
Z  ZS )r   )r{   r)  __constraints__r'  r(  r  NFr*  r+  r,  c             	      s   || _ t ||| |r|d urtd|r!t|dkr!tdd t fdd|D | _ztdj	
dd}W n ttfyH   d }Y nw |d	krR|| _d S d S )
Nz-Constraints cannot be combined with bound=...r   z"A single constraint is not allowedz:TypeVar(name, constraint, ...): constraints must be types.c                 3   r   r   r   r~   r   rd   re   r   *  r   z#TypeVar.__init__.<locals>.<genexpr>r{   __main__typing)r{   superr   rj   r   rr   r5  r  	_getframe	f_globalsr  r   r%  rx   )r   r  r*  r+  r,  Zconstraintsdef_mod	__class__r   re   r   !  s    
zTypeVar.__init__)r{   rx   ry   r   r   __classcell__rd   rd   r=  re   r     s    +r   c                   @   &   e Zd Z	 dd Zdd Zdd ZdS )rU   c                 C   
   || _ d S r   ri   r   originrd   rd   re   r   ?  r   zParamSpecArgs.__init__c                 C      | j j dS )Nz.argsri   r{   r   rd   rd   re   r   B  r   zParamSpecArgs.__repr__c                 C      t |tstS | j|jkS r   )ra   rU   r  ri   r   rd   rd   re   r  E     
zParamSpecArgs.__eq__Nr{   rx   ry   r   r   r  rd   rd   rd   re   rU   3  
    rU   c                   @   r@  )rV   c                 C   rA  r   rB  rC  rd   rd   re   r   W  r   zParamSpecKwargs.__init__c                 C   rE  )Nz.kwargsrF  r   rd   rd   re   r   Z  r   zParamSpecKwargs.__repr__c                 C   rG  r   )ra   rV   r  ri   r   rd   rd   re   r  ]  rH  zParamSpecKwargs.__eq__NrI  rd   rd   rd   re   rV   K  rJ  rV   c                       sD   e Zd Z	 dZedd Zedd Zdddd fd	d

Z  ZS )r   )r{   r)  r'  r(  r  c                 C      t | S r   )rU   r   rd   rd   re   r        zParamSpec.argsc                 C   rK  r   )rV   r   rd   rd   re   kwargs  rL  zParamSpec.kwargsNFr6  c             	      s`   || _ t ||| ztdjdd}W n ttfy$   d }Y nw |dkr.|| _	d S d S )Nr   r{   r7  r8  )
r{   r9  r   r  r:  r;  r  r   r%  rx   )r   r  r*  r+  r,  r<  r=  rd   re   r     s   
zParamSpec.__init__)	r{   rx   ry   r   propertyr   rM  r   r?  rd   rd   r=  re   r   c  s    -

r   c                 C   s   |  do	| dS )N__)
startswithendswith)attrrd   rd   re   
_is_dunder  s   rS  c                       sb   e Zd Z	 dddddZdd Zdd	 Zd
d Z fddZdd Zdd Z	 fddZ
  ZS )_BaseGenericAliasTNinstr  c                C   s   || _ || _|| _d | _d S r   )_instr   ri   r   )r   rD  rV  r  rd   rd   re   r     s   
z_BaseGenericAlias.__init__c                 O   sT   | j std| j d| jj d| j|i |}z| |_W |S  ty)   Y |S w )NzType z cannot be instantiated; use z
() instead)rW  rj   r   ri   r{   __orig_class__r   )r   r   rM  resultrd   rd   re   r     s   
z_BaseGenericAlias.__call__c                 C   sj   g }| j |vr|| j  || }||d d  D ]}t|ts&t|tr+ t|S q|t t|S )Nr   )ri   r   indexra   rT  
issubclassr   rr   )r   r   resibrd   rd   re   r     s   


z!_BaseGenericAlias.__mro_entries__c                 C   s<   |dv r| j p
| jjS d| jv rt|st| j|S t|)N>   r{   ry   ri   )r   ri   r{   r  rS  r  r   r   rR  rd   rd   re   r     s
   z_BaseGenericAlias.__getattr__c                    s4   t |s|dv rt || d S t| j|| d S )N>   r   rW  _nparamsr
  r  )rS  r9  __setattr__setattrri   )r   rR  valr=  rd   re   ra    s   z_BaseGenericAlias.__setattr__c                 C      |  t|S r   r   r`   r   rd   rd   re   r     r   z#_BaseGenericAlias.__instancecheck__c                 C      t d)NzBSubscripted generics cannot be used with class and instance checksr   r   rd   rd   re   r        z#_BaseGenericAlias.__subclasscheck__c                    s&   t tt  dd t| jD  S )Nc                 S   s   g | ]}t |s|qS rd   )rS  r   rR  rd   rd   re   r     r   z-_BaseGenericAlias.__dir__.<locals>.<listcomp>)rs   r   r9  __dir__dirri   r   r=  rd   re   ri    s   z_BaseGenericAlias.__dir__)r{   rx   ry   r   r   r   r   ra  r   r   ri  r?  rd   rd   r=  re   rT    s    
rT  c                       sx   e Zd Zddedd fdd
Zdd Zd	d
 Zdd Zdd Ze	dd Z
dd Zdd Zdd Z fddZ  ZS )rh   TNF)rV  r  r
  r  c                   sd   t  j|||d t|ts|f}tdd |D | _t||d| _|| _|| _|s0|j	| _	d S d S )NrU  c                 s   s,    | ]}|t u r
d n|tu rdn|V  qdS ).rd   N)_TypingEllipsis_TypingEmptyr   rd   rd   re   r     s    
z)_GenericAlias.__init__.<locals>.<genexpr>)r   )
r9  r   ra   rr   r   r   r   r
  r  rx   )r   rD  r   rV  r  r
  r  r=  rd   re   r     s   

z_GenericAlias.__init__c                 C   &   t |tstS | j|jko| j|jkS r   )ra   rh   r  ri   r   r   rd   rd   re   r    
   

z_GenericAlias.__eq__c                 C   r  r   )r  ri   r   r   rd   rd   re   r     r!  z_GenericAlias.__hash__c                 C   r   r   r   r-  rd   rd   re   r     r   z_GenericAlias.__or__c                 C   r   r   r   r/  rd   rd   re   r     r   z_GenericAlias.__ror__c                    sL  | j ttfv rtd|  t|ts|f}tdd |D }| jr2tdd | jD r2t	| |}n	t
| |t| j tt| j| g }| jD ]V}t|| jrjt|tre | }t|sdtd| n" | }nt|tttjfr|j}|rt fdd|D }|| }| j tjjkrt|tr|| qH|| qH| t|S )Nz%Cannot subscript already-subscripted c                 s       | ]}t |V  qd S r   rf   r   rd   rd   re   r     r  z,_GenericAlias.__getitem__.<locals>.<genexpr>c                 s       | ]}t |tV  qd S r   ra   r   r~   rd   rd   re   r     r   zFExpected a list of types, an ellipsis, ParamSpec, or Concatenate. Got c                 3   s    | ]} | V  qd S r   rd   )r   xsubstrd   re   r   2  r  )ri   r   r   rj   ra   rr   r  anyr   r   r   r   dictr   r   r
  r   ru   rh   r   rl   rm   collectionsabcr
   r   r   r   )r   r   new_argsrc   	subparamssubargsrd   rt  re   r     s>   



z_GenericAlias.__getitem__c                 C   s    | j | j|| j| j| j| jdS )Nr  rV  r
  r  )r>  ri   r   rW  r
  r  r   r   rd   rd   re   r   ;  s   z_GenericAlias.copy_withc                 C   sB   | j r	d| j  }nt| j}ddd | jD }| d| dS )Nr   , c                 S      g | ]}t |qS rd   r}   r   rd   rd   re   r   E      z*_GenericAlias.__repr__.<locals>.<listcomp>[])r   r}   ri   joinr   )r   r  r   rd   rd   re   r   @  s
   
z_GenericAlias.__repr__c                 C   sb   | j r
t | j  }n| j}t| j}t|dkr*t|d tr'|tu r*|d s*|\}tj	||ffS r   )
r   globalsri   rr   r   r   ra   r   r   r   )r   rD  r   rd   rd   re   r   H  s   
z_GenericAlias.__reduce__c                    s   t | jtrtd| | jrt |S | jtu r=t|v r!dS |	| }||d d  D ]}t |t
r<|| ur< dS q.| jfS )Nr   rd   r   )ra   ri   rk   rj   r   r9  r   r   r   rZ  rT  )r   r   r]  r^  r=  rd   re   r   S  s   

z_GenericAlias.__mro_entries__)r{   rx   ry   r   r   r  r   r   r   r   r   r   r   r   r   r?  rd   rd   r=  re   rh     s    
$rh   c                       sd   e Zd Zddd fdd
Zedd Zdd	 Zd
d Z fddZdd Z	dd Z
dd Z  ZS )_SpecialGenericAliasTNrU  c                   s`   |d u r|j }t j|||d || _|jdkr"d|j d| _d S d|j d|j d| _d S )NrU  rv   zA generic version of rg   )r{   r9  r   r`  rx   ry   r   )r   rD  ZnparamsrV  r  r=  rd   re   r   h  s   
z_SpecialGenericAlias.__init__c                    sB   t |ts|f}d t fdd|D }t| || j | |S )Nz*Parameters to generic types must be types.c                 3   r   r   r   r   r   rd   re   r   w  r   z3_SpecialGenericAlias.__getitem__.<locals>.<genexpr>)ra   rr   r   r`  r   r~  rd   r   re   r   r  s   

z _SpecialGenericAlias.__getitem__c                 C   s   t | j|| j| jdS )N)r  rV  )rh   ri   r   rW  r~  rd   rd   re   r   {  s   z_SpecialGenericAlias.copy_withc                 C   r   r   r   r   rd   rd   re   r     r   z_SpecialGenericAlias.__repr__c                    s:   t |trt|j| jS t |tst|| jS t |S r   )ra   r  r[  ri   rh   r9  r   r   r=  rd   re   r     s
   

z&_SpecialGenericAlias.__subclasscheck__c                 C   r   r   r   r   rd   rd   re   r     r   z_SpecialGenericAlias.__reduce__c                 C   r   r   r   r-  rd   rd   re   r     r   z_SpecialGenericAlias.__or__c                 C   r   r   r   r/  rd   rd   re   r     r   z_SpecialGenericAlias.__ror__)r{   rx   ry   r   r   r   r   r   r   r   r   r   r?  rd   rd   r=  re   r  g  s    

r  c                       s$   e Zd Z fddZdd Z  ZS )_CallableGenericAliasc                    sZ   | j }t|dkrt|d rt  S dddd |d d D  dt|d  d	S )
Nr  r   ztyping.Callable[[r  c                 S   r  rd   r  r   rd   rd   re   r     r  z2_CallableGenericAlias.__repr__.<locals>.<listcomp>r  z], r  )r   r   ru   r9  r   r  r}   r   r   r=  rd   re   r     s   

z_CallableGenericAlias.__repr__c                 C   sD   | j }t|dkrt|d st|d d |d f}tjt|ffS )Nr  r   r  )r   r   ru   rs   r   r   r
   r  rd   rd   re   r     s   z _CallableGenericAlias.__reduce__)r{   rx   ry   r   r   r?  rd   rd   r=  re   r    s    	r  c                   @   s(   e Zd Zdd Zdd Zedd ZdS )_CallableTypec                 C   s   t | j|| j| jttfddS )NTr}  )r  ri   r   rW  r   r   r~  rd   rd   re   r     s
   z_CallableType.copy_withc                 C   sP   t |trt|dkrtd|\}}t |trt||f}n||f}| |S )Nr  z6Callable must be used as Callable[[arg, ...], result].)ra   rr   r   rj   rs   __getitem_inner__)r   r   r   rY  rd   rd   re   r     s   

z_CallableType.__getitem__c                 C   sb   |\}}d}t ||}|tu r| t|fS t|ts|f}tdd |D }||f }| |S )Nz.Callable[args, result]: result must be a type.c                 s   ro  r   rp  )r   rc   rd   rd   re   r     r  z2_CallableType.__getitem_inner__.<locals>.<genexpr>)rq   Ellipsisr   rk  ra   rr   )r   r   r   rY  ro   rd   rd   re   r    s   



z_CallableType.__getitem_inner__N)r{   rx   ry   r   r   r   r  rd   rd   rd   re   r    s
    r  c                   @   s   e Zd Zedd ZdS )
_TupleTypec                    s   |dkr
|  tfS t|ts|f}t|dkr.|d du r.d t|d  }|  |tfS d t fdd	|D }|  |S )
Nrd   r  r   .z Tuple[t, ...]: t must be a type.r   z*Tuple[t0, t1, ...]: each t must be a type.c                 3   r   r   r   r   r   rd   re   r     r   z)_TupleType.__getitem__.<locals>.<genexpr>)r   rl  ra   rr   r   rq   rk  )r   r   r   rd   r   re   r     s   

z_TupleType.__getitem__N)r{   rx   ry   r   r   rd   rd   rd   re   r    s    r  c                       sP   e Zd Zdd Zdd Zdd Z fddZd	d
 Zdd Z fddZ	  Z
S )r   c                 C   s   t | S r   r   r~  rd   rd   re   r     rg  z_UnionGenericAlias.copy_withc                 C   s(   t |ttjfs
tS t| jt|jkS r   )ra   r   rl   rm   r  r   r   r   rd   rd   re   r    s   z_UnionGenericAlias.__eq__c                 C   s   t t| jS r   )r  	frozensetr   r   rd   rd   re   r     r   z_UnionGenericAlias.__hash__c                    sd   | j }t|dkr-|d td u rdt|d  dS |d td u r-dt|d  dS t  S )Nr  r   ztyping.Optional[r   r  )r   r   r`   r}   r9  r   r  r=  rd   re   r     s   
z_UnionGenericAlias.__repr__c                 C   rd  r   re  r   rd   rd   re   r     r   z$_UnionGenericAlias.__instancecheck__c                 C   s    | j D ]
}t||r dS qd S NT)r   r[  )r   r   rc   rd   rd   re   r     s
   

z$_UnionGenericAlias.__subclasscheck__c                    s   t   \}\}}|t|ffS r   )r9  r   r   )r   r   rD  r   r=  rd   re   r     s   z_UnionGenericAlias.__reduce__)r{   rx   ry   r   r  r   r   r   r   r   r?  rd   rd   r=  re   r     s    	r   c                 C   s   dd | D S )Nc                 s   s    | ]	}|t |fV  qd S r   )r`   r   rd   rd   re   r     s    z'_value_and_type_iter.<locals>.<genexpr>rd   )r   rd   rd   re   r    r   r  c                   @   s   e Zd Zdd Zdd ZdS )r   c                 C   s*   t |tstS tt| jtt|jkS r   )ra   r   r  r   r  r   r   rd   rd   re   r    s   
z_LiteralGenericAlias.__eq__c                 C   s   t tt| jS r   )r  r  r  r   r   rd   rd   re   r        z_LiteralGenericAlias.__hash__N)r{   rx   ry   r  r   rd   rd   rd   re   r     s    r   c                          e Zd Z fddZ  ZS )rt   c                    sz   t |d ttfrg |d d |d R S t |d tr,g |d d |d jR }nt |d ts7tdt |S )Nr  r  )	ra   rs   rr   rt   r   r   rj   r9  r   r~  r=  rd   re   r   	  s   z"_ConcatenateGenericAlias.copy_with)r{   rx   ry   r   r?  rd   rd   r=  re   rt     s    rt   c                       s2   e Zd Z	 dZdZedd Z fddZ  ZS )r   rd   Fc                 C   s   t |ts|f}|s| turtd| j dtdd |D }| ttfv rLtdd |D s8td| j dt	t
|t	|krKtd| j dntd	d | jD r\t| |}n	t| |t	| j t| |ttfd
dS )NzParameter list to z[...] cannot be emptyc                 s   ro  r   rp  r   rd   rd   re   r   2  r  z,Generic.__class_getitem__.<locals>.<genexpr>c                 s   s    | ]
}t |ttfV  qd S r   )ra   r   r   r   rd   rd   re   r   5  r   zParameters to zF[...] must all be type variables or parameter specification variables.z[...] must all be uniquec                 s   rq  r   rr  r~   rd   rd   re   r   >  r   Tr	  )ra   rr   r   rj   ry   r   r   allr{   r   r   rv  r   r   r   rh   r   r   )r   r   rd   rd   re   __class_getitem__+  s0   
zGeneric.__class_getitem__c           
         s  t  j|i | g }d| jv rt| jv }n
t| jv o| jdk}|r&tdd| jv rt| jt	t
f}d }| jD ]}t|trO|jtu rO|d urLtd|j}q8|d urt|}t| | ksd fdd|D }ddd |D }	td	| d
|	 d|}t|| _d S )N__orig_bases__r   z!Cannot inherit from plain Genericz0Cannot inherit from Generic[...] multiple types.r  c                 3   s     | ]}| vrt |V  qd S r   rb   r~   Zgvarsetrd   re   r   b      z,Generic.__init_subclass__.<locals>.<genexpr>c                 s   ro  r   r  )r   grd   rd   re   r   c  r  zSome type variables (z) are not listed in Generic[r  )r9  r   r  r   r  	__bases__r{   rj   r   r   r   ra   rh   ri   r   r   r  rr   )
r   r   rM  r   errorZgvarsbaseZtvarsetZs_varsZs_argsr=  r  re   r   F  s<   






zGeneric.__init_subclass__)	r{   rx   ry   r   _is_protocolr   r  r   r?  rd   rd   r=  re   r     s    
r   c                   @      e Zd ZdS )rl  Nr{   rx   ry   rd   rd   rd   re   rl  j      rl  c                   @   r  )rk  Nr  rd   rd   rd   re   rk  q  r  rk  )r   r  rX  r  _is_runtime_protocol)__abstractmethods____annotations__r  r   r   rx   __new__r   __subclasshook__r   r  _MutableMapping__markerc                 C   st   	 t  }| jd d D ],}|jdv rqt|di }t|j t|  D ]}|ds6|tvr6|	| q&q|S )Nr  )r   r   r  Z_abc_)
r   __mro__r{   r  rs   r  keysrP  EXCLUDED_ATTRIBUTESadd)r   Zattrsr  annotationsrR  rd   rd   re   _get_protocol_attrs  s   

r  c                    s   t  fddt D S )Nc                 3   s     | ]}t t |d V  qd S r   )rn   r  rh  r   rd   re   r     r  z,_is_callable_members_only.<locals>.<genexpr>)r  r  r  rd   r  re   _is_callable_members_only  s   r  c                 O   st   t | }|jrtd|jturd S |jD ]}|jdt}|tur'||_ nqtj|_|j| g|R i | d S )Nz Protocols cannot be instantiatedr   )	r`   r  rj   r   _no_init_or_replace_initr  r  r  object)r   r   rM  r   r  Zinitrd   rd   re   r    s   

r  r   r7  c              	   C   s4   zt | d jd|W S  ttfy   Y d S w )Nr   r{   )r  r:  r;  r  r   r%  )depthdefaultrd   rd   re   _caller  s
   r     c              	   C   s2   	 zt | jd dv W S  ttfy   Y dS w )Nr{   )ry  r   T)r  r:  r;  r   r%  r  rd   rd   re   _allow_reckless_class_checks  s   r  )
r
   r)   r   r   r+   r   r'   r   r-   r0   AbstractContextManagerAbstractAsyncContextManager)zcollections.abc
contextlibc                       r  )_ProtocolMetac                    s   t  ddrt  ddstddstdt  ddrt r'tj r'dS  jr:t fdd	t D r:dS t	 
S )
Nr  Fr  r  r  LInstance and class checks can only be used with @runtime_checkable protocolsTc                 3   s:    | ]}t |ott |d  pt|d uV  qd S r   )hasattrrn   r  rh  r   instancerd   re   r     s    

z2_ProtocolMeta.__instancecheck__.<locals>.<genexpr>)r  r  rj   r  r[  r>  r  r  r  r9  r   r  r=  r  re   r     s&   


z_ProtocolMeta.__instancecheck__)r{   rx   ry   r   r?  rd   rd   r=  re   r    s    r  c                       s*   e Zd Z	 dZdZdZ fddZ  ZS )r   rd   TFc                    s   t  j|i |  jddstdd  jD  _ fdd}d jvr)| _ js.d S  jD ]#}|tt	fv sT|j
tv rF|jt|j
 v sTt|t	rN|jsTtd| q1t _d S )	Nr  Fc                 s   s    | ]}|t u V  qd S r   )r   )r   r^  rd   rd   re   r     r  z-Protocol.__init_subclass__.<locals>.<genexpr>c                    s    j dds	tS t ddst rtS tdt s%t r!tS tdt| ts.tdt	 D ];}| j
D ]1}||j v rM|j | d u rKt    S  n t|di }t|tjjrh||v rht| trh| jrh nq7t  S q2dS )	Nr  Fr  r  z<Protocols with non-method members don't support issubclass()z"issubclass() arg 1 must be a classr  T)r  r  r  r  r  rj   r  ra   r`   r  r  rx  ry  r!   r[  r   r  )r   rR  r  r  r  rd   re   _proto_hook  s<   


z/Protocol.__init_subclass__.<locals>._proto_hookr  z7Protocols can only inherit from other protocols, got %r)r9  r   r  r  rv  r  r  r  r  r   rx   _PROTO_ALLOWLISTr{   r[  rj   r  r   )r   r   rM  r  r  r=  r  re   r     s*   
&


zProtocol.__init_subclass__)r{   rx   ry   r   r  r  r   r?  rd   rd   r=  re   r     s    r   )	metaclassc                       sR   e Zd Z	  fddZdd Zdd Zdd Zd	d
 Zdd Z fddZ	  Z
S )_AnnotatedAliasc                    s2   t |tr|j| }|j}t || || _d S r   )ra   r  __metadata__ri   r9  r   )r   rD  metadatar=  rd   re   r   U  s
   


z_AnnotatedAlias.__init__c                 C   s   |d }t || jS )Nr   )r  r  )r   r   Znew_typerd   rd   re   r   \  s   z_AnnotatedAlias.copy_withc                 C   s$   d t| jddd | jD S )Nztyping.Annotated[{}, {}]r  c                 s   ro  r   )rw   r   rd   rd   re   r   d  r  z+_AnnotatedAlias.__repr__.<locals>.<genexpr>)formatr}   ri   r  r  r   rd   rd   re   r   a  s   z_AnnotatedAlias.__repr__c                 C   s   t jt| jf| j ffS r   )r   r   r   ri   r  r   rd   rd   re   r   g  s   z_AnnotatedAlias.__reduce__c                 C   rm  r   )ra   r  r  ri   r  r   rd   rd   re   r  l  rn  z_AnnotatedAlias.__eq__c                 C   r  r   )r  ri   r  r   rd   rd   re   r   r  r!  z_AnnotatedAlias.__hash__c                    s   |dv rdS t  |S )N>   r{   ry   r   )r9  r   r_  r=  rd   re   r   u  s   z_AnnotatedAlias.__getattr__)r{   rx   ry   r   r   r   r   r  r   r   r?  rd   rd   r=  re   r  M  s    r  c                   @   s.   e Zd Z	 dZdd Zedd Zdd ZdS )	r   rd   c                 O   rf  )Nz&Type Annotated cannot be instantiated.r   r   r   rM  rd   rd   re   r    rg  zAnnotated.__new__c                 C   sN   t |trt|dk rtdd}t|d |dd}t|dd  }t||S )Nr  zUAnnotated[...] should be used with at least two arguments (a type and an annotation).z$Annotated[t, ...]: t must be a type.r   Tr\   r   )ra   rr   r   rj   rq   r  )r   r   ro   rD  r  rd   rd   re   r    s   
zAnnotated.__class_getitem__c                 O   s   t d| j)NzCannot subclass {}.Annotated)rj   r  rx   r  rd   rd   re   r     s   
zAnnotated.__init_subclass__N)r{   rx   ry   r   r  r   r  r   rd   rd   rd   re   r   {  s    

r   c                 C   s(   	 t | tr	| jstd|  d| _| S )NzB@runtime_checkable can be only applied to protocol classes, got %rT)r[  r   r  rj   r  r  rd   rd   re   rW     s   rW   c                 C   s   	 |S r   rd   )typrc  rd   rd   re   rJ     s   rJ   c           
      C   s   	 z| j }W n ty   i  Y S w |j}|j}|d | }| jp"d}| j}|r,t|ni }|t| }t||d  |D ]\}}	|	||< q=|S )Nrd   )	__code__r   co_argcountco_varnames__defaults____kwdefaults__rw  r   r   )
r   r  Z	pos_countZ	arg_namesdefaultsZ
kwdefaultsr\  Z
pos_offsetr  valuerd   rd   re   _get_defaults  s    


r  c                 C   sB  	 t | dd r	i S t| tri }t| jD ]d}|d u r(t tj|jd di }n|}|j	di }t|t
jr9i }|d u rCtt|n|}|d u rR|d u rR||}}| D ]"\}	}
|
d u rbtd }
t|
trnt|
ddd}
t|
||}
|
||	< qVq|r~|S dd | D S |d u rt| t
jr| j	}n| }t|d	r|j}t|d	st |d
i }|d u r|}n|d u r|}t | dd }|d u rt| tri S td| t| }t|}| D ]7\}	}
|
d u rtd }
t|
trt|
t| t
j dd}
t|
||}
|	|v r||	 d u rt|
 }
|
||	< q|r|S dd | D S )N__no_type_check__r  r  FT)rp   r_   c                 S      i | ]	\}}|t |qS rd   _strip_annotationsr   kr   rd   rd   re   
<dictcomp>+      z"get_type_hints.<locals>.<dictcomp>__wrapped____globals__z1{!r} is not a module, class, method, or function.c                 S   r  rd   r  r  rd   rd   re   r  S  r  )r  ra   r`   reversedr  r  r  r  rx   r  rl   GetSetDescriptorTyperw  varsitemsrb   r   r   
ModuleTyper  r  _allowed_typesrj   r  r  r   )r|   r   r   Zinclude_extrasZhintsr  Zbase_globalsannZbase_localsr  r  Znsobjr  rd   rd   re   rN     sx    








rN   c                 C   s   	 t | trt| jS t | tr&tdd | jD }|| jkr!| S | |S t | trBtdd | jD }|| jkr<| S t| j|S t | t	j
r`tdd | jD }|| jkrY| S ttj|S | S )Nc                 s   ro  r   r  r   rd   rd   re   r   \  r  z%_strip_annotations.<locals>.<genexpr>c                 s   ro  r   r  r   rd   rd   re   r   a  r  c                 s   ro  r   r  r   rd   rd   re   r   f  r  )ra   r  r  ri   rh   rr   r   r   r   rl   rm   r   r   r   r   )r   Zstripped_argsrd   rd   re   r  V  s&   







r  c                 C   sJ   	 t | trtS t | ttttfr| jS | tu rtS t | t	j
r#t	j
S d S r   )ra   r  r   rT  r   rU   rV   ri   r   rl   rm   tprd   rd   re   rM   n  s   
rM   c                 C   s   	 t | tr| jf| j S t | ttfr8| j}| jtjj	u r6t
|dkr*t|d s6t|d d |d f}|S t | tjrA| jS dS )Nr  r   r  rd   )ra   r  ri   r  rh   r   r   rx  ry  r
   r   ru   rs   rl   rm   )r  r\  rd   rd   re   rL     s   

rL   c                 C   s   	 t | tS r   )ra   _TypedDictMetar  rd   rd   re   rO     s   

rO   c                 C   s   	 t | tr;| j }| j D ]\}}|| j| f v r!|| q| D ]}t |tj	r1d|_
t |tr:t| q&zd| _
W | S  tyK   Y | S w r  )ra   r`   r  copyr  r  popvaluesrl   rz   r  rQ   rj   )rc   Z	arg_attrsrR  rc  r|   rd   rd   re   rQ     s(   



rQ   c                    s   	 t   fdd}|S )Nc                     s    | i |}t |}|S r   )rQ   )r   r   r   r   rd   re   wrapped_decorator  s   z2no_type_check_decorator.<locals>.wrapped_decorator)r   r   )r   r  rd   r  re   rR     s   rR   c                  O   s
   	 t d)NzYou should not call an overloaded function. A series of @overload-decorated functions outside a stub module should always be followed by an implementation that is not @overload-ed.)NotImplementedErrorr   rd   rd   re   _overload_dummy  s   r  c                 C   s   	 t S r   )r  )r   rd   rd   re   rT     s   rT   c                 C   s   	 | S r   rd   )frd   rd   re   rK     s   rK   TKTVTT_co)r+  V_coVT_coT_contra)r,  CT_co)r+  r*  rI   r  a  Callable type; Callable[[int], str] is a function of (int) -> str.

    The subscription syntax must always be used with exactly two
    values: the argument list and the return type.  The argument list
    must be a list of types or ellipsis; the return type must be a single type.

    There is no syntax to indicate optional or keyword arguments,
    such function types are rarely used as callback types.
    r   r  r  r   rU  a@  Tuple type; Tuple[X, Y] is the cross-product type of X and Y.

    Example: Tuple[T1, T2] is a tuple of two elements corresponding
    to type variables T1 and T2.  Tuple[int, float, str] is a tuple
    of an int, a float and a string.

    To specify a variable-length tuple of homogeneous type, use Tuple[T, ...].
    r=   r:   r?   r@   r   r/   r;   r<   r   a  A special construct usable to annotate class objects.

    For example, suppose we have the following classes::

      class User: ...  # Abstract base for User classes
      class BasicUser(User): ...
      class ProUser(User): ...
      class TeamUser(User): ...

    And a function that takes a class argument that's a subclass of
    User and returns an instance of the corresponding class::

      U = TypeVar('U', bound=User)
      def new_user(user_class: Type[U]) -> U:
          user = user_class()
          # (Here we could write the user object to a database)
          return user

      joe = new_user(BasicUser)

    At this point the type checker knows that joe has type BasicUser.
    c                   @   $   e Zd Z	 dZedefddZdS )r6   rd   returnc                 C      d S r   rd   r   rd   rd   re   __int__     zSupportsInt.__int__N)r{   rx   ry   r   r   intr  rd   rd   rd   re   r6     
    r6   c                   @   r  )r4   rd   r  c                 C   r  r   rd   r   rd   rd   re   	__float__  r  zSupportsFloat.__float__N)r{   rx   ry   r   r   floatr  rd   rd   rd   re   r4     r  r4   c                   @   r  )r3   rd   r  c                 C   r  r   rd   r   rd   rd   re   __complex__  r  zSupportsComplex.__complex__N)r{   rx   ry   r   r   complexr  rd   rd   rd   re   r3     r  r3   c                   @   r  )r2   rd   r  c                 C   r  r   rd   r   rd   rd   re   	__bytes__  r  zSupportsBytes.__bytes__N)r{   rx   ry   r   r   bytesr  rd   rd   rd   re   r2     r  r2   c                   @   r  )r5   rd   r  c                 C   r  r   rd   r   rd   rd   re   	__index__  r  zSupportsIndex.__index__N)r{   rx   ry   r   r   r  r   rd   rd   rd   re   r5     r  r5   c                   @   r  )r1   rd   r  c                 C   r  r   rd   r   rd   rd   re   __abs__  r  zSupportsAbs.__abs__N)r{   rx   ry   r   r   r  r  rd   rd   rd   re   r1     r  r1   c                   @   s*   e Zd Z	 dZeddedefddZdS )	r7   rd   r   ndigitsr  c                 C   r  r   rd   )r   r  rd   rd   re   	__round__  r  zSupportsRound.__round__Nr   )r{   rx   ry   r   r   r  r  r  rd   rd   rd   re   r7     s
    r7   rd   c                 C   s@   dd |D }dd |D }t j| |||d}| |_|j_|S )Nc                 S   s   g | ]\}}|qS rd   rd   r   nr   rd   rd   re   r     r  z!_make_nmtuple.<locals>.<listcomp>c                 S   s$   i | ]\}}|t |d | dqS )zfield z annotation must be a typer   r  rd   rd   re   r    s    z!_make_nmtuple.<locals>.<dictcomp>r  r^   )rx  
namedtupler  r  )r  rl   r^   r  fieldsnm_tplrd   rd   re   _make_nmtuple  s   r  >
   _field_defaults__getnewargs___asdict_fieldsr   _maker   Z_source_replacer  >   rx   r{   r  c                   @   r   )NamedTupleMetac           	   
      s     di }g }|D ]&}| v r|| q
|r0td| dt|dkr%dnd dd| q
t||  fd	d
|D  d d} D ]}|tv rRtd| |t	vrc||j
vrct|| |  qF|S )Nr  zNon-default namedtuple field z cannot follow default fieldr   s  r  c                    s   g | ]} | qS rd   rd   )r   r  nsrd   re   r     r  z*NamedTupleMeta.__new__.<locals>.<listcomp>rx   r  z&Cannot overwrite NamedTuple attribute )r  r   rj   r   r  r  r  _prohibitedr   _specialr  rb  )	r   typenamer   r  rl   Zdefault_names
field_namer
  keyrd   r  re   r    s.   

zNamedTupleMeta.__new__N)r{   rx   ry   r  rd   rd   rd   re   r    s    r  c             	   K   sb   	 |d u r
|  }n|rtdztdjdd}W n ttfy)   d }Y nw t| ||dS )NzIEither list of fields or keywords can be provided to NamedTuple, not bothr   r{   r7  r^   )	r  rj   r  r:  r;  r  r   r%  r  )r  r	  rM  r^   rd   rd   re   rA     s   
rA   c                 C   s   t | dkr
tdtfS )Nr   z5Multiple inheritance with NamedTuple is not supported)r   rj   _NamedTupler   rd   rd   re   _namedtuple_mro_entries	  s   r   c                   @   s&   e Zd ZdddZeZdd ZeZdS )r  Tc                    s  	 |D ]}t |turtdqt t|tf|i }|di }t| }d  fdd| D }t }	t }
|D ] }|	|j
di  |		|j
dd |
	|j
dd q=|	| |rk|		| n|
	| |_t|	_t|
_td	s|_S )
NzHcannot inherit from both a TypedDict type and a non-TypedDict base classr  z?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typec                    s"   i | ]\}}|t | jd qS )r  )rq   rx   )r   r  r  ro   Ztp_dictrd   re   r  4	  s    z*_TypedDictMeta.__new__.<locals>.<dictcomp>__required_keys__rd   __optional_keys__	__total__)r`   r  rj   r  rw  r  r   r  r  updater  r  r  r"  r#  r  r$  )r   r  r   r  totalr  r  Zown_annotationsZown_annotation_keysZrequired_keysZoptional_keysrd   r!  re   r  "	  s:   




z_TypedDictMeta.__new__c                 C   rf  )Nz4TypedDict does not support instance and class checksr   )r   r   rd   rd   re   r   O	  rL  z _TypedDictMeta.__subclasscheck__N)T)r{   rx   ry   r  rw  r   r   r   rd   rd   rd   re   r  !	  s
    
+r  r&  c            	   K   sl   	 |d u r|}n|rt ddt|i}ztdjdd|d< W n ttfy-   Y nw t| d||dS )	Nz@TypedDict takes either a dict or keyword arguments, but not bothr  r   r{   r7  rx   rd   r'  )	rj   rw  r  r:  r;  r  r   r%  r  )r  r	  r&  rM  r  rd   rd   re   rB   V	  s   )rB   c                 C   s   t fS r   )
_TypedDictr  rd   rd   re   <lambda>	  s    r)  c                   @   s>   e Zd Z	 dd Zdd Zdd Zdd Zd	d
 Zdd ZdS )rP   c                 C   sD   || _ d|v r|dd }|| _|| _t }|dkr || _d S d S )Nrg   r  r8  )ry   
rpartitionr{   Z__supertype__r  rx   )r   r  r  r<  rd   rd   re   r   	  s   
zNewType.__init__c                 C   s   | j  d| j S )Nrg   )rx   ry   r   rd   rd   re   r   	  r  zNewType.__repr__c                 C   s   |S r   rd   )r   rs  rd   rd   re   r   	  r   zNewType.__call__c                 C   r   r   )ry   r   rd   rd   re   r   	  r   zNewType.__reduce__c                 C   r   r   r   r   rd   rd   re   r   	  r   zNewType.__or__c                 C   r   r   r   r   rd   rd   re   r   	  r   zNewType.__ror__N)	r{   rx   ry   r   r   r   r   r   r   rd   rd   rd   re   rP   	  s    
rP   c                   @   s  e Zd Z	 dZeedefddZeedefddZed7dd	Z	eede
fd
dZedefddZed7ddZede
fddZed8dedefddZede
fddZed8dedefddZed8dedee fddZed9ded edefd!d"Zede
fd#d$Zedefd%d&Zed:d'edefd(d)Zede
fd*d+Zed,edefd-d.Zed/ee ddfd0d1Zed;d3d4Zed7d5d6ZdS )<rE   rd   r  c                 C   r  r   rd   r   rd   rd   re   mode	     zIO.modec                 C   r  r   rd   r   rd   rd   re   r  	  r,  zIO.nameNc                 C   r  r   rd   r   rd   rd   re   close	  r  zIO.closec                 C   r  r   rd   r   rd   rd   re   closed	  r,  z	IO.closedc                 C   r  r   rd   r   rd   rd   re   fileno	  r  z	IO.filenoc                 C   r  r   rd   r   rd   rd   re   flush	  r  zIO.flushc                 C   r  r   rd   r   rd   rd   re   isatty	  r  z	IO.isattyr  r  c                 C   r  r   rd   )r   r  rd   rd   re   read	  r  zIO.readc                 C   r  r   rd   r   rd   rd   re   readable	  r  zIO.readablelimitc                 C   r  r   rd   )r   r4  rd   rd   re   readline	  r  zIO.readlinehintc                 C   r  r   rd   )r   r6  rd   rd   re   	readlines
  r  zIO.readlinesr   offsetwhencec                 C   r  r   rd   )r   r8  r9  rd   rd   re   seek
  r  zIO.seekc                 C   r  r   rd   r   rd   rd   re   seekable

  r  zIO.seekablec                 C   r  r   rd   r   rd   rd   re   tell
  r  zIO.tellsizec                 C   r  r   rd   )r   r=  rd   rd   re   truncate
  r  zIO.truncatec                 C   r  r   rd   r   rd   rd   re   writable
  r  zIO.writabler  c                 C   r  r   rd   r   r  rd   rd   re   write
  r  zIO.writelinesc                 C   r  r   rd   )r   rB  rd   rd   re   
writelines
  r  zIO.writelines
IO[AnyStr]c                 C   r  r   rd   r   rd   rd   re   	__enter__"
  r  zIO.__enter__c                 C   r  r   rd   )r   r`   r  	tracebackrd   rd   re   __exit__&
  r  zIO.__exit__)r  N)r  r  r   )r  rD  )r{   rx   ry   r   rN  r   rb   r+  r  r-  r&  r.  r  r/  r0  r1  rI   r2  r3  r5  r=   r7  r:  r;  r<  r>  r?  rA  rC  rE  rG  rd   rd   rd   re   rE   	  s\    rE   c                   @   s>   e Zd Z	 dZedeeef defddZ	ed	ddZ
dS )
rD   rd   r  r  c                 C   r  r   rd   r@  rd   rd   re   rA  0
  r  zBinaryIO.writec                 C   r  r   rd   r   rd   rd   re   rE  4
  r  zBinaryIO.__enter__N)r  rD   )r{   rx   ry   r   r   r   r  	bytearrayr  rA  rE  rd   rd   rd   re   rD   +
  s    rD   c                   @   s   e Zd Z	 dZeedefddZeedefddZ	eede
e fddZeedefd	d
ZeedefddZedddZdS )rH   rd   r  c                 C   r  r   rd   r   rd   rd   re   buffer>
  r,  zTextIO.bufferc                 C   r  r   rd   r   rd   rd   re   encodingC
  r,  zTextIO.encodingc                 C   r  r   rd   r   rd   rd   re   errorsH
  r,  zTextIO.errorsc                 C   r  r   rd   r   rd   rd   re   line_bufferingM
  r,  zTextIO.line_bufferingc                 C   r  r   rd   r   rd   rd   re   newlinesR
  r,  zTextIO.newlinesc                 C   r  r   rd   r   rd   rd   re   rE  W
  r  zTextIO.__enter__N)r  rH   )r{   rx   ry   r   rN  r   rD   rI  rb   rJ  r   rK  r&  rL  r	   rM  rE  rd   rd   rd   re   rH   9
  s(    rH   c                   @   s"   e Zd Z	 g dZeZeZeZdS )io)rE   rH   rD   N)r{   rx   ry   __all__rE   rH   rD   rd   rd   rd   re   rN  \
  s    rN  z.ioc                   @   s   e Zd Z	 ddgZeZeZdS )rerG   rF   N)r{   rx   ry   rO  rG   rF   rd   rd   rd   re   rP  k
  s
    rP  z.rer   r#  )r   r7  )r  )NNF)rd   )ry  r   r   rx  collections.abcr  r   r   rP  Z	stdlib_rer  rl   r   r   r   r   rO  rf   rq   ru   r}   r   r   r   r   r   r   r   r   r  r   r   r   rk   r   r	   rS   r   r   r   r   r   rZ   r   r[   r   r$  r   rU   rV   r   rS  rT  rh   r  r  r  r  r   r  r   rt   r   rl  rk  Z_TYPING_INTERNALSZ_SPECIAL_NAMESr  r  r  r  r  r  r  r  r   r  r   rW   rJ   r  rz   BuiltinFunctionType
MethodTyper  r  rN   r  rM   rL   rO   rQ   rR   r  rT   rK   r  r  r  r  r  r  r  r`   r  r  rb   rI   Z_aliasr   r)   r,   r+   r*   r   r   r0   r'   r   r-   r
   r   r?   r   r%   r!   r#   r&   r$   r   rr   r   rs   r=   dequer:   r   r@   r"   r    r   r(   r  r   r  r/   rw  r;   defaultdictr<   r>   r9   r8   rC   r.   r   r6   r4   r3   r2   r5   r1   r7   r  r  r  r  rA   r  r  r   r   r  rB   r(  rP   rX   rY   rE   rD   rH   rN  r{   r  rG   rF   rd   rd   rd   re   <module>   s   g	"
	+




'
!


/@"ADMp+#"V

	b.5
i	
							
	
#59
.c#
	
