B
    `                @   sL  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 d dlZd dlmZm	Z	m
Z
mZ ejdd dkZerte ZZnd dlmZmZ dZyd dlmZmZmZ W n ek
r   dZY nX yd d	lmZ dZW n ek
r   dZY nX yd d
lmZ W n ek
r   dd ZY nX yd dlmZmZ W n2 ek
r^   G dd dZG dd dZY nX dd Zdd ZeedrejZndd Zeedrd dlmZ dZ ndZdZ ejdd dkrd dl!Z!e!j"Z#ndd Z#ddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1gZ$epeZ%er*e$&d2d3d4g e%r:e$'d5 ejdd d6kZ(e(rbe$&d7d8d9g eed:rvej)Z)nXeed;rG d<d= d=ej*dd>Z+e+dd>Z)n*G d?d@ d@ejZ,G dAd: d:ej-e,ddBZ)e
dCZ.e
dDZ/e
dEZ0ej
dFddGZ1ej
dHddGZ2ej
dIddGZ3ej
dJddKZ4eedr8ej5Z5nXeed;rfG dLdM dMej*dd>Z6e6dd>Z5n*G dNdO dOejZ7G dPd dej-e7ddBZ5eed rejdd dQkrej-Z-nejdd dQkrG dRdS dSej8dd>Z9e9d dTdUZ-nXeed;rG dVdW dWej*dd>Z:e:dd>Z-n*G dXdY dYejZ;G dZd  d ej-e;ddBZ-eed)r\ej<Z<nd[d) Z<d\d* Z=eed+rej>Z>nejdd dQkrG d]d^ d^ej8dd>Z?e?d+d_dUZ>nXeed;rG d`da daej*dd>Z@e@dd>Z>n*G dbdc dcejZAG ddd+ d+ej-eAddBZ>dedf ZBdgd- ZCeed"r4ejDZDn*ej
dhdediZEG djd" d"ejeE edkZDdldm ZFG dndo doeZGeFdprG dqdp dpeje1 eGejHdrZHeFdsrG dtds dseHe2 eje1e4e2f eGejIdrZIeFdurG dvdu dueje1 eGejJdrZJeFdwr G dxdw dweJe1 eGejKdrZKeed%r4ejLZLnLe r^G dyd% d%ejMejNe. eGejMdrZLn"G dzd% d%ejMejNe. eGejMdrZLeed#rejOZOnBeed{rG d|d# d#eje1 eGejPdrZOnG d}d# d#eje1 ZOeed~rejQZQe$'d~ nReedr*G dd~ d~eje1 eGejRdrZQe$'d~ nejdd dkrFeSd eed&rZejTZTnTe rG dd& d&ejUejVe/e0f eGejUdrZTn&G dd& d&ejUejVe/e0f eGejUdrZTeedrejWZWndejdd   krdk rn neXejWe/e0fZWnTe r*G dd dejWejVe/e0f eGejWdrZWn&G dd dejWejVe/e0f eGejWdrZWeed$rdejYZYnd6ejdd   krdkrn nNe stZe
dZ[G dd dejZ\G dd$ d$ejYej]e.e^f e\ejYdrZYnTe 	rG dd$ d$ejYej]e.e^f eGejYdrZYn&G dd$ d$ejYej]e.e^f eGejYdrZYeed	rJej_Z_e$'d njeed	re 	rG dd dej_ejVe/e0f eGej_drZ_n&G dd dej_ejVe/e0f eGej_drZ_e$'d eFd	rG dd deKe1 eje1e4f eGej`drZ`eed,	rejaZandd, Zaeed.
rejbZbnecZbeed1
r.ejdZdndZddd Zee
rHdd Zddpdddudwdddddd#d~gZfdd Zgdd Zheed7
rejiZine(
re
sdd ZjG dd deZkG dd7 d7ekdZieijldk	r.eijljme
rdnddei_lnFer.d dlmZmnZnmoZo dd ZjG dd de jpZkG dd7 d7ekdZieed9rBejqZqne(rPdd9 Zqe(rZeqZreed(rnejsZsne(reqG dd( d(eiZsejdkrejtZtnTdd Zudd Zvdev_wddddZxdex_wG dd deZyeydezfi Zte{et_|det_leed5rej}Z}ej~Z~ejZnperNG ddĄ dejndd>ZG dd5 d5Z}ddǄ Zddd4Z~n2e%rddʄ ZG dd̄ dejZG dd5 d5edZ}ejdd dkrejZejZnzerd dlmnZn yd dlmZ W n ek
r   enZY nX yd dlmZ W n ek
r
   enZY nX dd3 Zdd2 Zeed/r0ejZnejdd dkrhG ddք dej8dd>Zedd/ Znejdd dQkrG ddք dej8dd>Zed/ddUZnheed;rG ddۄ dejZG dd݄ dej*eddBZedd>Zn&G ddۄ dejZG dd/ d/eddBZeedr"ejZejZn.G dd dZG dd deZG dd deZeed!rdejZnG dd! d!eZG dd deZedd ZeedrejZejZnejdd dkredd Znejdd dQkrG dd dej8dd>ZedddUZnheed;rFG dd dejZG dd dej*eddBZedd>Zn&G dd dejZG dd deddBZeed0rejZnejdd dkrG dd dej8dd>Zedd0 Znejdd dQkrG dd dej8dd>Zed0ddUZnXeed;rG dd dej*dd>Zedd>Zn*G dd dejZG dd0 d0ej-eddBZdS (       N)GenericCallableTypeVarTuple   )r      r   )GenericMeta
TypingMetaF)
_type_vars_next_in_mro_type_checkT)
_subs_tree)	_tp_cachec             C   s   | S )N )xr   r   Y/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/typing_extensions.pyr   $   s    r   )_TypingEllipsis_TypingEmptyc               @   s   e Zd ZdS )r   N)__name__
__module____qualname__r   r   r   r   r   )   s   r   c               @   s   e Zd ZdS )r   N)r   r   r   r   r   r   r   r   ,   s   r   c             C   s2   t | }d|kr.x|d D ]}||d  qW |S )N	__slots__)dictpop)dctZ	dict_copyZslotr   r   r   _no_slots_copy4   s
    r   c             C   sX   | j stdt|  t|}t| j }||krTtd||kr@dndt| ||f d S )Nz%s is not a generic classz0Too %s parameters for %s; actual %s, expected %smanyfew)__parameters__	TypeErrorreprlen)cls
parametersalenelenr   r   r   _check_generic<   s    
r&   _generic_newc             O   s   | j |f||S )N)__new__)Zbase_clsr"   argskwargsr   r   r   r'   V   s    _geqv)r+      )r      c             G   sH   | j }x<|D ]4}x.|D ]"}||jkr|j| d kr6tS P qW tS qW dS )NT)__mro____dict__NotImplemented)CmethodsmromethodBr   r   r   _check_methods_in_mroe   s    


r6   ClassVarConcatenateFinal	ParamSpecTypeContextManagerCounterDequeDefaultDictZOrderedDictTypedDictSupportsIndexfinalIntVarLiteralNewTypeoverloadText	TypeAlias	TypeGuardTYPE_CHECKINGget_args
get_originget_type_hints	Annotated)r      r   Protocolruntimeruntime_checkableNoReturn_FinalTypingBasec               @   s$   e Zd ZdZdZdd Zdd ZdS )	_NoReturna7  Special type indicating functions that never return.
        Example::

          from typing import NoReturn

          def stop() -> NoReturn:
              raise Exception('no way')

        This type is invalid in other positions, e.g., ``List[NoReturn]``
        will fail in static type checkers.
        r   c             C   s   t dd S )Nz*NoReturn cannot be used with isinstance().)r   )selfobjr   r   r   __instancecheck__   s    z_NoReturn.__instancecheck__c             C   s   t dd S )Nz*NoReturn cannot be used with issubclass().)r   )rU   r"   r   r   r   __subclasscheck__   s    z_NoReturn.__subclasscheck__N)r   r   r   __doc__r   rW   rX   r   r   r   r   rT      s   rT   )_rootc                   s2   e Zd ZdZd	 fdd	Zdd Zdd Z  ZS )
_NoReturnMetazMetaclass for NoReturnFc                s   t  j| ||||dS )N)rZ   )superr(   )r"   namebases	namespacerZ   )	__class__r   r   r(      s    z_NoReturnMeta.__new__c             C   s   t dd S )Nz*NoReturn cannot be used with isinstance().)r   )rU   rV   r   r   r   rW      s    z_NoReturnMeta.__instancecheck__c             C   s   t dd S )Nz*NoReturn cannot be used with issubclass().)r   )rU   r"   r   r   r   rX      s    z_NoReturnMeta.__subclasscheck__)F)r   r   r   rY   r(   rW   rX   __classcell__r   r   )r`   r   r[      s   r[   c               @   s   e Zd ZdZdZdS )rR   a7  Special type indicating functions that never return.
        Example::

          from typing import NoReturn

          def stop() -> NoReturn:
              raise Exception('no way')

        This type is invalid in other positions, e.g., ``List[NoReturn]``
        will fail in static type checkers.
        r   N)r   r   r   rY   r   r   r   r   r   rR      s   )	metaclassrZ   TKTVTT_co)	covariantV_coVT_coT_contra)contravariantc                   sN   e Zd ZdZdZdddZdd Zdd	 Z fd
dZdd Z	dd Z
  ZS )	_ClassVara[  Special type construct to mark class variables.

        An annotation wrapped in ClassVar indicates that a given
        attribute is intended to be used as a class variable and
        should not be set on instances of that class. Usage::

          class Starship:
              stats: ClassVar[Dict[str, int]] = {} # class variable
              damage: int = 10                     # instance variable

        ClassVar accepts only types and cannot be further subscribed.

        Note that ClassVar is not a class itself, and should not
        be used with isinstance() or issubclass().
        )__type__Nc             K   s
   || _ d S )N)rm   )rU   tpkwdsr   r   r   __init__  s    z_ClassVar.__init__c          	   C   sR   t | }| jd kr6|t|d|jdd  ddS td|jdd  d S )Nz{} accepts only single type.   T)rZ   z {} cannot be further subscripted)typerm   typingr   formatr   r   )rU   itemr"   r   r   r   __getitem__  s    
z_ClassVar.__getitem__c             C   s.   t | j||}|| jkr| S t| |ddS )NT)rZ   )rs   
_eval_typerm   rr   )rU   globalnslocalnsnew_tpr   r   r   rw     s    
z_ClassVar._eval_typec                s.   t   }| jd k	r*|dt| j7 }|S )Nz[{}])r\   __repr__rm   rt   rs   
_type_repr)rU   r)r`   r   r   r{     s    

z_ClassVar.__repr__c             C   s   t t| j| jfS )N)hashrr   r   rm   )rU   r   r   r   __hash__  s    z_ClassVar.__hash__c             C   s,   t |tstS | jd k	r$| j|jkS | |kS )N)
isinstancerl   r0   rm   )rU   otherr   r   r   __eq__  s
    

z_ClassVar.__eq__)N)r   r   r   rY   r   rp   rv   rw   r{   r   r   ra   r   r   )r`   r   rl      s   
	rl   c                   s^   e Zd ZdZd fdd	Zdd Zdd	 Zd
d Zdd Z fddZ	dd Z
dd Z  ZS )_ClassVarMetazMetaclass for ClassVarNFc                s(   t  j| ||||d}|d k	r$||_|S )N)rZ   )r\   r(   rm   )r"   r]   r^   r_   rn   rZ   rU   )r`   r   r   r(   *  s    z_ClassVarMeta.__new__c             C   s   t dd S )Nz*ClassVar cannot be used with isinstance().)r   )rU   rV   r   r   r   rW   0  s    z_ClassVarMeta.__instancecheck__c             C   s   t dd S )Nz*ClassVar cannot be used with issubclass().)r   )rU   r"   r   r   r   rX   3  s    z_ClassVarMeta.__subclasscheck__c             C   sb   t | }| jd k	r*td|jdd  t|d|jdd  }|| j| jt| j	|ddS )Nz {} cannot be further subscriptedrq   z{} accepts only single type.T)rn   rZ   )
rr   rm   r   rt   r   rs   r   	__bases__r   r/   )rU   ru   r"   paramr   r   r   rv   6  s    

z_ClassVarMeta.__getitem__c             C   s@   t | j||}|| jkr| S t| | j| jt| j| jddS )NT)rn   rZ   )rs   rw   rm   rr   r   r   r   r/   )rU   rx   ry   rz   r   r   r   rw   B  s    
z_ClassVarMeta._eval_typec                s.   t   }| jd k	r*|dt| j7 }|S )Nz[{}])r\   r{   rm   rt   rs   r|   )rU   r}   )r`   r   r   r{   J  s    

z_ClassVarMeta.__repr__c             C   s   t t| j| jfS )N)r~   rr   r   rm   )rU   r   r   r   r   P  s    z_ClassVarMeta.__hash__c             C   s,   t |tstS | jd k	r$| j|jkS | |kS )N)r   r7   r0   rm   )rU   r   r   r   r   r   S  s
    

z_ClassVarMeta.__eq__)NF)r   r   r   rY   r(   rW   rX   rv   rw   r{   r   r   ra   r   r   )r`   r   r   '  s   r   c               @   s   e Zd ZdZdZdS )r7   a[  Special type construct to mark class variables.

        An annotation wrapped in ClassVar indicates that a given
        attribute is intended to be used as a class variable and
        should not be set on instances of that class. Usage::

          class Starship:
              stats: ClassVar[Dict[str, int]] = {} # class variable
              damage: int = 10                     # instance variable

        ClassVar accepts only types and cannot be further subscribed.

        Note that ClassVar is not a class itself, and should not
        be used with isinstance() or issubclass().
        N)r   r   r   rY   rm   r   r   r   r   r7   Z  s   )r   r   c               @   s   e Zd Zdd Zdd ZdS )
_FinalFormc             C   s
   d| j  S )Nztyping_extensions.)_name)rU   r   r   r   r{   s  s    z_FinalForm.__repr__c             C   s    t |d| j}t| |fS )Nz{} accepts only single type)rs   r   rt   r   _GenericAlias)rU   r#   ru   r   r   r   rv   v  s    z_FinalForm.__getitem__N)r   r   r   r{   rv   r   r   r   r   r   q  s   r   aW  A special typing construct to indicate that a name
                       cannot be re-assigned or overridden in a subclass.
                       For example:

                           MAX_SIZE: Final = 9000
                           MAX_SIZE += 1  # Error reported by type checker

                           class Connection:
                               TIMEOUT: Final[int] = 10
                           class FastConnector(Connection):
                               TIMEOUT = 1  # Error reported by type checker

                       There is no runtime checking of these properties.)docc                   sN   e Zd ZdZdZdddZdd Zdd	 Z fd
dZdd Z	dd Z
  ZS )_Finala  A special typing construct to indicate that a name
        cannot be re-assigned or overridden in a subclass.
        For example:

            MAX_SIZE: Final = 9000
            MAX_SIZE += 1  # Error reported by type checker

            class Connection:
                TIMEOUT: Final[int] = 10
            class FastConnector(Connection):
                TIMEOUT = 1  # Error reported by type checker

        There is no runtime checking of these properties.
        )rm   Nc             K   s
   || _ d S )N)rm   )rU   rn   ro   r   r   r   rp     s    z_Final.__init__c          	   C   sR   t | }| jd kr6|t|d|jdd  ddS td|jdd  d S )Nz{} accepts only single type.rq   T)rZ   z {} cannot be further subscripted)rr   rm   rs   r   rt   r   r   )rU   ru   r"   r   r   r   rv     s    
z_Final.__getitem__c             C   s.   t | j||}|| jkr| S t| |ddS )NT)rZ   )rs   rw   rm   rr   )rU   rx   ry   rz   r   r   r   rw     s    
z_Final._eval_typec                s.   t   }| jd k	r*|dt| j7 }|S )Nz[{}])r\   r{   rm   rt   rs   r|   )rU   r}   )r`   r   r   r{     s    

z_Final.__repr__c             C   s   t t| j| jfS )N)r~   rr   r   rm   )rU   r   r   r   r     s    z_Final.__hash__c             C   s,   t |tstS | jd k	r$| j|jkS | |kS )N)r   r   r0   rm   )rU   r   r   r   r   r     s
    

z_Final.__eq__)N)r   r   r   rY   r   rp   rv   rw   r{   r   r   ra   r   r   )r`   r   r     s   
	r   c                   s^   e Zd ZdZd fdd	Zdd Zdd	 Zd
d Zdd Z fddZ	dd Z
dd Z  ZS )
_FinalMetazMetaclass for FinalNFc                s(   t  j| ||||d}|d k	r$||_|S )N)rZ   )r\   r(   rm   )r"   r]   r^   r_   rn   rZ   rU   )r`   r   r   r(     s    z_FinalMeta.__new__c             C   s   t dd S )Nz'Final cannot be used with isinstance().)r   )rU   rV   r   r   r   rW     s    z_FinalMeta.__instancecheck__c             C   s   t dd S )Nz'Final cannot be used with issubclass().)r   )rU   r"   r   r   r   rX     s    z_FinalMeta.__subclasscheck__c             C   sb   t | }| jd k	r*td|jdd  t|d|jdd  }|| j| jt| j	|ddS )Nz {} cannot be further subscriptedrq   z{} accepts only single type.T)rn   rZ   )
rr   rm   r   rt   r   rs   r   r   r   r/   )rU   ru   r"   r   r   r   r   rv     s    

z_FinalMeta.__getitem__c             C   s@   t | j||}|| jkr| S t| | j| jt| j| jddS )NT)rn   rZ   )rs   rw   rm   rr   r   r   r   r/   )rU   rx   ry   rz   r   r   r   rw     s    
z_FinalMeta._eval_typec                s.   t   }| jd k	r*|dt| j7 }|S )Nz[{}])r\   r{   rm   rt   rs   r|   )rU   r}   )r`   r   r   r{     s    

z_FinalMeta.__repr__c             C   s   t t| j| jfS )N)r~   rr   r   rm   )rU   r   r   r   r     s    z_FinalMeta.__hash__c             C   s,   t |tstS | jd k	r$| j|jkS | |kS )N)r   r9   r0   rm   )rU   r   r   r   r   r     s
    

z_FinalMeta.__eq__)NF)r   r   r   rY   r(   rW   rX   rv   rw   r{   r   r   ra   r   r   )r`   r   r     s   r   c               @   s   e Zd ZdZdZdS )r9   a  A special typing construct to indicate that a name
        cannot be re-assigned or overridden in a subclass.
        For example:

            MAX_SIZE: Final = 9000
            MAX_SIZE += 1  # Error reported by type checker

            class Connection:
                TIMEOUT: Final[int] = 10
            class FastConnector(Connection):
                TIMEOUT = 1  # Error reported by type checker

        There is no runtime checking of these properties.
        N)r   r   r   rY   rm   r   r   r   r   r9     s   c             C   s   | S )au  This decorator can be used to indicate to type checkers that
        the decorated method cannot be overridden, and decorated class
        cannot be subclassed. For example:

            class Base:
                @final
                def done(self) -> None:
                    ...
            class Sub(Base):
                def done(self) -> None:  # Error reported by type checker
                    ...
            @final
            class Leaf:
                ...
            class Other(Leaf):  # Error reported by type checker
                ...

        There is no runtime checking of these properties.
        r   )fr   r   r   rA   	  s    c             C   s   t | S )N)r   )r]   r   r   r   rB      s    c               @   s   e Zd Zdd Zdd ZdS )_LiteralFormc             C   s
   d| j  S )Nztyping_extensions.)r   )rU   r   r   r   r{   )  s    z_LiteralForm.__repr__c             C   s
   t | |S )N)r   )rU   r#   r   r   r   rv   ,  s    z_LiteralForm.__getitem__N)r   r   r   r{   rv   r   r   r   r   r   '  s   r   ao  A type that can be used to indicate to type checkers
                           that the corresponding value has a value literally equivalent
                           to the provided parameter. For example:

                               var: Literal[4] = 4

                           The type checker understands that 'var' is literally equal to
                           the value 4 and no other value.

                           Literal[...] cannot be subclassed. There is no runtime
                           checking verifying that the parameter is actually a value
                           instead of a type.c                   sN   e Zd ZdZdZdddZdd Zdd	 Z fd
dZdd Z	dd Z
  ZS )_Literala  A type that can be used to indicate to type checkers that the
        corresponding value has a value literally equivalent to the
        provided parameter. For example:

            var: Literal[4] = 4

        The type checker understands that 'var' is literally equal to the
        value 4 and no other value.

        Literal[...] cannot be subclassed. There is no runtime checking
        verifying that the parameter is actually a value instead of a type.
        )
__values__Nc             K   s
   || _ d S )N)r   )rU   valuesro   r   r   r   rp   M  s    z_Literal.__init__c             C   sJ   t | }| jd kr.t|ts"|f}||ddS td|jdd  d S )NT)rZ   z {} cannot be further subscriptedrq   )rr   r   r   tupler   rt   r   )rU   r   r"   r   r   r   rv   P  s    

z_Literal.__getitem__c             C   s   | S )Nr   )rU   rx   ry   r   r   r   rw   Y  s    z_Literal._eval_typec                s6   t   }| jd k	r2|ddttj| j7 }|S )Nz[{}]z, )r\   r{   r   rt   joinmaprs   r|   )rU   r}   )r`   r   r   r{   \  s    

z_Literal.__repr__c             C   s   t t| j| jfS )N)r~   rr   r   r   )rU   r   r   r   r   b  s    z_Literal.__hash__c             C   s,   t |tstS | jd k	r$| j|jkS | |kS )N)r   r   r0   r   )rU   r   r   r   r   r   e  s
    

z_Literal.__eq__)N)r   r   r   rY   r   rp   rv   rw   r{   r   r   ra   r   r   )r`   r   r   =  s   
	r   c                   s^   e Zd ZdZd fdd	Zdd Zdd	 Zd
d Zdd Z fddZ	dd Z
dd Z  ZS )_LiteralMetazMetaclass for LiteralNFc                s(   t  j| ||||d}|d k	r$||_|S )N)rZ   )r\   r(   r   )r"   r]   r^   r_   r   rZ   rU   )r`   r   r   r(   q  s    z_LiteralMeta.__new__c             C   s   t dd S )Nz)Literal cannot be used with isinstance().)r   )rU   rV   r   r   r   rW   w  s    z_LiteralMeta.__instancecheck__c             C   s   t dd S )Nz)Literal cannot be used with issubclass().)r   )rU   r"   r   r   r   rX   z  s    z_LiteralMeta.__subclasscheck__c             C   sV   t | }| jd k	r*td|jdd  t|ts:|f}|| j| jt| j	|ddS )Nz {} cannot be further subscriptedrq   T)r   rZ   )
rr   r   r   rt   r   r   r   r   r   r/   )rU   ru   r"   r   r   r   rv   }  s    


z_LiteralMeta.__getitem__c             C   s   | S )Nr   )rU   rx   ry   r   r   r   rw     s    z_LiteralMeta._eval_typec                s6   t   }| jd k	r2|ddttj| j7 }|S )Nz[{}]z, )r\   r{   r   rt   r   r   rs   r|   )rU   r}   )r`   r   r   r{     s    

z_LiteralMeta.__repr__c             C   s   t t| j| jfS )N)r~   rr   r   r   )rU   r   r   r   r     s    z_LiteralMeta.__hash__c             C   s,   t |tstS | jd k	r$| j|jkS | |kS )N)r   rC   r0   r   )rU   r   r   r   r   r     s
    

z_LiteralMeta.__eq__)NF)r   r   r   rY   r(   rW   rX   rv   rw   r{   r   r   ra   r   r   )r`   r   r   n  s   r   c               @   s   e Zd ZdZdZdS )rC   a  A type that can be used to indicate to type checkers that the
        corresponding value has a value literally equivalent to the
        provided parameter. For example:

            var: Literal[4] = 4

        The type checker understands that 'var' is literally equal to the
        value 4 and no other value.

        Literal[...] cannot be subclassed. There is no runtime checking
        verifying that the parameter is actually a value instead of a type.
        N)r   r   r   rY   r   r   r   r   r   rC     s   c              O   s   t ddS )z*Helper for @overload to raise when called.zYou 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.N)NotImplementedError)r)   ro   r   r   r   _overload_dummy  s    r   c             C   s   t S )a
  Decorator for overloaded functions/methods.

    In a stub file, place two or more stub definitions for the same
    function in a row, each decorated with @overload.  For example:

      @overload
      def utf8(value: None) -> None: ...
      @overload
      def utf8(value: bytes) -> bytes: ...
      @overload
      def utf8(value: str) -> bytes: ...

    In a non-stub file (i.e. a regular .py file), do the same but
    follow it with an implementation.  The implementation should *not*
    be decorated with @overload.  For example:

      @overload
      def utf8(value: None) -> None: ...
      @overload
      def utf8(value: bytes) -> bytes: ...
      @overload
      def utf8(value: str) -> bytes: ...
      def utf8(value):
          # implementation goes here
    )r   )funcr   r   r   rE     s    CT_co)rg   boundc               @   s   e Zd ZdZdZdS )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.
        r   N)r   r   r   rY   r   r   r   r   r   r;     s   )extrac             C   sH   t t| r(t|  tt| t | < dS t t| r@t|  dS dS dS )z
    Returns True if the given type isn't defined in typing but
    is defined in collections_abc.

    Adds the type to __all__ if the collection is found in either
    typing or collection_abc.
    FTN)hasattrrs   __all__appendgetattrglobalscollections_abc)	type_namer   r   r   _define_guard  s    



r   c                   s   e Zd Z fddZ  ZS )_ExtensionsGenericMetac                s   t jdd dks$t jdd dk rN| jdk	rNt djd dkrJtdd	S | js`t |S | j	|}|t
k	rx|S | j|jkrd
S x,| j D ]}t|trqt||rd
S qW d	S )a*  This mimics a more modern GenericMeta.__subclasscheck__() logic
        (that does not have problems with recursion) to work around interactions
        between collections, typing, and typing_extensions on older
        versions of Python, see https://github.com/python/typing/issues/501.
        Nr   )r   rN   r   )r   rN   r   rq   r   )abc	functoolszCParameterized generics cannot be used with class or instance checksFT)sysversion_info
__origin__	_getframe	f_globalsr   	__extra__r\   rX   __subclasshook__r0   r.   __subclasses__r   r   
issubclass)rU   subclassresZscls)r`   r   r   rX   
  s$    $


z(_ExtensionsGenericMeta.__subclasscheck__)r   r   r   rX   ra   r   r   )r`   r   r   	  s   r   	Awaitablec               @   s   e Zd ZdZdS )r   r   N)r   r   r   r   r   r   r   r   r   &  s   )rb   r   	Coroutinec               @   s   e Zd ZdZdS )r   r   N)r   r   r   r   r   r   r   r   r   ,  s   AsyncIterablec               @   s   e Zd ZdZdS )r   r   N)r   r   r   r   r   r   r   r   r   3  s   AsyncIteratorc               @   s   e Zd ZdZdS )r   r   N)r   r   r   r   r   r   r   r   r   :  s   c               @   s   e Zd ZdZdd ZdS )r>   r   c             O   s*   t | trtj||S ttj| f||S )N)r+   r>   collectionsdequer'   )r"   r)   ro   r   r   r   r(   H  s    
zDeque.__new__N)r   r   r   r   r(   r   r   r   r   r>   C  s   c               @   s   e Zd ZdZdd ZdS )r>   r   c             O   s*   | j tkrtj||S ttj| f||S )N)_gorgr>   r   r   r'   )r"   r)   ro   r   r   r   r(   R  s    
zDeque.__new__N)r   r   r   r   r(   r   r   r   r   r>   M  s   AbstractContextManagerc               @   s   e Zd ZdZdS )r<   r   N)r   r   r   r   r   r   r   r   r<   [  s   c               @   s2   e Zd ZdZdd Zejdd Zedd Z	dS )	r<   r   c             C   s   | S )Nr   )rU   r   r   r   	__enter__c  s    zContextManager.__enter__c             C   s   d S )Nr   )rU   exc_type	exc_value	tracebackr   r   r   __exit__f  s    zContextManager.__exit__c             C   s8   | t kr4tdd |jD r4tdd |jD r4dS tS )Nc             s   s   | ]}d |j kV  qdS )r   N)r/   ).0r5   r   r   r   	<genexpr>r  s    z2ContextManager.__subclasshook__.<locals>.<genexpr>c             s   s   | ]}d |j kV  qdS )r   N)r/   )r   r5   r   r   r   r   s  s    T)r<   anyr.   r0   )r"   r1   r   r   r   r   j  s
    zContextManager.__subclasshook__N)
r   r   r   r   r   r   abstractmethodr   classmethodr   r   r   r   r   r<   `  s   AsyncContextManagerAbstractAsyncContextManagerc               @   s   e Zd ZdZdS )r   r   N)r   r   r   r   r   r   r   r   r   |  s   )r   rN   a  
class AsyncContextManager(typing.Generic[T_co]):
    __slots__ = ()

    async def __aenter__(self):
        return self

    @abc.abstractmethod
    async def __aexit__(self, exc_type, exc_value, traceback):
        return None

    @classmethod
    def __subclasshook__(cls, C):
        if cls is AsyncContextManager:
            return _check_methods_in_mro(C, "__aenter__", "__aexit__")
        return NotImplemented

__all__.append('AsyncContextManager')
c               @   s   e Zd ZdZdd ZdS )r?   r   c             O   s*   t | trtj||S ttj| f||S )N)r+   r?   r   defaultdictr'   )r"   r)   ro   r   r   r   r(     s    
zDefaultDict.__new__N)r   r   r   r   r(   r   r   r   r   r?     s   c               @   s   e Zd ZdZdd ZdS )r?   r   c             O   s*   | j tkrtj||S ttj| f||S )N)r   r?   r   r   r'   )r"   r)   ro   r   r   r   r(     s    
zDefaultDict.__new__N)r   r   r   r   r(   r   r   r   r   r?     s   OrderedDict)r   r   r,   c               @   s   e Zd ZdZdd ZdS )r   r   c             O   s*   t | trtj||S ttj| f||S )N)r+   r   r   r'   )r"   r)   ro   r   r   r   r(     s    
zOrderedDict.__new__N)r   r   r   r   r(   r   r   r   r   r     s   c               @   s   e Zd ZdZdd ZdS )r   r   c             O   s*   | j tkrtj||S ttj| f||S )N)r   r   r   r'   )r"   r)   ro   r   r   r   r(     s    
zOrderedDict.__new__N)r   r   r   r   r(   r   r   r   r   r     s   )r   rN   rq   _TIntc                   s    e Zd ZdZ fddZ  ZS )_CounterMetazMetaclass for Counterc                s   t  |tfS )N)r\   rv   int)rU   ru   )r`   r   r   rv     s    z_CounterMeta.__getitem__)r   r   r   rY   rv   ra   r   r   )r`   r   r     s   r   c               @   s   e Zd ZdZdd ZdS )r=   r   c             O   s*   t | trtj||S ttj| f||S )N)r+   r=   r   r'   )r"   r)   ro   r   r   r   r(     s    
zCounter.__new__N)r   r   r   r   r(   r   r   r   r   r=     s   c               @   s   e Zd ZdZdd ZdS )r=   r   c             O   s*   t | trtj||S ttj| f||S )N)r+   r=   r   r'   )r"   r)   ro   r   r   r   r(     s    
zCounter.__new__N)r   r   r   r   r(   r   r   r   r   r=     s   c               @   s   e Zd ZdZdd ZdS )r=   r   c             O   s*   | j tkrtj||S ttj| f||S )N)r   r=   r   r'   )r"   r)   ro   r   r   r   r(     s    
zCounter.__new__N)r   r   r   r   r(   r   r   r   r   r=     s   ChainMapc               @   s   e Zd ZdZdd ZdS )r   r   c             O   s*   t | trtj||S ttj| f||S )N)r+   r   r   r'   )r"   r)   ro   r   r   r   r(   
  s    
zChainMap.__new__N)r   r   r   r   r(   r   r   r   r   r     s   c               @   s   e Zd ZdZdd ZdS )r   r   c             O   s*   | j tkrtj||S ttj| f||S )N)r   r   r   r'   )r"   r)   ro   r   r   r   r(     s    
zChainMap.__new__N)r   r   r   r   r(   r   r   r   r   r     s   AsyncGeneratorc               @   s   e Zd ZdZdS )r   r   N)r   r   r   r   r   r   r   r   r     s   c             C   s   dd }| |_ ||_|S )aQ  NewType creates simple unique types with almost zero
        runtime overhead. NewType(name, tp) is considered a subtype of tp
        by static type checkers. At runtime, NewType(name, tp) returns
        a dummy function that simply returns its argument. Usage::

            UserId = NewType('UserId', int)

            def name_by_id(user_id: UserId) -> str:
                ...

            UserId('user')          # Fails type check

            name_by_id(42)          # Fails type check
            name_by_id(UserId(42))  # OK

            num = UserId(5) + 1     # type: int
        c             S   s   | S )Nr   )r   r   r   r   new_type:  s    zNewType.<locals>.new_type)r   __supertype__)r]   rn   r   r   r   r   rD   '  s    c             C   s8   t | tstt| dr| jS x| jdk	r2| j} q W | S )z@This function exists for compatibility with old typing versions.r   N)r   r   AssertionErrorr   r   r   )r"   r   r   r   r   O  s    

r   c             C   sL   t }xBt| jdd D ],\}}t|trt|tkr| j|d  }qW |S )z@This function exists for compatibility with old typing versions.Nrq   )object	enumerater.   r   r   r   r   )r"   Znext_in_mroicr   r   r   r   Z  s
    r   r   IterableIteratorHashableSized	Container
Collection
Reversiblec             C   sz   t  }xn| jd d D ]\}|jdkr&qt|di }x>t|j t|  D ] }|dsN|dkrN|| qNW qW |S )Nr   )rO   r   __annotations___abc_)__abstractmethods__r   __weakref___is_protocol_is_runtime_protocolr/   __args__r   __next_in_mro__r   r   __orig_bases__r   __tree_hash__rY   r   rp   r(   r   _MutableMapping__markerr   )	setr.   r   r   listr/   keys
startswithadd)r"   attrsbaseannotationsattrr   r   r   _get_protocol_attrsi  s    
 r   c                s   t  fddt D S )Nc             3   s   | ]}t t |d V  qd S )N)callabler   )r   r   )r"   r   r   r   }  s    z,_is_callable_members_only.<locals>.<genexpr>)allr   )r"   r   )r"   r   _is_callable_members_only|  s    r   c             O   s   t | jrtdd S )Nz Protocols cannot be instantiated)rr   r   r   )rU   r)   r*   r   r   r   _no_init  s    
r   c                   sZ   e Zd ZdZesd fdd	Z fddZ fddZ fd	d
ZesRe	dd Z
  ZS )_ProtocolMetazInternal metaclass for Protocol.

        This exists so Protocol classes can be generic without deriving
        from Generic.
        Nc	                sL  |d kst |d k	r<|d k	s t tdd |D s:t |nt|}d }	xJ|D ]B}
|
tkrbtdt|
trN|
jttfkrN|	d k	rtd|
j	}	qNW |	d kr|}	njt
|}t
|	 | kstdd fdd|D tdd |D rd	nd
ddd |	D f |	}|}|d k	r>t|tjkr>||kr>|f| }tdd |D }tdd |D rvtdd |D }|||d tt| j| |||dd}tt|d|s|nt| ||_	|rtdd |D nd |_t||_|d kr ||_n|d k	r|j|_|j|_t|drH|r8t| ntt| |_ |S )Nc             s   s   | ]}t |tV  qd S )N)r   r   )r   tr   r   r   r     s    z(_ProtocolMeta.__new__.<locals>.<genexpr>z!Cannot inherit from plain GenericzACannot inherit from Generic[...] or Protocol[...] multiple times.z1Some type variables (%s) are not listed in %s[%s]z, c             3   s   | ]}| krt |V  qd S )N)str)r   r   )gvarsetr   r   r     s    c             s   s   | ]}|j tkV  qd S )N)r   r   )r   br   r   r   r     s   r   rO   c             s   s   | ]}t |V  qd S )N)r   )r   gr   r   r   r     s    c             s   s$   | ]}t |trt|n|V  qd S )N)r   r   r   )r   r   r   r   r   r     s   c             s   s    | ]}t |to|tk	V  qd S )N)r   r   r   )r   r   r   r   r   r     s    c             s   s   | ]}|t k	r|V  qd S )N)r   )r   r   r   r   r   r     s    )r   r   T)rZ   r   c             s   s*   | ]"}|t krd n|tkrdn|V  qdS ).r   N)r   r   )r   ar   r   r   r     s   r   )!r   r   r
   r   r   r   r   r   rO   r   r   r   r   rr   r   ABCMetar   updater\   r(   __setattr__r   r   r   r   r   _abc_registry
_abc_cacher   r~   r   r   r   )r"   r]   r^   r_   tvarsr)   originr   
orig_basesgvarsr   tvarsetZinitial_basesrU   )r`   )r   r   r(     sj    











z_ProtocolMeta.__new__c                s   t  j||  jdd s2tdd  jD  _ jrxf jdd  D ]T}|tt	fksH|j
dkrl|jtksHt|tr||jsHt|tr|jt	ksHtd| qHW t _ fdd}d	 jkr| _d S )
Nr   c             s   s*   | ]"}|t kp t|to |jt kV  qd S )N)rO   r   r   r   )r   r   r   r   r   r     s   z)_ProtocolMeta.__init__.<locals>.<genexpr>rq   zcollections.abcz7Protocols can only inherit from other protocols, got %rc                s    j dd stS t| ts$tdxtt D ]h}xb| jD ]T}||j kr\|j | d krZtS P t|di }t|t	j
r:||kr:t| tr:| jr:P q:W tS q.W dS )Nr   z"issubclass() arg 1 must be a classr   T)r/   getr0   r   rr   r   r   r.   r   rs   Mappingr   r   )r   r   r   r   )r"   r   r   _proto_hook  s$    


z+_ProtocolMeta.__init__.<locals>._proto_hookr   )r\   rp   r/   r  r   r   r   r.   r   r   r   r   _PROTO_WHITELISTr   r	   r   r   r   r   r   )r"   r)   r*   r   r  )r`   )r"   r   rp     s$    




z_ProtocolMeta.__init__c                sZ   t ddrtr$t jr$dS jrJt fddtD rJdS tt	 S )Nr   FTc             3   s8   | ]0}t  |o.tt|d  p.t |d k	V  qd S )N)r   r   r   )r   r   )instancerU   r   r   r     s   z2_ProtocolMeta.__instancecheck__.<locals>.<genexpr>)
r   r   r   r`   r   r   r   r\   r   rW   )rU   r	  )r`   )r	  rU   r   rW     s    z_ProtocolMeta.__instancecheck__c                s   | j d k	r*tdjd dkr&tddS | jdd rf| jdd sftdjd dkr^dS td	| jdd rt| stdjd dkrtt	| 
|S td
tt	| 
|S )Nrq   r   )r   r   zCParameterized generics cannot be used with class or instance checksFr   r   )r   r   rs   zBInstance and class checks can only be used with @runtime protocolsz<Protocols with non-method members don't support issubclass())r   r   r   r   r   r/   r  r   r\   r   rX   )rU   r"   )r`   r   r   rX     s    
z_ProtocolMeta.__subclasscheck__c          
      s,  t |ts|f}|s.t| tk	r.td| j d t fdd|D }| ttfkrtdd |D srtd|  t	t
|t	|krtd|  |}|}nP| ttfkrt|}|}n6| jttfkrtdt|  nt| | t|}|}| jd kr| fnd	}| j| j|| j t| j||| | j| jd
S )Nz)Parameter list to %s[...] cannot be emptyz*Parameters to generic types must be types.c             3   s   | ]}t | V  qd S )N)r   )r   p)msgr   r   r   .  s    z,_ProtocolMeta.__getitem__.<locals>.<genexpr>c             s   s   | ]}t |tV  qd S )N)r   r   )r   r
  r   r   r   r   0  s    z0Parameters to %r[...] must all be type variablesz(Parameters to %r[...] must all be uniquez'Cannot subscript already-subscripted %sr   )r   r)   r  r   r  )r   r   r   r   r   r   r   rO   r   r!   r   r   r
   r   r    r&   r`   r   r   r   r/   r   r   )rU   paramsr   r)   prependr   )r  r   rv   $  sD    



z_ProtocolMeta.__getitem__)NNNNN)r   r   r   rY   OLD_GENERICSr(   rp   rW   rX   r   rv   ra   r   r   )r`   r   r     s   @,r   c               @   s    e Zd ZdZdZdZdd ZdS )rO   a  Base class for protocol classes. Protocol classes are defined as::

          class Proto(Protocol):
              def meth(self) -> int:
                  ...

        Such classes are primarily used with static type checkers that recognize
        structural subtyping (static duck-typing), for example::

          class C:
              def meth(self) -> int:
                  return 0

          def func(x: Proto) -> int:
              return x.meth()

          func(C())  # Passes static type check

        See PEP 544 for details. Protocol classes decorated with
        @typing_extensions.runtime act as simple-minded runtime protocol that checks
        only the presence of given attributes, ignoring their type signatures.

        Protocol classes can be generic, they are defined as::

          class GenProto({bases}):
              def meth(self) -> T:
                  ...
        r   Tc             O   sB   t | tkrtdtr.tt| | f||S t| j| f||S )NzIType Protocol cannot be instantiated; it can be used only as a base class)r   rO   r   r  r'   r   r   )r"   r)   ro   r   r   r   r(   m  s
    zProtocol.__new__N)r   r   r   rY   r   r   r(   r   r   r   r   rO   M  s   )rb   zProtocol, Generic[T]zProtocol[T])r^   )r   r   _collect_type_varsc             O   s   t | jrtdd S )Nz Protocols cannot be instantiated)rr   r   r   )rU   r)   r*   r   r   r   r   |  s    
c                   s   e Zd Z fddZ  ZS )r   c                sV   t  ddrt r$tj r$dS  jrJt fddt D rJdS t S )Nr   FTc             3   s8   | ]0}t |o.tt |d  p.t|d k	V  qd S )N)r   r   r   )r   r   )r"   r	  r   r   r     s   z2_ProtocolMeta.__instancecheck__.<locals>.<genexpr>)	r   r   r   r`   r   r   r   r\   rW   )r"   r	  )r`   )r"   r	  r   rW     s    z_ProtocolMeta.__instancecheck__)r   r   r   rW   ra   r   r   )r`   r   r     s   c                   s<   e Zd ZdZdZdZ fddZedd Zdd	 Z	  Z
S )
rO   a  Base class for protocol classes. Protocol classes are defined as::

            class Proto(Protocol):
                def meth(self) -> int:
                    ...

        Such classes are primarily used with static type checkers that recognize
        structural subtyping (static duck-typing), for example::

            class C:
                def meth(self) -> int:
                    return 0

            def func(x: Proto) -> int:
                return x.meth()

            func(C())  # Passes static type check

        See PEP 544 for details. Protocol classes decorated with
        @typing_extensions.runtime act as simple-minded runtime protocol that checks
        only the presence of given attributes, ignoring their type signatures.

        Protocol classes can be generic, they are defined as::

            class GenProto(Protocol[T]):
                def meth(self) -> T:
                    ...
        r   Tc                s   | t krtdt | S )NzIType Protocol cannot be instantiated; it can only be used as a base class)rO   r   r\   r(   )r"   r)   ro   )r`   r   r   r(     s    zProtocol.__new__c                s   t |ts|f}|s,| tk	r,td| jd t fdd|D }| tkrtdd |D sd}xt || tr~|d7 }qfW td|d || t	t
|t	|krtd	n
t| | t| |S )
Nz)Parameter list to {}[...] cannot be emptyz*Parameters to generic types must be types.c             3   s   | ]}t | V  qd S )N)r   )r   r
  )r  r   r   r     s    z-Protocol.__class_getitem__.<locals>.<genexpr>c             s   s   | ]}t |tV  qd S )N)r   r   )r   r
  r   r   r   r     s    r   rq   zJParameters to Protocol[...] must all be type variables. Parameter {} is {}z.Parameters to Protocol[...] must all be unique)r   r   r   r   rt   r   rO   r   r   r!   r   r&   r   )r"   r  r   r   )r  r   __class_getitem__  s(    

zProtocol.__class_getitem__c                s  g }d j krt jk}n
t jk}|r0tdd j krt j}d }xN jD ]D}t|trR|jtt	fkrR|jtkr|dnd}|d k	rtd|j
}qRW |d kr|}nZt|}t||ksdfdd|D }	dd	d |D }
td
|	||
|}t| _
 j dd s2tdd  jD  _ fdd}d j krP| _ js\d S xV jD ]L}|ttfksd|jdkr|jtksdt|tr|jsdtd| qdW t _d S )Nr   z!Cannot inherit from plain Genericr   rO   zECannot inherit from Generic[...] and/or Protocol[...] multiple types.z, c             3   s   | ]}| krt |V  qd S )N)r   )r   r   )r   r   r   r     s    z-Protocol.__init_subclass__.<locals>.<genexpr>c             s   s   | ]}t |V  qd S )N)r   )r   r   r   r   r   r     s    z1Some type variables ({}) are not listed in {}[{}]r   c             s   s   | ]}|t kV  qd S )N)rO   )r   r   r   r   r   r     s    c                s    j dd stS t dds>tdjd dkr6tS tdt sftdjd dkr^tS tdt	| t
sxtd	xtt D ]h}xb| jD ]T}||j kr|j | d krtS P t|d
i }t	|tjr||krt	| tr| jrP qW tS qW dS )Nr   r   Fr,   r   )r   r   zBInstance and class checks can only be used with @runtime protocolsz<Protocols with non-method members don't support issubclass()z"issubclass() arg 1 must be a classr   T)r/   r  r0   r   r   r   r   r   r   r   rr   r   r.   rs   r  r   r   )r   r   r   r   )r"   r   r   r    s4    


z/Protocol.__init_subclass__.<locals>._proto_hookr   zcollections.abcz7Protocols can only inherit from other protocols, got %r)r/   r   r   r   r   r  r   r   r   rO   r   r   r   rt   r   r  r   r   r   r   r   r   r  r   r   rp   )r"   r)   r*   r   errorr  r   Zthe_baser  s_varss_argsr  r   )r"   r   r   __init_subclass__  sX    






zProtocol.__init_subclass__)r   r   r   rY   r   r   r(   r   r  r  ra   r   r   )r`   r   rO     s   c             C   s&   t | tr| jstd|  d| _| S )a4  Mark a protocol class as a runtime protocol, so that it
        can be used with isinstance() and issubclass(). Raise TypeError
        if applied to a non-protocol class.

        This allows a simple-minded structural check very similar to the
        one-offs in collections.abc such as Hashable.
        zB@runtime_checkable can be only applied to protocol classes, got %rT)r   r   r   r   r   )r"   r   r   r   rQ   6  s
    c               @   s$   e Zd ZdZejedddZdS )r@   r   )returnc             C   s   d S )Nr   )rU   r   r   r   	__index__Q  s    zSupportsIndex.__index__N)r   r   r   r   r   r   r   r  r   r   r   r   r@   M  s   )r   	   r,   c          	   C   s>   y t djd dkrtdW n ttfk
r8   Y nX dS )Nrq   r   )r   r   rs   z4TypedDict does not support instance and class checksF)r   r   r   r   AttributeError
ValueError)r"   r   r   r   r   _check_fails]  s    r  c              O   s,   | st d| d | dd   }} t| |S )Nz)TypedDict.__new__(): not enough argumentsr   rq   )r   r   )r)   r*   _r   r   r   	_dict_newh  s    r  z,($cls, _typename, _fields=None, /, **kwargs))totalc          	   O   sZ  |st d|d |dd   }}|r>|d |dd   }}n4d|krj|d}dd l}|jdtdd nt d|ry
|\}W q tk
r   t d	t|d Y qX n<d
|krt|dkr|d
}dd l}|jdtdd nd }|d kr|}n|rt ddt|i}yt	
djdd|d< W n ttfk
rH   Y nX t|d|| dS )Nz)TypedDict.__new__(): not enough argumentsr   rq   Z	_typenamez5Passing '_typename' as keyword argument is deprecatedr,   )
stacklevelzGTypedDict.__new__() missing 1 required positional argument: '_typename'zLTypedDict.__new__() takes from 2 to 3 positional arguments but {} were given_fieldsz3Passing '_fields' as keyword argument is deprecatedz@TypedDict takes either a dict or keyword arguments, but not bothr   r   __main__r   r   )r  )r   r   warningswarnDeprecationWarningr  rt   r!   r   r   r   r   r  r  _TypedDictMeta)r  r)   r*   r  typenamer!  fieldsnsr   r   r   _typeddict_newp  sB    


r(  z;($cls, _typename, _fields=None, /, *, total=True, **kwargs)c                   s4   e Zd Zd fdd	Zd fdd	Ze ZZ  ZS )r$  Tc                s   t t| ||| d S )N)r\   r$  rp   )r"   r]   r^   r'  r  )r`   r   r   rp     s    z_TypedDictMeta.__init__c                s  |dkrt nt|d< tt| | |tf|}i }|di }t| }d  fdd|	 D }t }	t }
xH|D ]@}|
|jdi  |	
|jdd |

|jd	d qtW |
| |r|	
| n
|

| ||_t|	|_t|
|_t|d
s||_|S )N	TypedDictr(   r   z?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typec                s   i | ]\}}t | |qS r   )rs   r   )r   nrn   )r  r   r   
<dictcomp>  s   z*_TypedDictMeta.__new__.<locals>.<dictcomp>__required_keys__r   __optional_keys__	__total__)r(  r  r\   r$  r(   r   r  r   r   itemsr   r/   r   	frozensetr,  r-  r   r.  )r"   r]   r^   r'  r  Ztp_dictr   Zown_annotationsZown_annotation_keysZrequired_keysZoptional_keysr   )r`   )r  r   r(     s0    





z_TypedDictMeta.__new__)T)T)	r   r   r   rp   r(   r  rW   rX   ra   r   r   )r`   r   r$    s   &r$  r)  a  A simple typed name space. At runtime it is equivalent to a plain dict.

        TypedDict creates a dictionary type that expects all of its
        instances to have a certain set of keys, with each key
        associated with a value of a consistent type. This expectation
        is not checked at runtime but is only enforced by type checkers.
        Usage::

            class Point2D(TypedDict):
                x: int
                y: int
                label: str

            a: Point2D = {'x': 1, 'y': 2, 'label': 'good'}  # OK
            b: Point2D = {'z': 3, 'label': 'bad'}           # Fails type check

            assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')

        The type info can be accessed via the Point2D.__annotations__ dict, and
        the Point2D.__required_keys__ and Point2D.__optional_keys__ frozensets.
        TypedDict supports two additional equivalent forms::

            Point2D = TypedDict('Point2D', x=int, y=int, label=str)
            Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})

        The class syntax is only supported in Python 3.6+, while two other
        syntax forms work for Python 2.7 and 3.2+
        c                   sH   e Zd ZdZ fddZdd Zdd Zdd	 Zd
d Zdd Z	  Z
S )_AnnotatedAliasaK  Runtime representation of an annotated type.

        At its core 'Annotated[t, dec1, dec2, ...]' is an alias for the type 't'
        with extra annotations. The alias behaves like a normal typing alias,
        instantiating is the same as instantiating the underlying type, binding
        it to types is also the same.
        c                s2   t |tr|j| }|j}t || || _d S )N)r   r1  __metadata__r   r\   rp   )rU   r  metadata)r`   r   r   rp     s
    

z_AnnotatedAlias.__init__c             C   s$   t |dkst|d }t|| jS )Nrq   r   )r!   r   r1  r2  )rU   r  r   r   r   r   	copy_with  s    z_AnnotatedAlias.copy_withc             C   s&   d t| jddd | jD S )Nz#typing_extensions.Annotated[{}, {}]z, c             s   s   | ]}t |V  qd S )N)r    )r   r   r   r   r   r     s    z+_AnnotatedAlias.__repr__.<locals>.<genexpr>)rt   rs   r|   r   r   r2  )rU   r   r   r   r{   
  s    
z_AnnotatedAlias.__repr__c             C   s   t jt| jf| j ffS )N)operatorgetitemrM   r   r2  )rU   r   r   r   
__reduce__  s    z_AnnotatedAlias.__reduce__c             C   s*   t |tstS | j|jkrdS | j|jkS )NF)r   r1  r0   r   r2  )rU   r   r   r   r   r     s
    
z_AnnotatedAlias.__eq__c             C   s   t | j| jfS )N)r~   r   r2  )rU   r   r   r   r     s    z_AnnotatedAlias.__hash__)r   r   r   rY   rp   r4  r{   r7  r   r   ra   r   r   )r`   r   r1    s   r1  c               @   s0   e Zd ZdZdZdd Zedd Zdd Zd	S )
rM   a  Add context specific metadata to a type.

        Example: Annotated[int, runtime_check.Unsigned] indicates to the
        hypothetical runtime_check module that this type is an unsigned int.
        Every other consumer of this type can ignore this metadata and treat
        this type as int.

        The first argument to Annotated must be a valid type (and will be in
        the __origin__ field), the remaining arguments are kept as a tuple in
        the __extra__ field.

        Details:

        - It's an error to call `Annotated` with less than two arguments.
        - Nested Annotated are flattened::

            Annotated[Annotated[T, Ann1, Ann2], Ann3] == Annotated[T, Ann1, Ann2, Ann3]

        - Instantiating an annotated type is equivalent to instantiating the
        underlying type::

            Annotated[C, Ann1](5) == C(5)

        - Annotated can be used as a generic type alias::

            Optimized = Annotated[T, runtime.Optimize()]
            Optimized[int] == Annotated[int, runtime.Optimize()]

            OptimizedList = Annotated[List[T], runtime.Optimize()]
            OptimizedList[int] == Annotated[List[int], runtime.Optimize()]
        r   c             O   s   t dd S )Nz&Type Annotated cannot be instantiated.)r   )r"   r)   r*   r   r   r   r(   B  s    zAnnotated.__new__c             C   sL   t |trt|dk rtdd}t|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   rq   )r   r   r!   r   rs   r   r1  )r"   r  r  r  r3  r   r   r   r  E  s    zAnnotated.__class_getitem__c             O   s   t d| jd S )NzCannot subclass {}.Annotated)r   rt   r   )r"   r)   r*   r   r   r   r  P  s    zAnnotated.__init_subclass__N)	r   r   r   rY   r   r(   r   r  r  r   r   r   r   rM     s
   c             C   s\   t | trt| jS t | tjrXtdd | jD }|| jkrB| S | |}| j	|_	|S | S )z2Strips the annotations from a given type.
        c             s   s   | ]}t |V  qd S )N)_strip_annotations)r   r   r   r   r   r   [  s    z%_strip_annotations.<locals>.<genexpr>)
r   r1  r8  r   rs   r   r   r   r4  _special)r   Zstripped_argsr   r   r   r   r8  U  s    



r8  c             C   s*   t j| ||d}|r|S dd | D S )a]  Return type hints for an object.

        This is often the same as obj.__annotations__, but it handles
        forward references encoded as string literals, adds Optional[t] if a
        default value equal to None is set and recursively replaces all
        'Annotated[T, ...]' with 'T' (unless 'include_extras=True').

        The argument may be a module, class, method, or function. The annotations
        are returned as a dictionary. For classes, annotations include also
        inherited members.

        TypeError is raised if the argument is not of a type that can contain
        annotations, and an empty dictionary is returned if no annotations are
        present.

        BEWARE -- the behavior of globalns and localns is counterintuitive
        (unless you are familiar with how eval() and exec() work).  The
        search order is locals first, then globals.

        - If no dict arguments are passed, an attempt is made to use the
          globals from obj (or the respective module's globals for classes),
          and these are also used as the locals.  If the object does not appear
          to have globals, an empty dictionary is used.

        - If one dict argument is passed, it is used for both globals and
          locals.

        - If two dict arguments are passed, they specify globals and
          locals, respectively.
        )rx   ry   c             S   s   i | ]\}}t ||qS r   )r8  )r   kr   r   r   r   r+    s    z"get_type_hints.<locals>.<dictcomp>)rs   rL   r/  )rV   rx   ry   Zinclude_extrashintr   r   r   rL   c  s    c             C   s    t | dko| do| dS )z3Returns True if name is a __dunder_variable_name__.   __)r!   r   endswith)r]   r   r   r   
_is_dunder  s    r?  c                   s   e Zd ZdZ fddZedd Zdd Zd fd	d
	Zdd Z	e
 fddZdd Zdd Z fddZdd Zdd Z  ZS )AnnotatedMetazMetaclass for Annotatedc                s8   t dd |D r"tdtt t j| |||f|S )Nc             s   s   | ]}|t k	V  qd S )N)r   )r   r   r   r   r   r     s    z(AnnotatedMeta.__new__.<locals>.<genexpr>zCannot subclass )r   r   r   rM   r\   r(   )r"   r]   r^   r_   r*   )r`   r   r   r(     s    zAnnotatedMeta.__new__c             C   s   |   d S )Nr,   )r   )rU   r   r   r   r2    s    zAnnotatedMeta.__metadata__c             C   sP   |\}}}t |ts t|}n|d |}ddd |D }d|||f S )Nr   z, c             s   s   | ]}t |V  qd S )N)r    )r   argr   r   r   r     s    z+AnnotatedMeta._tree_repr.<locals>.<genexpr>z
%s[%s, %s])r   r   rs   r|   
_tree_reprr   )rU   treer"   r  r3  Ztp_reprZmetadata_reprsr   r   r   rB    s    

zAnnotatedMeta._tree_reprNc                sh   | t krt S t j||d}t|d trd|d d t krd|d d }|d d }t |||d  fS |S )N)r   r)   rq   r   r,   )rM   r\   r   r   r   )rU   r   r)   r   Zsub_tpZ	sub_annot)r`   r   r   r     s    zAnnotatedMeta._subs_treec             C   sX   | j dkrtd|  }x"t|tr<|d tkr<|d }qW t|trP|d S |S dS )z6Return the class used to create instance of this type.NzCCannot get the underlying type of a non-specialized Annotated type.r   rq   )r   r   r   r   r   rM   )rU   rC  r   r   r   	_get_cons  s    

zAnnotatedMeta._get_consc                s   t |ts|f}| jd k	r&t |S t |tr<t|dk rFtdn$d}t|d |}t|dd  }| j	| j
| jt| jt|f||f| dS )Nr,   z]Annotated[...] should be instantiated with at least two arguments (a type and an annotation).z$Annotated[t, ...]: t must be a type.r   rq   )r   r)   r  )r   r   r   r\   rv   r!   r   rs   r   r`   r   r   r   r/   r
   )rU   r  r  rn   r3  )r`   r   r   rv     s     


zAnnotatedMeta.__getitem__c             O   s6   |   }|||}y
| |_W n tk
r0   Y nX |S )N)rD  __orig_class__r  )rU   r)   r*   Zconsresultr   r   r   __call__  s    

zAnnotatedMeta.__call__c             C   s,   | j d k	r t|s t|  |S t|d S )N)r   r?  r   rD  r  )rU   r   r   r   r   __getattr__  s    zAnnotatedMeta.__getattr__c                sJ   t |s|dr"t || n$| jd kr6t|nt|  || d S )Nr   )r?  r   r\   r   r   r  setattrrD  )rU   r   value)r`   r   r   r     s
    

zAnnotatedMeta.__setattr__c             C   s   t dd S )Nz+Annotated cannot be used with isinstance().)r   )rU   rV   r   r   r   rW     s    zAnnotatedMeta.__instancecheck__c             C   s   t dd S )Nz+Annotated cannot be used with issubclass().)r   )rU   r"   r   r   r   rX     s    zAnnotatedMeta.__subclasscheck__)NN)r   r   r   rY   r(   propertyr2  rB  r   rD  r   rv   rG  rH  r   rW   rX   ra   r   r   )r`   r   r@    s   		r@  c               @   s   e Zd ZdZdS )rM   av  Add context specific metadata to a type.

        Example: Annotated[int, runtime_check.Unsigned] indicates to the
        hypothetical runtime_check module that this type is an unsigned int.
        Every other consumer of this type can ignore this metadata and treat
        this type as int.

        The first argument to Annotated must be a valid type, the remaining
        arguments are kept as a tuple in the __metadata__ field.

        Details:

        - It's an error to call `Annotated` with less than two arguments.
        - Nested Annotated are flattened::

            Annotated[Annotated[T, Ann1, Ann2], Ann3] == Annotated[T, Ann1, Ann2, Ann3]

        - Instantiating an annotated type is equivalent to instantiating the
        underlying type::

            Annotated[C, Ann1](5) == C(5)

        - Annotated can be used as a generic type alias::

            Optimized = Annotated[T, runtime.Optimize()]
            Optimized[int] == Annotated[int, runtime.Optimize()]

            OptimizedList = Annotated[List[T], runtime.Optimize()]
            OptimizedList[int] == Annotated[List[int], runtime.Optimize()]
        N)r   r   r   rY   r   r   r   r   rM     s   )r   
   )r   )_BaseGenericAlias)GenericAliasc             C   s8   t | trtS t | tttttfr(| jS | t	kr4t	S dS )a6  Get the unsubscripted version of a type.

        This supports generic types, Callable, Tuple, Union, Literal, Final, ClassVar
        and Annotated. Return None for unsupported types. Examples::

            get_origin(Literal[42]) is Literal
            get_origin(int) is None
            get_origin(ClassVar[int]) is ClassVar
            get_origin(Generic) is Generic
            get_origin(Generic[T]) is Generic
            get_origin(Union[T, int]) is Union
            get_origin(List[Tuple[T, T]][int]) == list
            get_origin(P.args) is P
        N)
r   r1  rM   r   rN  rM  ParamSpecArgsParamSpecKwargsr   r   )rn   r   r   r   rK   '  s    


c             C   sx   t | tr| jf| j S t | ttfrtt| ddr6dS | j}t| t	j
jkrp|d tk	rpt|dd |d f}|S dS )a  Get type arguments with all substitutions performed.

        For unions, basic simplifications used by Union constructor are performed.
        Examples::
            get_args(Dict[str, int]) == (str, int)
            get_args(int) == ()
            get_args(Union[int, Union[T, int], str][int]) == (int, str)
            get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int])
            get_args(Callable[[], T][int]) == ([], int)
        r9  Fr   r   Nr   )r   r1  r   r2  r   rN  r   r   rK   r   r   r   Ellipsisr   )rn   r   r   r   r   rJ   ?  s    
)r   r  c               @   s   e Zd Zdd ZdS )_TypeAliasFormc             C   s
   d| j  S )Nztyping_extensions.)r   )rU   r   r   r   r{   Z  s    z_TypeAliasForm.__repr__N)r   r   r   r{   r   r   r   r   rR  Y  s   rR  c             C   s   t d| dS )a&  Special marker indicating that an assignment should
        be recognized as a proper type alias definition by type
        checkers.

        For example::

            Predicate: TypeAlias = Callable[..., bool]

        It's invalid when used anywhere except as in the example above.
        z{} is not subscriptableN)r   rt   )rU   r#   r   r   r   rG   ]  s    c               @   s   e Zd Zdd ZdS )rR  c             C   s
   d| j  S )Nztyping_extensions.)r   )rU   r   r   r   r{   m  s    z_TypeAliasForm.__repr__N)r   r   r   r{   r   r   r   r   rR  l  s   a  Special marker indicating that an assignment should
                               be recognized as a proper type alias definition by type
                               checkers.

                               For example::

                                   Predicate: TypeAlias = Callable[..., bool]

                               It's invalid when used anywhere except as in the example
                               above.c               @   s   e Zd ZdZdd ZdS )_TypeAliasMetazMetaclass for TypeAliasc             C   s   dS )Nztyping_extensions.TypeAliasr   )rU   r   r   r   r{     s    z_TypeAliasMeta.__repr__N)r   r   r   rY   r{   r   r   r   r   rS  }  s   rS  c               @   s,   e Zd ZdZdZdd Zdd Zdd Zd	S )
_TypeAliasBasea&  Special marker indicating that an assignment should
        be recognized as a proper type alias definition by type
        checkers.

        For example::

            Predicate: TypeAlias = Callable[..., bool]

        It's invalid when used anywhere except as in the example above.
        r   c             C   s   t dd S )Nz+TypeAlias cannot be used with isinstance().)r   )rU   rV   r   r   r   rW     s    z _TypeAliasBase.__instancecheck__c             C   s   t dd S )Nz+TypeAlias cannot be used with issubclass().)r   )rU   r"   r   r   r   rX     s    z _TypeAliasBase.__subclasscheck__c             C   s   dS )Nztyping_extensions.TypeAliasr   )rU   r   r   r   r{     s    z_TypeAliasBase.__repr__N)r   r   r   rY   r   rW   rX   r{   r   r   r   r   rT    s
   
rT  c               @   s(   e Zd ZdZdd Zdd Zdd ZdS )	rS  zMetaclass for TypeAliasc             C   s   t dd S )Nz+TypeAlias cannot be used with isinstance().)r   )rU   rV   r   r   r   rW     s    z _TypeAliasMeta.__instancecheck__c             C   s   t dd S )Nz+TypeAlias cannot be used with issubclass().)r   )rU   r"   r   r   r   rX     s    z _TypeAliasMeta.__subclasscheck__c             O   s   t dd S )NzCannot instantiate TypeAlias)r   )rU   r)   r*   r   r   r   rG    s    z_TypeAliasMeta.__call__N)r   r   r   rY   rW   rX   rG  r   r   r   r   rS    s   c               @   s   e Zd ZdZdZdS )rG   a&  Special marker indicating that an assignment should
        be recognized as a proper type alias definition by type
        checkers.

        For example::

            Predicate: TypeAlias = Callable[..., bool]

        It's invalid when used anywhere except as in the example above.
        r   N)r   r   r   rY   r   r   r   r   r   rG     s   
rO  c               @   s$   e Zd ZdZdZdd Zdd ZdS )
_Immutablez3Mixin to indicate that object should not be copied.r   c             C   s   | S )Nr   )rU   r   r   r   __copy__  s    z_Immutable.__copy__c             C   s   | S )Nr   )rU   memor   r   r   __deepcopy__  s    z_Immutable.__deepcopy__N)r   r   r   rY   r   rV  rX  r   r   r   r   rU    s   rU  c               @   s    e Zd ZdZdd Zdd ZdS )rO  aQ  The args for a ParamSpec object.

        Given a ParamSpec object P, P.args is an instance of ParamSpecArgs.

        ParamSpecArgs objects have a reference back to their ParamSpec:

        P.args.__origin__ is P

        This type is meant for runtime introspection and has no special meaning to
        static type checkers.
        c             C   s
   || _ d S )N)r   )rU   r  r   r   r   rp     s    zParamSpecArgs.__init__c             C   s   d | jjS )Nz{}.args)rt   r   r   )rU   r   r   r   r{     s    zParamSpecArgs.__repr__N)r   r   r   rY   rp   r{   r   r   r   r   rO    s   c               @   s    e Zd ZdZdd Zdd ZdS )rP  a[  The kwargs for a ParamSpec object.

        Given a ParamSpec object P, P.kwargs is an instance of ParamSpecKwargs.

        ParamSpecKwargs objects have a reference back to their ParamSpec:

        P.kwargs.__origin__ is P

        This type is meant for runtime introspection and has no special meaning to
        static type checkers.
        c             C   s
   || _ d S )N)r   )rU   r  r   r   r   rp     s    zParamSpecKwargs.__init__c             C   s   d | jjS )Nz	{}.kwargs)rt   r   r   )rU   r   r   r   r{     s    zParamSpecKwargs.__repr__N)r   r   r   rY   rp   r{   r   r   r   r   rP    s   rP  c                   sj   e Zd ZdZedd Zedd Zdddd fd	d

Zdd Zdd Z	dd Z
dd Zdd Z  ZS )r:   a'  Parameter specification variable.

        Usage::

           P = ParamSpec('P')

        Parameter specification variables exist primarily for the benefit of static
        type checkers.  They are used to forward the parameter types of one
        callable to another callable, a pattern commonly found in higher order
        functions and decorators.  They are only valid when used in ``Concatenate``,
        or s the first argument to ``Callable``. In Python 3.10 and higher,
        they are also supported in user-defined Generics at runtime.
        See class Generic for more information on generic types.  An
        example for annotating a decorator::

           T = TypeVar('T')
           P = ParamSpec('P')

           def add_logging(f: Callable[P, T]) -> Callable[P, T]:
               '''A type-safe decorator to add logging to a function.'''
               def inner(*args: P.args, **kwargs: P.kwargs) -> T:
                   logging.info(f'{f.__name__} was called')
                   return f(*args, **kwargs)
               return inner

           @add_logging
           def add_two(x: float, y: float) -> float:
               '''Add two numbers together.'''
               return x + y

        Parameter specification variables defined with covariant=True or
        contravariant=True can be used to declare covariant or contravariant
        generic types.  These keyword arguments are valid, but their actual semantics
        are yet to be decided.  See PEP 612 for details.

        Parameter specification variables can be introspected. e.g.:

           P.__name__ == 'T'
           P.__bound__ == None
           P.__covariant__ == False
           P.__contravariant__ == False

        Note that only parameter specification variables defined in global scope can
        be pickled.
        c             C   s   t | S )N)rO  )rU   r   r   r   r)   	  s    zParamSpec.argsc             C   s   t | S )N)rP  )rU   r   r   r   r*    	  s    zParamSpec.kwargsNF)r   rg   rk   c         	      s   t  | g || _t|| _t|| _|r<t|d| _nd | _yt	
djdd}W n ttfk
rv   d }Y nX |dkr|| _d S )NzBound must be a type.rq   r   r   Ztyping_extensions)r\   rp   r   bool__covariant____contravariant__rs   r   	__bound__r   r   r   r  r  r  r   )rU   r]   r   rg   rk   def_mod)r`   r   r   rp   $	  s    


zParamSpec.__init__c             C   s&   | j rd}n| jrd}nd}|| j S )N+-~)rZ  r[  r   )rU   prefixr   r   r   r{   6	  s    zParamSpec.__repr__c             C   s
   t | S )N)r   r   )rU   r   r   r   r   ?	  s    zParamSpec.__hash__c             C   s   | |kS )Nr   )rU   r   r   r   r   r   B	  s    zParamSpec.__eq__c             C   s   | j S )N)r   )rU   r   r   r   r7  E	  s    zParamSpec.__reduce__c             O   s   d S )Nr   )rU   r)   r*   r   r   r   rG  I	  s    zParamSpec.__call__)r   r   r   rY   rK  r)   r*   rp   r{   r   r   r7  rG  ra   r   r   )r`   r   r:     s   -	c                   s,   e Zd Z fddZdd Zdd Z  ZS )_ConcatenateGenericAliasc                s   t  | || _|| _d S )N)r\   rp   r   r   )rU   r  r)   )r`   r   r   rp   T	  s    z!_ConcatenateGenericAlias.__init__c                s0   t j dj | jd fdd| jD dS )Nz{origin}[{args}]z, c             3   s   | ]} |V  qd S )Nr   )r   rA  )r|   r   r   r   ]	  s    z4_ConcatenateGenericAlias.__repr__.<locals>.<genexpr>)r  r)   )rs   r|   rt   r   r   r   )rU   r   )r|   r   r{   Y	  s    z!_ConcatenateGenericAlias.__repr__c             C   s   t | j| jfS )N)r~   r   r   )rU   r   r   r   r   _	  s    z!_ConcatenateGenericAlias.__hash__)r   r   r   rp   r{   r   ra   r   r   )r`   r   rb  S	  s   rb  c                sZ   |dkrt dt|ts |f}t|d ts6t dd t fdd|D }t| |S )Nr   z&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.c             3   s   | ]}t | V  qd S )N)rs   r   )r   r
  )r  r   r   r   l	  s    z'_concatenate_getitem.<locals>.<genexpr>)r   r   r   r:   rb  )rU   r#   r   )r  r   _concatenate_getitemb	  s    
rc  c             C   s
   t | |S )a&  Used in conjunction with ``ParamSpec`` and ``Callable`` to represent a
        higher order function which adds, removes or transforms parameters of a
        callable.

        For example::

           Callable[Concatenate[int, P], int]

        See PEP 612 for detailed information.
        )rc  )rU   r#   r   r   r   r8   t	  s    c               @   s   e Zd Zdd Zdd ZdS )_ConcatenateFormc             C   s
   d| j  S )Nztyping_extensions.)r   )rU   r   r   r   r{   	  s    z_ConcatenateForm.__repr__c             C   s
   t | |S )N)rc  )rU   r#   r   r   r   rv   	  s    z_ConcatenateForm.__getitem__N)r   r   r   r{   rv   r   r   r   r   rd  	  s   rd  a&  Used in conjunction with ``ParamSpec`` and ``Callable`` to represent a
        higher order function which adds, removes or transforms parameters of a
        callable.

        For example::

           Callable[Concatenate[int, P], int]

        See PEP 612 for detailed information.
        c               @   s   e Zd ZdZdd ZdS )_ConcatenateAliasMetazMetaclass for Concatenate.c             C   s   dS )Nztyping_extensions.Concatenater   )rU   r   r   r   r{   	  s    z_ConcatenateAliasMeta.__repr__N)r   r   r   rY   r{   r   r   r   r   re  	  s   re  c               @   s4   e Zd ZdZdZdd Zdd Zdd Zd	d
 ZdS )_ConcatenateAliasBasea&  Used in conjunction with ``ParamSpec`` and ``Callable`` to represent a
        higher order function which adds, removes or transforms parameters of a
        callable.

        For example::

           Callable[Concatenate[int, P], int]

        See PEP 612 for detailed information.
        r   c             C   s   t dd S )Nz-Concatenate cannot be used with isinstance().)r   )rU   rV   r   r   r   rW   	  s    z'_ConcatenateAliasBase.__instancecheck__c             C   s   t dd S )Nz-Concatenate cannot be used with issubclass().)r   )rU   r"   r   r   r   rX   	  s    z'_ConcatenateAliasBase.__subclasscheck__c             C   s   dS )Nztyping_extensions.Concatenater   )rU   r   r   r   r{   	  s    z_ConcatenateAliasBase.__repr__c             C   s
   t | |S )N)rc  )rU   r#   r   r   r   rv   	  s    z!_ConcatenateAliasBase.__getitem__N)	r   r   r   rY   r   rW   rX   r{   rv   r   r   r   r   rf  	  s   rf  c               @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )re  zMetaclass for Concatenate.c             C   s   t dd S )Nz+TypeAlias cannot be used with isinstance().)r   )rU   rV   r   r   r   rW   	  s    z'_ConcatenateAliasMeta.__instancecheck__c             C   s   t dd S )Nz+TypeAlias cannot be used with issubclass().)r   )rU   r"   r   r   r   rX   	  s    z'_ConcatenateAliasMeta.__subclasscheck__c             O   s   t dd S )NzCannot instantiate TypeAlias)r   )rU   r)   r*   r   r   r   rG  	  s    z_ConcatenateAliasMeta.__call__c             C   s
   t | |S )N)rc  )rU   r#   r   r   r   rv   	  s    z!_ConcatenateAliasMeta.__getitem__N)r   r   r   rY   rW   rX   rG  rv   r   r   r   r   re  	  s
   c               @   s   e Zd ZdZdZdS )r8   a&  Used in conjunction with ``ParamSpec`` and ``Callable`` to represent a
        higher order function which adds, removes or transforms parameters of a
        callable.

        For example::

           Callable[Concatenate[int, P], int]

        See PEP 612 for detailed information.
        r   N)r   r   r   rY   r   r   r   r   r   r8   	  s   
c               @   s   e Zd Zdd ZdS )_TypeGuardFormc             C   s
   d| j  S )Nztyping_extensions.)r   )rU   r   r   r   r{   	  s    z_TypeGuardForm.__repr__N)r   r   r   r{   r   r   r   r   rg  	  s   rg  c             C   s   t |d| }t| |fS )a	  Special typing form used to annotate the return type of a user-defined
        type guard function.  ``TypeGuard`` only accepts a single type argument.
        At runtime, functions marked this way should return a boolean.

        ``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static
        type checkers to determine a more precise type of an expression within a
        program's code flow.  Usually type narrowing is done by analyzing
        conditional code flow and applying the narrowing to a block of code.  The
        conditional expression here is sometimes referred to as a "type guard".

        Sometimes it would be convenient to use a user-defined boolean function
        as a type guard.  Such a function should use ``TypeGuard[...]`` as its
        return type to alert static type checkers to this intention.

        Using  ``-> TypeGuard`` tells the static type checker that for a given
        function:

        1. The return value is a boolean.
        2. If the return value is ``True``, the type of its argument
        is the type inside ``TypeGuard``.

        For example::

            def is_str(val: Union[str, float]):
                # "isinstance" type guard
                if isinstance(val, str):
                    # Type of ``val`` is narrowed to ``str``
                    ...
                else:
                    # Else, type of ``val`` is narrowed to ``float``.
                    ...

        Strict type narrowing is not enforced -- ``TypeB`` need not be a narrower
        form of ``TypeA`` (it can even be a wider form) and this may lead to
        type-unsafe results.  The main reason is to allow for things like
        narrowing ``List[object]`` to ``List[str]`` even though the latter is not
        a subtype of the former, since ``List`` is invariant.  The responsibility of
        writing type-safe type guards is left to the user.

        ``TypeGuard`` also works with type variables.  For more information, see
        PEP 647 (User-Defined Type Guards).
        z{} accepts only single type.)rs   r   rt   r   )rU   r#   ru   r   r   r   rH   	  s    ,c               @   s   e Zd Zdd Zdd ZdS )rg  c             C   s
   d| j  S )Nztyping_extensions.)r   )rU   r   r   r   r{   
  s    z_TypeGuardForm.__repr__c             C   s    t |d| j}t| |fS )Nz{} accepts only a single type)rs   r   rt   r   r   )rU   r#   ru   r   r   r   rv   
  s    z_TypeGuardForm.__getitem__N)r   r   r   r{   rv   r   r   r   r   rg  
  s   a	  Special typing form used to annotate the return type of a user-defined
        type guard function.  ``TypeGuard`` only accepts a single type argument.
        At runtime, functions marked this way should return a boolean.

        ``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static
        type checkers to determine a more precise type of an expression within a
        program's code flow.  Usually type narrowing is done by analyzing
        conditional code flow and applying the narrowing to a block of code.  The
        conditional expression here is sometimes referred to as a "type guard".

        Sometimes it would be convenient to use a user-defined boolean function
        as a type guard.  Such a function should use ``TypeGuard[...]`` as its
        return type to alert static type checkers to this intention.

        Using  ``-> TypeGuard`` tells the static type checker that for a given
        function:

        1. The return value is a boolean.
        2. If the return value is ``True``, the type of its argument
        is the type inside ``TypeGuard``.

        For example::

            def is_str(val: Union[str, float]):
                # "isinstance" type guard
                if isinstance(val, str):
                    # Type of ``val`` is narrowed to ``str``
                    ...
                else:
                    # Else, type of ``val`` is narrowed to ``float``.
                    ...

        Strict type narrowing is not enforced -- ``TypeB`` need not be a narrower
        form of ``TypeA`` (it can even be a wider form) and this may lead to
        type-unsafe results.  The main reason is to allow for things like
        narrowing ``List[object]`` to ``List[str]`` even though the latter is not
        a subtype of the former, since ``List`` is invariant.  The responsibility of
        writing type-safe type guards is left to the user.

        ``TypeGuard`` also works with type variables.  For more information, see
        PEP 647 (User-Defined Type Guards).
        c                   sN   e Zd ZdZdZdddZdd Zdd	 Z fd
dZdd Z	dd Z
  ZS )
_TypeGuarda	  Special typing form used to annotate the return type of a user-defined
        type guard function.  ``TypeGuard`` only accepts a single type argument.
        At runtime, functions marked this way should return a boolean.

        ``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static
        type checkers to determine a more precise type of an expression within a
        program's code flow.  Usually type narrowing is done by analyzing
        conditional code flow and applying the narrowing to a block of code.  The
        conditional expression here is sometimes referred to as a "type guard".

        Sometimes it would be convenient to use a user-defined boolean function
        as a type guard.  Such a function should use ``TypeGuard[...]`` as its
        return type to alert static type checkers to this intention.

        Using  ``-> TypeGuard`` tells the static type checker that for a given
        function:

        1. The return value is a boolean.
        2. If the return value is ``True``, the type of its argument
        is the type inside ``TypeGuard``.

        For example::

            def is_str(val: Union[str, float]):
                # "isinstance" type guard
                if isinstance(val, str):
                    # Type of ``val`` is narrowed to ``str``
                    ...
                else:
                    # Else, type of ``val`` is narrowed to ``float``.
                    ...

        Strict type narrowing is not enforced -- ``TypeB`` need not be a narrower
        form of ``TypeA`` (it can even be a wider form) and this may lead to
        type-unsafe results.  The main reason is to allow for things like
        narrowing ``List[object]`` to ``List[str]`` even though the latter is not
        a subtype of the former, since ``List`` is invariant.  The responsibility of
        writing type-safe type guards is left to the user.

        ``TypeGuard`` also works with type variables.  For more information, see
        PEP 647 (User-Defined Type Guards).
        )rm   Nc             K   s
   || _ d S )N)rm   )rU   rn   ro   r   r   r   rp   s
  s    z_TypeGuard.__init__c          	   C   sR   t | }| jd kr6|t|d|jdd  ddS td|jdd  d S )Nz{} accepts only a single type.rq   T)rZ   z {} cannot be further subscripted)rr   rm   rs   r   rt   r   r   )rU   ru   r"   r   r   r   rv   v
  s    
z_TypeGuard.__getitem__c             C   s.   t | j||}|| jkr| S t| |ddS )NT)rZ   )rs   rw   rm   rr   )rU   rx   ry   rz   r   r   r   rw   
  s    
z_TypeGuard._eval_typec                s.   t   }| jd k	r*|dt| j7 }|S )Nz[{}])r\   r{   rm   rt   rs   r|   )rU   r}   )r`   r   r   r{   
  s    

z_TypeGuard.__repr__c             C   s   t t| j| jfS )N)r~   rr   r   rm   )rU   r   r   r   r   
  s    z_TypeGuard.__hash__c             C   s,   t |tstS | jd k	r$| j|jkS | |kS )N)r   rh  r0   rm   )rU   r   r   r   r   r   
  s
    

z_TypeGuard.__eq__)N)r   r   r   rY   r   rp   rv   rw   r{   r   r   ra   r   r   )r`   r   rh  E
  s   *
	rh  c                   s^   e Zd ZdZd fdd	Zdd Zdd	 Zd
d Zdd Z fddZ	dd Z
dd Z  ZS )_TypeGuardMetazMetaclass for TypeGuardNFc                s(   t  j| ||||d}|d k	r$||_|S )N)rZ   )r\   r(   rm   )r"   r]   r^   r_   rn   rZ   rU   )r`   r   r   r(   
  s    z_TypeGuardMeta.__new__c             C   s   t dd S )Nz+TypeGuard cannot be used with isinstance().)r   )rU   rV   r   r   r   rW   
  s    z _TypeGuardMeta.__instancecheck__c             C   s   t dd S )Nz+TypeGuard cannot be used with issubclass().)r   )rU   r"   r   r   r   rX   
  s    z _TypeGuardMeta.__subclasscheck__c             C   sb   t | }| jd k	r*td|jdd  t|d|jdd  }|| j| jt| j	|ddS )Nz {} cannot be further subscriptedrq   z{} accepts only single type.T)rn   rZ   )
rr   rm   r   rt   r   rs   r   r   r   r/   )rU   ru   r"   r   r   r   r   rv   
  s    

z_TypeGuardMeta.__getitem__c             C   s@   t | j||}|| jkr| S t| | j| jt| j| jddS )NT)rn   rZ   )rs   rw   rm   rr   r   r   r   r/   )rU   rx   ry   rz   r   r   r   rw   
  s    
z_TypeGuardMeta._eval_typec                s.   t   }| jd k	r*|dt| j7 }|S )Nz[{}])r\   r{   rm   rt   rs   r|   )rU   r}   )r`   r   r   r{   
  s    

z_TypeGuardMeta.__repr__c             C   s   t t| j| jfS )N)r~   rr   r   rm   )rU   r   r   r   r   
  s    z_TypeGuardMeta.__hash__c             C   s,   t |dstS | jd k	r$| j|jkS | |kS )Nrm   )r   r0   rm   )rU   r   r   r   r   r   
  s
    

z_TypeGuardMeta.__eq__)NF)r   r   r   rY   r(   rW   rX   rv   rw   r{   r   r   ra   r   r   )r`   r   ri  
  s   ri  c               @   s   e Zd ZdZdZdS )rH   a	  Special typing form used to annotate the return type of a user-defined
        type guard function.  ``TypeGuard`` only accepts a single type argument.
        At runtime, functions marked this way should return a boolean.

        ``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static
        type checkers to determine a more precise type of an expression within a
        program's code flow.  Usually type narrowing is done by analyzing
        conditional code flow and applying the narrowing to a block of code.  The
        conditional expression here is sometimes referred to as a "type guard".

        Sometimes it would be convenient to use a user-defined boolean function
        as a type guard.  Such a function should use ``TypeGuard[...]`` as its
        return type to alert static type checkers to this intention.

        Using  ``-> TypeGuard`` tells the static type checker that for a given
        function:

        1. The return value is a boolean.
        2. If the return value is ``True``, the type of its argument
        is the type inside ``TypeGuard``.

        For example::

            def is_str(val: Union[str, float]):
                # "isinstance" type guard
                if isinstance(val, str):
                    # Type of ``val`` is narrowed to ``str``
                    ...
                else:
                    # Else, type of ``val`` is narrowed to ``float``.
                    ...

        Strict type narrowing is not enforced -- ``TypeB`` need not be a narrower
        form of ``TypeA`` (it can even be a wider form) and this may lead to
        type-unsafe results.  The main reason is to allow for things like
        narrowing ``List[object]`` to ``List[str]`` even though the latter is not
        a subtype of the former, since ``List`` is invariant.  The responsibility of
        writing type-safe type guards is left to the user.

        ``TypeGuard`` also works with type variables.  For more information, see
        PEP 647 (User-Defined Type Guards).
        N)r   r   r   rY   rm   r   r   r   r   rH   
  s   *)NNF)r   r   
contextlibr   rs   collections.abcr   r5  r   r   r   r   r   ZPEP_560rr   r   r	   r  r
   r   r   ImportErrorr   Z	SUBS_TREEr   r   r   r   r&   r   r'   r+   Z_geqv_defined_collections_abc_check_methodsr6   r   ZHAVE_ANNOTATEDextendr   ZHAVE_PROTOCOLSrR   rS   rT   r[   r9   rc   rd   re   rf   rh   ri   rj   r7   rl   r   _SpecialFormr   r   r   rA   rB   rC   r   r   r   r   rE   r;   r   r   r   r   r   r   r   r>   r   MutableSequencer<   r   r   r   execr?   r   MutableMappingr   _aliasr=   r   r   r   Dictr   r   r   rD   rF   r   rI   r   r  r   r   rO   r   r   rY   rt   r   r  r   rQ   rP   r@   r)  r  r  __text_signature__r(  r$  r   r   r   rM   rL   r1  r8  r?  r@  rK   rJ   rM  rN  rG   rR  rS  rT  rO  rP  rU  r:   r   rb  rc  r8   rd  re  rf  rH   rg  rh  ri  r   r   r   r   <module>   s  








53 

43
/-	








	
	

&	

&

	

	
	



	
 F' ",.)6$b$




f

/
*
P3