o
    Gg3                    @   s.  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Z	d dl
Z
d dlZg dZdZeZejdkZG dd dZe ZejdkrMdd	 Znejd
krWdd	 Zndd	 Ze
jZe
dZe
dZe
dZe
jdddZe
jdddZejdkrd dl
mZ nG dd deZG dd dedZe
jZG dd de
jddZ e
j!Z!ejdkre
j"Z"ndd Z"d d! Z#ejd"kre
j$Z$n"d#d$ Z%d%d& Z&G d'd( d(e
j'ddZ(G d)d* d*e ddZ)e)d+d,Z$e
j*Z*e+e
d-re
j,Z,e
j-Z-e
j.Z.ne/e0ej/e1Z2d.d/ Z,d0d- Z-d1d2 Z.e
j3Z3e
j4Z4e
j5Z5e
j6Z6e
j7Z7e
j8Z8e
j9Z9e
j:Z:e
j;Z;e
j<Z<e
j=Z=e
j>Z>ejdkrDd d3l
m?Z?m@Z@mAZAmBZB nHd4d5 ZCeDe
d6e
j'ZEG d7d6 d6eEddZFedZGeFej jBd8eGeGfd9ZBeFej j@d:eGfd9Z@eFejHd:d;e
jIeJ fd<ZAeFejKd:d=e
jIeJ fd<Z?g d>d?d@gdAgdBZLeMe
jNh dCB ZOdDdE ZPddFdGZQejdHkre
jRZRn*d dIdJZSdKdL ZTdMdN ZUG dOdP dPee
jRZVeWdQdR ZXG dSdT dTe
jYeVdZRejdHkre
jZZZndUdV ZZeZZ[ejdWkr
e
j\Z\e
j]Z]e
j^Z^e
j_Z_e
j`Z`e
jaZae
jbZbnJeZG dXdY dYeRZ\eZG dZd[ d[eRZ]eZG d\d] d]eRZ^eZG d^d_ d_eRZ_eZG d`da daeRZ`eZG dbdc dceRe ZaeZG ddde deeRe Zbdfdg ZcdhZdedrge
jeZee
jfZfe
jgZgn@diehe
jijjv Zkdjdk ZlG dldm dmeZfemefdndoi Znecdpdq efddhdrdsdnZee+e
dmre
jfeffZoneffZodtdu Zge+e
dvre
jpZpndwdv Zpe+e
dxre
jqZqn
dydz Zrd!d{d|Zqe+e
d}re
jsZse
jtZtnG d~d de
j'ddZtG dd} d}Zsejdd: dkre
juZue
jvZvn4zd dl
mwZw W n exy   e
j'ZwY nw zd dl
myZz W n exy$   e
j'ZzY nw dd Zudd Zve+e
dr7e
j{Z{nejdd: d
krHe dd Z{ne ddd,Z{e+e
drXe
j|Z|nG dd deZ}G dd de}dZ~e~ Z|[~[}dd Zdd ZG dd dZG dd deZerd dl
mZ n	G dd dedZe+e
dre
jZe
jZnG dd dZG dd deZG dd deZerd dl
mZ ne+e
drG dd dedZn	G dd deeZe+e
dsG dd deZe
jdd Ze+e
dre
jZe
jZn!ejdd: d
kre dd ZnG dd de ddZeddd,Ze+e
dr,e
jZn!ejdd: d
kr=e dd ZnG dd de ddZeddd,Ze+e
drWe
jZn!ejdd: d
krhe dd ZnG dd de ddZeddd,ZG dd de
jddZe+e
dre
jZnedd Ze+e
dre
jZnedd Ze+e
dre
jZnedd Ze+e
dre
jZe
jZn-ejdd: d
kre dd Ze dd ZnG ddĄ de ddZeddd,Zeddd,Ze+e
dxre
jZn!ejdd: d
kre ddx ZnG ddɄ de ddZedxdd,ZdZejdWkr(e
jZdd̈́ ZnIejdd: d
krRG ddτ de ddZG ddф de
j'ddZeddӄ Zdd̈́ ZnG ddф de
j'ddZG ddׄ de ddZeded,Zdd̈́ Zer{d dl
mZ ne+e
dڃrdd܄ ZG ddڄ dedZnG ddڄ deZe+e
d߃re
jZn	dedefdd߄Ze+e
dre
jZndZe+e
dre
jZn	dedefddZejdWkre
jZn5ddhdhdhdoddeJdeJdeJdeJde
je
je
j3e
j e
jde
jf f df de
jde
jegef fddZe+e
dre
jZne
jde
jde
jf dZdedefddZe+edr2ejZne
dZG dd dZe+e
dڃsKefddZndd ZesUee
_deJfddZeeDe
ddhZdeJfddZe+e
d r~d"dd Zee
_ndd Zesee
_ejdHkre
jZn8d#ddZe
jZeMh dZG dd deZemed	doi Zd
d Zeceefdd	Ze+ej dArej jZnG ddA dAe jZee ee ee e+e	dre	jZndd Zejdkre
jZn
G dd dZe+e
dr!e
jZndd ZG dd dZe+e
dr?e
jZe
jZndedeJfddZŐdede
je fddZe+e
dree
jZn
G dd dZeDe	ddZedu rzd dlZW n
 exy   Y nw eDeːddZedureẽZedureZeΐd e
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jYZYe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jIZIe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZe
jZdS ($      N)mAnyClassVarConcatenateFinalLiteralString	ParamSpecParamSpecArgsParamSpecKwargsSelfTypeTypeVarTypeVarTupleUnpack	AwaitableAsyncIteratorAsyncIterable	CoroutineAsyncGeneratorAsyncContextManagerBufferChainMapContextManagerCounterDequeDefaultDict
NamedTupleOrderedDict	TypedDictSupportsAbsSupportsBytesSupportsComplexSupportsFloatSupportsIndexSupportsIntSupportsRound	Annotatedassert_neverassert_typeclear_overloadsdataclass_transform
deprecatedDocget_overloadsfinalget_args
get_originget_original_basesget_protocol_membersget_type_hintsIntVaris_protocolis_typeddictLiteralNewTypeoverloadoverrideProtocolreveal_typeruntimeruntime_checkableText	TypeAliasTypeAliasType	TypeGuardTypeIsTYPE_CHECKINGNeverNoReturnReadOnlyRequiredNotRequiredAbstractSetAnyStrBinaryIOCallable
Collection	ContainerDict
ForwardRef	FrozenSet	GeneratorGenericHashableIO	ItemsViewIterableIteratorKeysViewListMappingMappingViewMatchMutableMappingMutableSequence
MutableSet	NoDefaultOptionalPattern
ReversibleSequenceSetSizedTextIOTupleUnion
ValuesViewcastno_type_checkno_type_check_decoratorT)      r   betac                   @      e Zd Zdd ZdS )	_Sentinelc                 C      dS )Nz
<sentinel> selfru   ru   T/var/www/html/AyurvedaChatbot/venv/lib/python3.10/site-packages/typing_extensions.py__repr__      z_Sentinel.__repr__N__name__
__module____qualname__ry   ru   ru   ru   rx   rs          rs   ro   
   c                 C   s   t | tjtjtjfS N)
isinstancetyping_GenericAlias_typesGenericAlias	UnionTypetru   ru   rx   _should_collect_from_parameters   s   r   ro   	   c                 C   s   t | tjtjfS r   )r   r   r   r   r   r   ru   ru   rx   r         c                 C   s   t | tjo	| j S r   )r   r   r   _specialr   ru   ru   rx   r         TKTVTT_co)	covariantT_contra)contravariant)ro      )r   c                       s(   e Zd Z fddZ fddZ  ZS )_AnyMetac                    s   | t u rtdt |S )Nz6typing_extensions.Any cannot be used with isinstance())r   	TypeErrorsuper__instancecheck__rw   obj	__class__ru   rx   r      s   z_AnyMeta.__instancecheck__c                    s   | t u rdS t  S )Nztyping_extensions.Any)r   r   ry   rv   r   ru   rx   ry      s   
z_AnyMeta.__repr__)r|   r}   r~   r   ry   __classcell__ru   ru   r   rx   r      s    r   c                       s    e Zd ZdZ fddZ  ZS )r   aq  Special type indicating an unconstrained type.
        - Any is compatible with every type.
        - Any assumed to have all methods.
        - All values assumed to be instances of Any.
        Note that all the above statements are true from the point of view of
        static type checkers. At runtime, Any should not be used with instance
        checks.
        c                    s*   | t u rtdt j| g|R i |S )NzAny cannot be instantiated)r   r   r   __new__clsargskwargsr   ru   rx   r      s   zAny.__new__)r|   r}   r~   __doc__r   r   ru   ru   r   rx   r      s    r   )	metaclassc                   @   rr   )_ExtensionsSpecialFormc                 C   s
   d| j  S Nztyping_extensions._namerv   ru   ru   rx   ry         
z_ExtensionsSpecialForm.__repr__Nr{   ru   ru   ru   rx   r      r   r   )_rootc              	   C   &   zd| _ W | S  ttfy   Y | S w )a  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. The decorator
        sets the ``__final__`` attribute to ``True`` on the decorated object
        to allow runtime introspection.
        T)	__final__AttributeErrorr   )fru   ru   rx   r-      s   r-   c                 C   
   t | S r   )r   r   )nameru   ru   rx   r3      r   r3   )ro   r      c                 C   s8   g }| D ]}t |tr||j q|| qt|S )zJAn internal helper for Literal creation: flatten Literals among parameters)r   _LiteralGenericAliasextend__args__appendtuple)
parametersparamspru   ru   rx   _flatten_literal_params  s   
r   c                 c   s    | D ]	}|t |fV  qd S r   )type)r   r   ru   ru   rx   _value_and_type_iter  s   r   c                   @   s   e Zd Zdd Zdd ZdS )r   c                 C   s2   t |tstS tt| j}tt|j}||kS r   )r   r   NotImplementedsetr   r   )rw   otherthese_args_dedupedother_args_dedupedru   ru   rx   __eq__  s
   
z_LiteralGenericAlias.__eq__c                 C   s   t tt| jS r   )hash	frozensetr   r   rv   ru   ru   rx   __hash__  r   z_LiteralGenericAlias.__hash__N)r|   r}   r~   r   r   ru   ru   ru   rx   r     s    r   c                   @   s"   e Zd ZdefddZdd ZdS )_LiteralFormdocc                 C   s   d| _ | | _| _d S )Nr6   )r   _docr   )rw   r   ru   ru   rx   __init__!  s   z_LiteralForm.__init__c                 C   s   t |ts|f}t|}tt|}zt|}W n	 ty!   Y n*w t|t|k rKg }|D ]}||v r@||d  |	| q.|rGJ |t|}t
| |S )Nr   )r   r   r   listr   r   r   lenr   remover   )rw   r   val_type_pairsdeduped_pairsnew_parameterspairru   ru   rx   __getitem__%  s&   


z_LiteralForm.__getitem__N)r|   r}   r~   strr   r   ru   ru   ru   rx   r      s    r   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.)r   r,   c                 C   s@   t | d| }z| t|j |j |jj< W tS  ty   Y tS w )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

        The overloads for a function can be retrieved at runtime using the
        get_overloads() function.
        __func__)getattr_overload_registryr}   r~   __code__co_firstlinenor   _overload_dummy)funcr   ru   ru   rx   r8   Z  s   r8   c                 C   sD   t | d| }|jtvrg S t|j }|j|vrg S t||j  S )z6Return all defined overloads for *func* as a sequence.r   )r   r}   r   r~   r   values)r   r   mod_dictru   ru   rx   r,     s   


c                   C   s   t   dS )z$Clear all overloads in the registry.N)r   clearru   ru   ru   rx   r(        r(   )r   r   r   rR   c                 C   s   |  do	| dS )N__)
startswithendswith)attrru   ru   rx   
_is_dunder  r   r   _SpecialGenericAliasc                       s<   e Zd Zdddd fdd
Zdd Zejd	d
 Z  ZS )r   TNru   )instr   defaultsc                   sL   t tju r|| _|| _t j||d||d n
t j||||d || _d S )NT)specialr   r   )r   r   )_special_generic_alias_baser   r   
__origin___nparamsr   r   	_defaults)rw   originnparamsr   r   r   r   ru   rx   r     s   

z_SpecialGenericAlias.__init__c                 C   sP   h d}t tju r|d t|s||v rt| || d S t| j|| d S )N>   _instr   r   r   r   )	r   r   r   addr   object__setattr__setattrr   )rw   r   valallowed_attrsru   ru   rx   r     s   

z _SpecialGenericAlias.__setattr__c              	      s   t |ts|f}d t fdd|D }| jr<t|| jk r<t|t| j | jkr<g || jt|| j d  R }t|}|| jkrz| jrTd| jt| j  }nt| j}| jsct|  dtd|| jkrldnd d	|  d
| d| | |S )Nz*Parameters to generic types must be types.c                 3       | ]	}t | V  qd S r   r   _type_check.0r   msgru   rx   	<genexpr>      z3_SpecialGenericAlias.__getitem__.<locals>.<genexpr>	at least  is not a generic classToo manyfew arguments for 	; actual , expected )r   r   r   r   r   r   r   	copy_with)rw   r   
actual_lenexpectedru   r   rx   r     s4   
"


z _SpecialGenericAlias.__getitem__)	r|   r}   r~   r   r   r   	_tp_cacher   r   ru   ru   r   rx   r     s
    
ro   )r      r   )r   r   r   )rL   r   rW   rX   r   rT   rg   rN   rM   rd   r   AbstractContextManagerAbstractAsyncContextManagerr   )zcollections.abc
contextlibtyping_extensions>   r   __match_args____protocol_attrs____non_callable_proto_members__c                 C   sh   t  }| jd d D ]'}|jdv rq
t|di }g |j|R D ]}|ds0|tvr0|| q q
|S )N>   rS   r:   __annotations___abc_)r   __mro__r|   r   __dict__r   _EXCLUDED_ATTRSr   )r   attrsbaseannotationsr   ru   ru   rx   _get_protocol_attrs  s   

r  c              	   C   s0   zt | jddW S  ttfy   Y d S w )Nr|   __main__)sys	_getframe	f_globalsgetr   
ValueErrordepthru   ru   rx   _caller  s
   r'  ro   rp   c                 C   s   t | dv S )zAllow instance and class checks for special stdlib modules.
        The abc and functools modules indiscriminately call isinstance() and
        issubclass() on the whole MRO of a user class, which may contain protocols.
        >   Nabc	functools)r'  r%  ru   ru   rx   _allow_reckless_class_checks  s   r+  c                 O   s   t | jr	tdd S )Nz Protocols cannot be instantiated)r   _is_protocolr   rw   r   r   ru   ru   rx   _no_init%  s   
r.  c                 C   s   t | ts	tddS )a  Raise TypeError if `arg` is not an instance of `type`
        in `issubclass(arg, <protocol>)`.

        In most cases, this is verified by type.__subclasscheck__.
        Checking it again unnecessarily would slow down issubclass() checks,
        so, we don't perform this check unless we absolutely have to.

        For various error paths, however,
        we want to ensure that *this* error message is shown to the user
        where relevant, rather than a typing.py-specific error message.
        z"issubclass() arg 1 must be a classN)r   r   r   argru   ru   rx   _type_check_issubclass_arg_1)  s   
r1  c                   @   sB   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdefddZ	dS )_ProtocolMetac                 K   s   |dkrt |dk rn-ttjht|@ r8|D ]!}|ttjttjhv s7|jt|j	g v s7t
|s7td|qtjj| |||fi |S )Nr:   r  z5Protocols can only inherit from other protocols, got )r   r:   r   r   r   rS   r|   _PROTO_ALLOWLISTr#  r}   r4   r   r)  ABCMetar   )mclsr   bases	namespacer   r  ru   ru   rx   r   C  s   z_ProtocolMeta.__new__c                 O   s8   t jj| g|R i | t| ddrt| | _d S d S )Nr,  F)r)  r4  r   r   r  r  r   ru   ru   rx   r   S  s   z_ProtocolMeta.__init__c                 C   s   | t u r
t| |S t| ddrCt sCt| dds!t| td| jrC| j	dt
u rCt| t| j}tdt|dd  d	tj| |S )
Nr,  F_is_runtime_protocolLInstance and class checks can only be used with @runtime_checkable protocols__subclasshook__zRProtocols with non-method members don't support issubclass(). Non-method members: r   r  .)r:   r   __subclasscheck__r   r+  r1  r   r  r  r#  _proto_hooksortedr   r)  r4  )r   r   non_method_attrsru   ru   rx   r<  X  s,   

z_ProtocolMeta.__subclasscheck__c              	   C   s   | t u r
t| |S t| ddstj| |S t| dds$t s$tdtj| |r-dS | jD ]"}zt	
||}W n tyE   Y  dS w |d u rR|| jvrR dS q0dS )Nr,  Fr8  r9  T)r:   r   r   r   r)  r4  r+  r   r  inspectgetattr_staticr   r  )r   instancer   r   ru   ru   rx   r   r  s.   

z_ProtocolMeta.__instancecheck__c                 C   s(   t j| |du rdS | tu o|tju S )NT)r)  r4  r   r:   r   r   r   ru   ru   rx   r     s   z_ProtocolMeta.__eq__returnc                 C   r   r   )r   r   r   ru   ru   rx   r     r   z_ProtocolMeta.__hash__N)
r|   r}   r~   r   r   r<  r   r   intr   ru   ru   ru   rx   r2  <  s     r2  c                 C   s   | j dds	tS | jD ]7}|jD ]-}||j v r'|j | d u r%t    S  nt|di }t|tjj	r>||v r>t
|r> nqt  S qdS )Nr,  Fr  T)r  r#  r   r  r  r   r   collectionsr)  r[   r4   )r   r   r   r  r  ru   ru   rx   r=    s&   


r=  c                       s0   e Zd ZejjZdZdZdZ fddZ	  Z
S )r:   ru   TFc                    sj   t  j|i | | jddstdd | jD | _d| jvr#t| _| jr1| j	t
j	u r3t| _	d S d S d S )Nr,  Fc                 s   s    | ]}|t u V  qd S r   )r:   r   bru   ru   rx   r         z-Protocol.__init_subclass__.<locals>.<genexpr>r:  )r   __init_subclass__r  r#  any	__bases__r,  r=  r:  r   r:   r.  r   r   ru   rx   rK    s   

zProtocol.__init_subclass__)r|   r}   r~   r   r:   r   	__slots__r,  r8  rK  r   ru   ru   r   rx   r:     s    r:   c                 C   s   t | tjrt| ddstd| d| _t| ts tj	dkrRt
 | _| jD ]*}z
tt| |d}W n tyH } z	td|d|d}~ww |sQ| j| q'| S )	aj  Mark a protocol class as a runtime protocol.

        Such protocol 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
        one trick ponies in collections.abc such as Iterable.

        For example::

            @runtime_checkable
            class Closable(Protocol):
                def close(self): ...

            assert isinstance(open('/some/file'), Closable)

        Warning: this will check only the presence of the required methods,
        not their type signatures!
        r,  Fz@@runtime_checkable can be only applied to protocol classes, got T)ro      r  Nz,Failed to determine whether protocol member z is a method member)
issubclassr   rS   r   r   r8  r   r2  r   version_infor   r  r  callable	Exceptionr   )r   r   is_callableeru   ru   rx   r=     s,   	

r=   ro   rO  c                   @   (   e Zd ZdZdZejdefddZdS )r#   z(An ABC with one abstract method __int__.ru   rD  c                 C      d S r   ru   rv   ru   ru   rx   __int__     zSupportsInt.__int__N)	r|   r}   r~   r   rN  r)  abstractmethodrF  rY  ru   ru   ru   rx   r#     
    r#   c                   @   rW  )r!   z*An ABC with one abstract method __float__.ru   rD  c                 C   rX  r   ru   rv   ru   ru   rx   	__float__"  rZ  zSupportsFloat.__float__N)	r|   r}   r~   r   rN  r)  r[  floatr]  ru   ru   ru   rx   r!     r\  r!   c                   @   rW  )r    z,An ABC with one abstract method __complex__.ru   rD  c                 C   rX  r   ru   rv   ru   ru   rx   __complex__+  rZ  zSupportsComplex.__complex__N)	r|   r}   r~   r   rN  r)  r[  complexr_  ru   ru   ru   rx   r    &  r\  r    c                   @   rW  )r   z*An ABC with one abstract method __bytes__.ru   rD  c                 C   rX  r   ru   rv   ru   ru   rx   	__bytes__4  rZ  zSupportsBytes.__bytes__N)	r|   r}   r~   r   rN  r)  r[  bytesra  ru   ru   ru   rx   r   /  r\  r   c                   @   s$   e Zd ZdZejdefddZdS )r"   ru   rD  c                 C   rX  r   ru   rv   ru   ru   rx   	__index__<  rZ  zSupportsIndex.__index__N)r|   r}   r~   rN  r)  r[  rF  rc  ru   ru   ru   rx   r"   8  s    r"   c                   @   rW  )r   z_
        An ABC with one abstract method __abs__ that is covariant in its return type.
        ru   rD  c                 C   rX  r   ru   rv   ru   ru   rx   __abs__G  rZ  zSupportsAbs.__abs__N)	r|   r}   r~   r   rN  r)  r[  r   rd  ru   ru   ru   rx   r   @  s
    r   c                   @   s.   e Zd ZdZdZejd	dedefddZ	dS )
r$   za
        An ABC with one abstract method __round__ that is covariant in its return type.
        ru   r   ndigitsrD  c                 C   rX  r   ru   )rw   re  ru   ru   rx   	__round__R  rZ  zSupportsRound.__round__N)r   )
r|   r}   r~   r   rN  r)  r[  rF  r   rf  ru   ru   ru   rx   r$   K  s
    r$   c                    s    fdd}|S )Nc                    sN   t jjdkr"t jdk r"t| t d}t| jd|}t| | S  | _	| S )Npypyr   )__call____mro_entries__ru   )
r   implementationr   rQ  staticmethodr   r|   r*  update_wrapperri  )r   cls_dictr   mro_entriesru   rx   innerX  s   z#_ensure_subclassable.<locals>.innerru   )ro  rp  ru   rn  rx   _ensure_subclassableW  s   rq  Fmodulec                 c   s    	 t | }|tu rt| }|r|d } n+d S |tu r$tV  t| \} n|tu r1tV  t| \} n|tu r>tV  t| \} nd S q)NTr   )r/   r%   r.   rG   rH   rF   )annotation_typeannotation_originannotation_argsru   ru   rx   _get_typeddict_qualifiers~  s&   
rv  c                   @   s,   e Zd ZdddddZeZdd ZeZdS )	_TypedDictMetaTFtotalclosedc                   s  |D ]}t |tur|tjurtdqtdd |D r"tjf}nd}t tdg |tR ||_j	dkr<|_	t
dsD|_i }d|v rO|d }	nd|v rZ|d d	}	ni }	d
 trm fdd|	 D }	n fdd|	 D }	t }
t }t }t }d}|D ]>}|j}||di  |
|dd ||dd ||dd ||dd |dd}|dur|}q|r|du rt}|rd|	v r|	d}tt|}t|v rtdt|v rtd|}||	 |	 D ]H\}}tt|}t|v r|
| nt|v r|| n|r$|
| n|| t|v r9|| || q|| || q|_t|
_t|_t|_t|_t
dsd|_ |_!|_"S )aI  Create new typed dict class object.

            This method is called when TypedDict is subclassed,
            or when TypedDict is instantiated. This way
            TypedDict supports all three syntax forms described in its docstring.
            Subclasses and instances of TypedDict return actual dictionaries.
            zHcannot inherit from both a TypedDict type and a non-TypedDict base classc                 s   s    | ]	}t |tjV  qd S r   )rP  r   rS   rH  ru   ru   rx   r     r   z)_TypedDictMeta.__new__.<locals>.<genexpr>ru   r:   __orig_bases__r  __annotate__r   z?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typec                    s$   i | ]\}}|t j| jd qS )rr  )r   r   r}   r   ntpr   tp_dictru   rx   
<dictcomp>  s    z*_TypedDictMeta.__new__.<locals>.<dictcomp>c                    s   i | ]\}}|t | qS ru   r   r~  r   ru   rx   r    s    N__required_keys____optional_keys____readonly_keys____mutable_keys____extra_items__z5Special key __extra_items__ does not support Requiredz8Special key __extra_items__ does not support NotRequired	__total__)#r   rw  r   rS   r   rL  r   dictr|   r~   hasattrr{  _TAKES_MODULEitemsr   r  updater#  rD   poprv  rG   rH   r   rF   discardr  r   r  r  r  r  r  
__closed__r  )r   r   r6  nsry  rz  r  generic_baser  own_annotationsrequired_keysoptional_keysreadonly_keysmutable_keysextra_items_type	base_dictbase_extra_items_typers  
qualifiersannotation_keyru   r  rx   r     s   
















z_TypedDictMeta.__new__c                 C      t d)Nz4TypedDict does not support instance and class checksr   rC  ru   ru   rx   r<       z _TypedDictMeta.__subclasscheck__N)r|   r}   r~   r   r  rh  r<  r   ru   ru   ru   rx   rw    s
    prw  r   ru   c                 C   s   t fS r   )
_TypedDictr6  ru   ru   rx   <lambda>  s    r  rx  c               K   s   |t u s|du r<|t u rd}nd}d|  d| d}| d| d }tj|td	d
 |dur9|dur9||d< d}|}n|rBtd|rUtjdkrMtdtjdtd	d
 dt|i}t }	|	durf|	|d< t	| d|||d}
t
f|
_|
S )aq  A simple typed namespace. At runtime it is equivalent to a plain dict.

        TypedDict creates a dictionary type such that a type checker will expect all
        instances to have a certain set of keys, where each key is
        associated with a value of a consistent type. This expectation
        is not checked at runtime.

        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 an additional equivalent form::

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

        By default, all keys must be present in a TypedDict. It is possible
        to override this by specifying totality::

            class Point2D(TypedDict, total=False):
                x: int
                y: int

        This means that a Point2D TypedDict can have any of the keys omitted. A type
        checker is only expected to support a literal False or True as the value of
        the total argument. True is the default, and makes all items defined in the
        class body be required.

        The Required and NotRequired special forms can also be used to mark
        individual keys as being required or not required::

            class Point2D(TypedDict):
                x: int  # the "x" key must always be present (Required is the default)
                y: NotRequired[int]  # the "y" key can be omitted

        See PEP 655 for more details on Required and NotRequired.
        N2Failing to pass a value for the 'fields' parameter(Passing `None` as the 'fields' parameter`z = TypedDict(z, {})`z is deprecated and will be disallowed in Python 3.15. To create a TypedDict class with 0 fields using the functional syntax, pass an empty dictionary, e.g. r;  r  
stacklevelFTrz  z@TypedDict takes either a dict or keyword arguments, but not bothr(  z$TypedDict takes no keyword argumentszThe kwargs-based syntax for TypedDict definitions is deprecated in Python 3.11, will be removed in Python 3.13, and may not be understood by third-party type checkers.r  r}   ru   rx  )_markerwarningswarnDeprecationWarningr   r   rQ  r  r'  rw  r   r{  )typenamefieldsry  rz  r   deprecated_thingexampledeprecation_msgr  rr  tdru   ru   rx   r     s@   0
c                 C   s"   t tdr| tju rdS t| tS )a  Check if an annotation is a TypedDict class

        For example::
            class Film(TypedDict):
                title: str
                year: int

            is_typeddict(Film)  # => True
            is_typeddict(Union[list, str])  # => False
        r   F)r  r   r   r   _TYPEDDICT_TYPESr  ru   ru   rx   r5   l  s   
r5   r'   c                C      | S )a  Assert (to the type checker) that the value is of the given type.

        When the type checker encounters a call to assert_type(), it
        emits an error if the value is not of the specified type::

            def greet(name: str) -> None:
                assert_type(name, str)  # ok
                assert_type(name, int)  # type checker error

        At runtime this returns the first argument unchanged and otherwise
        does nothing.
        ru   )r   typru   ru   rx   r'     s   rF   c                 C   s  t | tr
t| jS t| dr| jtttfv rt| jd S t | t	j
r:tdd | jD }|| jkr5| S | |S ttdr]t | tjr]tdd | jD }|| jkrV| S t| j|S ttdrt | tjrtdd | jD }|| jkry| S ttj|S | S )	z=Strips Annotated, Required and NotRequired from a given type.r   r   c                 s       | ]}t |V  qd S r   _strip_extrasr   aru   ru   rx   r     rJ  z _strip_extras.<locals>.<genexpr>r   c                 s   r  r   r  r  ru   ru   rx   r     rJ  r   c                 s   r  r   r  r  ru   ru   rx   r     rJ  )r   _AnnotatedAliasr  r   r  rG   rH   rF   r   r   r   r   r	  r   r   r   r*  reduceoperatoror_)r   stripped_argsru   ru   rx   r    s(   





r  c                 C   sH   t tdrtj| ||dd}n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, ...]', 'Required[T]' or 'NotRequired[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.
        r%   T)globalnslocalnsinclude_extras)r  r  c                 S   s   i | ]	\}}|t |qS ru   r  )r   kr   ru   ru   rx   r    s    z"get_type_hints.<locals>.<dictcomp>)r  r   r2   r  )r   r  r  r  hintru   ru   rx   r2     s   
 r2   r%   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 )r  aK  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 r   )r   r  __metadata__r   r   r   )rw   r   metadatar   ru   rx   r     s
   


z_AnnotatedAlias.__init__c                 C   s$   t |dksJ |d }t|| jS )Nr   r   )r   r  r  )rw   r   new_typeru   ru   rx   r	    s   z_AnnotatedAlias.copy_withc                 C   s,   dt | j dddd | jD  dS )Nztyping_extensions.Annotated[, c                 s   r  r   )reprr  ru   ru   rx   r     rJ  z+_AnnotatedAlias.__repr__.<locals>.<genexpr>])r   
_type_reprr   joinr  rv   ru   ru   rx   ry     s   z_AnnotatedAlias.__repr__c                 C   s   t jt| jg| jR ffS r   )r  getitemr%   r   r  rv   ru   ru   rx   
__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   r  r   r   r  rw   r   ru   ru   rx   r     s
   
z_AnnotatedAlias.__eq__c                 C      t | j| jfS r   )r   r   r  rv   ru   ru   rx   r        z_AnnotatedAlias.__hash__)r|   r}   r~   r   r   r	  ry   r  r   r   r   ru   ru   r   rx   r    s    r  c                   @   s2   e Zd ZdZdZdd Zejdd Zdd Z	d	S )
r%   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()]
        ru   c                 O   r  )Nz&Type Annotated cannot be instantiated.r  r   ru   ru   rx   r   *     zAnnotated.__new__c                 C   sn   t |trt|dk rtdttf}t|d |v r |d }n
d}t|d |}t|dd  }t	||S )Nr  zUAnnotated[...] should be used with at least two arguments (a type and an annotation).r   z$Annotated[t, ...]: t must be a type.r   )
r   r   r   r   r   r   r/   r   r   r  )r   r   allowed_special_formsr   r   r  ru   ru   rx   __class_getitem__-  s   

zAnnotated.__class_getitem__c                 O   s   t d| j d)NCannot subclass z
.Annotated)r   r}   r   ru   ru   rx   rK  <  s   zAnnotated.__init_subclass__N)
r|   r}   r~   r   rN  r   r   r  r  rK  ru   ru   ru   rx   r%     s     
)_BaseGenericAlias)r   c                 C   s>   t | trtS t | tjttttfr| j	S | tj
u rtj
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   r  r%   r   r   _typing_GenericAliasr  r   r	   r   rS   r  ru   ru   rx   r/   T  s   

r/   c                 C   s|   t | tr| jg| jR S t | tjtfr<t| ddrdS | j}t	| t
jju r:|d tur:t|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)
        r   Fru   r   Nr  )r   r  r   r  r   r   r  r   r   r/   rG  r)  rL   Ellipsisr   )r  resru   ru   rx   r.   l  s   
r.   r?   c                 C      t |  d)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.
         is not subscriptabler  rw   r   ru   ru   rx   r?     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.ra   c                   @   rr   )NoDefaultTypeMetac                 C   s   t d|d| j)Nzcannot set z attribute of immutable type r   r|   )r   r   valueru   ru   rx   r     s   zNoDefaultTypeMeta.__setattr__N)r|   r}   r~   r   ru   ru   ru   rx   r    r   r  c                   @   s,   e Zd ZdZdZdd Zdd Zdd Zd	S )
NoDefaultTypez$The type of the NoDefault singleton.ru   c                 C   s   t  dp
t| S Nra   )globalsr#  r   r   rE  ru   ru   rx   r     s   zNoDefaultType.__new__c                 C   rt   )Nztyping_extensions.NoDefaultru   rv   ru   ru   rx   ry     rz   zNoDefaultType.__repr__c                 C   rt   r  ru   rv   ru   ru   rx   r    rz   zNoDefaultType.__reduce__N)r|   r}   r~   r   rN  r   ry   r  ru   ru   ru   rx   r    s    r  c                    s    fdd| _  | _d S )Nc                      s    t uS r   )ra   ru   defaultru   rx   r    s    z_set_default.<locals>.<lambda>)has_default__default__)
type_paramr  ru   r  rx   _set_default  s   
r  c                 C   s    t dd}|dkr|| _d S d S )Nro   r%  r  )r'  r}   )typevarlikedef_modru   ru   rx   _set_module  s   

r  c                   @   s   e Zd ZdZdZeZdS )_DefaultMixinzMixin for TypeVarLike defaults.ru   N)r|   r}   r~   r   rN  r  r   ru   ru   ru   rx   r    s    r  c                   @   s   e Zd ZdedefddZdS )_TypeVarLikeMeta_TypeVarLikeMeta__instancerD  c                 C   s   t || jS r   )r   _backported_typevarlike)r   r  ru   ru   rx   r        z"_TypeVarLikeMeta.__instancecheck__N)r|   r}   r~   r   boolr   ru   ru   ru   rx   r    s    r  )r   c                   @   s6   e Zd ZdZejZdddeddddZd
dd	Z	dS )r   zType variable.NF)boundr   r   r  infer_variancec          	         s   t tdrtj|g|R ||||d ntj|g|R |||d |r-|s)|r-td| _t | t   fdd}| _ S )Nr@   r  r   r   r  r  r   r   z1Variance cannot be specified with infer_variance.c                    s,      r| j t|kr| jf7 }|S r   )r  __parameters__indexr   r  )aliasr   typevarru   rx   _tvar_prepare_subst  s
   z,TypeVar.__new__.<locals>._tvar_prepare_subst)r  r   r   r$  __infer_variance__r  r  __typing_prepare_subst__)	r   r   r  r   r   r  r  constraintsr  ru   r  rx   r     s    


zTypeVar.__new__rD  c                 C      t dt d)Ntype 'z(.TypeVar' is not an acceptable base typer  rE  ru   ru   rx   rK    r  zTypeVar.__init_subclass__rD  N)
r|   r}   r~   r   r   r   r  ra   r   rK  ru   ru   ru   rx   r     s    r   r   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.ru   c                 C   r  r   ru   rv   ru   ru   rx   __copy__  rz   z_Immutable.__copy__c                 C   r  r   ru   )rw   memoru   ru   rx   __deepcopy__  rz   z_Immutable.__deepcopy__N)r|   r}   r~   r   rN  r  r  ru   ru   ru   rx   r    s
    r  c                   @   (   e Zd ZdZdd Zdd Zdd ZdS )	r   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   
   || _ d S r   r   rw   r   ru   ru   rx   r   !  r   zParamSpecArgs.__init__c                 C      | j j dS )Nz.argsr   r|   rv   ru   ru   rx   ry   $     zParamSpecArgs.__repr__c                 C      t |tstS | j|jkS r   )r   r   r   r   r  ru   ru   rx   r   '     
zParamSpecArgs.__eq__Nr|   r}   r~   r   r   ry   r   ru   ru   ru   rx   r     
    c                   @   r  )	r	   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   r  r   r	  r
  ru   ru   rx   r   8  r   zParamSpecKwargs.__init__c                 C   r  )Nz.kwargsr  rv   ru   ru   rx   ry   ;  r  zParamSpecKwargs.__repr__c                 C   r  r   )r   r	   r   r   r  ru   ru   rx   r   >  r  zParamSpecKwargs.__eq__Nr  ru   ru   ru   rx   r	   ,  r  r	   )r   r   c                   @   s6   e Zd ZdZejZddddedddZd
dd	Z	dS )r   zParameter specification.NFr  r   r   r  r  c                   s`   t tdrtj|||||d ntj||||d | _t | t   fdd}| _ S )Nr@   r  r  c                    s   | j }| }|t|kr  rg | j}|t|kr&td|  t|dkr>t|d s>|dks9J |f}|S t|| t	r\g |d | t
|| ||d d  R }|S )NToo few arguments for r   r   )r  r  r   r  r  r   r   _is_param_exprr   r   r   )r  r   r   i	paramspecru   rx   _paramspec_prepare_substb  s   
.z3ParamSpec.__new__.<locals>._paramspec_prepare_subst)r  r   r   r  r  r  r  )r   r   r  r   r   r  r  r  ru   r  rx   r   P  s    

zParamSpec.__new__rD  c                 C   r   )Nr  z*.ParamSpec' is not an acceptable base typer  rE  ru   ru   rx   rK  u  r  zParamSpec.__init_subclass__r  )
r|   r}   r~   r   r   r   r  ra   r   rK  ru   ru   ru   rx   r   K  s    %c                   @   sl   e Zd ZdZejZedd Zedd Z	dddde
dd	d
Zdd Zdd Zdd Zdd Zdd Zd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      t | S r   )r   rv   ru   ru   rx   r     r  zParamSpec.argsc                 C   r  r   )r	   rv   ru   ru   rx   r     r  zParamSpec.kwargsNFr  c                C   st   t | | g || _t|| _t|| _t|| _|r#t|d| _	nd | _	t
| | t }|dkr8|| _d S d S )NzBound must be a type.r  )r   r   r|   r  __covariant____contravariant__r  r   r   	__bound__r  r'  r}   )rw   r   r  r   r   r  r  r  ru   ru   rx   r     s   



zParamSpec.__init__c                 C   s2   | j rd}n| jrd}n| jrd}nd}|| j S )N +-~)r  r  r  r|   )rw   prefixru   ru   rx   ry     s   
zParamSpec.__repr__c                 C   r   r   r   r   rv   ru   ru   rx   r     r   zParamSpec.__hash__c                 C      | |u S r   ru   r  ru   ru   rx   r     r  zParamSpec.__eq__c                 C      | j S r   r|   rv   ru   ru   rx   r       zParamSpec.__reduce__c                 O   rX  r   ru   r-  ru   ru   rx   rh    rz   zParamSpec.__call__)r|   r}   r~   r   r   r   r   propertyr   r   ra   r   ry   r   r   r  rh  ru   ru   ru   rx   r   |  s    /

r   c                       sJ   e Zd ZejZdZ fddZdd Zdd Z	dd	 Z
ed
d Z  ZS )_ConcatenateGenericAliasFc                    s   t  | || _|| _d S r   )r   r   r   r   )rw   r   r   r   ru   rx   r     s   
z!_ConcatenateGenericAlias.__init__c                    s2   t j  | j dd fdd| jD  dS )N[r  c                 3   s    | ]} |V  qd S r   ru   )r   r0  r  ru   rx   r     rJ  z4_ConcatenateGenericAlias.__repr__.<locals>.<genexpr>r  )r   r  r   r  r   rv   ru   r*  rx   ry     s   z!_ConcatenateGenericAlias.__repr__c                 C   r  r   )r   r   r   rv   ru   ru   rx   r     r  z!_ConcatenateGenericAlias.__hash__c                 O   rX  r   ru   r-  ru   ru   rx   rh    rz   z!_ConcatenateGenericAlias.__call__c                 C   s   t dd | jD S )Nc                 s   s$    | ]}t |tjtfr|V  qd S r   )r   r   r   r   )r   r  ru   ru   rx   r     s    
z:_ConcatenateGenericAlias.__parameters__.<locals>.<genexpr>)r   r   rv   ru   ru   rx   r    s   z'_ConcatenateGenericAlias.__parameters__)r|   r}   r~   r   r   r   r   r   ry   r   rh  r'  r  r   ru   ru   r   rx   r(    s    r(  c                    sZ   |dkrt dt|ts|f}t|d tst dd t fdd|D }t| |S )Nru   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   r   r   r   r   r   ru   rx   r     r   z'_concatenate_getitem.<locals>.<genexpr>)r   r   r   r   r(  r  ru   r   rx   _concatenate_getitem  s   

r+  c                 C   
   t | |S )&  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+  r  ru   ru   rx   r     s   
c                   @   rr   )_ConcatenateFormc                 C   r,  r   r.  r  ru   ru   rx   r   )  r   z_ConcatenateForm.__getitem__Nr|   r}   r~   r   ru   ru   ru   rx   r/  (  r   r/  r-  rA   c                 C       t ||  d}t | |fS )	  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).
         accepts only a single type.r   r   r   rw   r   itemru   ru   rx   rA   >  s   ,c                   @   rr   )_TypeGuardFormc                 C   "   t || j d}t | |fS Nz accepts only a single typer   r   r   r   r5  ru   ru   rx   r   o     
z_TypeGuardForm.__getitem__Nr0  ru   ru   ru   rx   r7  n  r   r7  r2  rB   c                 C   r1  )z  Special typing form used to annotate the return type of a user-defined
        type narrower function.  ``TypeIs`` only accepts a single type argument.
        At runtime, functions marked this way should return a boolean.

        ``TypeIs`` 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 ``TypeIs[...]`` as its
        return type to alert static type checkers to this intention.

        Using  ``-> TypeIs`` 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 intersection of the type inside ``TypeGuard`` and the argument's
        previously known type.

        For example::

            def is_awaitable(val: object) -> TypeIs[Awaitable[Any]]:
                return hasattr(val, '__await__')

            def f(val: Union[int, Awaitable[int]]) -> int:
                if is_awaitable(val):
                    assert_type(val, Awaitable[int])
                else:
                    assert_type(val, int)

        ``TypeIs`` also works with type variables.  For more information, see
        PEP 742 (Narrowing types with TypeIs).
        r3  r4  r5  ru   ru   rx   rB     s   &c                   @   rr   )_TypeIsFormc                 C   r8  r9  r:  r5  ru   ru   rx   r     r;  z_TypeIsForm.__getitem__Nr0  ru   ru   ru   rx   r=    r   r=  r<  c                   @   sn   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jdd ZdS )_SpecialForm)r   r   _getitemc                 C   s   || _ |j| _|j| _d S r   )r?  r|   r   r   rw   r  ru   ru   rx   r     s   z_SpecialForm.__init__c                 C   s   |dv r| j S t|)N>   r|   r~   )r   r   )rw   r6  ru   ru   rx   __getattr__  s   z_SpecialForm.__getattr__c                 C      t d| )Nr  r  )rw   r6  ru   ru   rx   ri    r  z_SpecialForm.__mro_entries__c                 C   s   d| j  S r   r   rv   ru   ru   rx   ry     r  z_SpecialForm.__repr__c                 C   r$  r   r   rv   ru   ru   rx   r    r&  z_SpecialForm.__reduce__c                 O   rB  )NzCannot instantiate r  rw   r   kwdsru   ru   rx   rh    r  z_SpecialForm.__call__c                 C      t j| |f S r   r   rj   r  ru   ru   rx   __or__  r  z_SpecialForm.__or__c                 C      t j|| f S r   rF  r  ru   ru   rx   __ror__  r  z_SpecialForm.__ror__c                 C   r  )Nz! cannot be used with isinstance()r  r   ru   ru   rx   r     r  z_SpecialForm.__instancecheck__c                 C   r  )Nz! cannot be used with issubclass()r  )rw   r   ru   ru   rx   r<  "  r  z_SpecialForm.__subclasscheck__c                 C   s   |  | |S r   )r?  r  ru   ru   rx   r   %  r   z_SpecialForm.__getitem__N)r|   r}   r~   rN  r   rA  ri  ry   r  rh  rG  rI  r   r<  r   r  r   ru   ru   ru   rx   r>    s    r>  r   c                 C   r  )aD  Represents an arbitrary literal string.

        Example::

          from typing_extensions import LiteralString

          def query(sql: LiteralString) -> ...:
              ...

          query("SELECT * FROM table")  # ok
          query(f"SELECT * FROM {input()}")  # not ok

        See PEP 675 for details.

        r  r  rw   r   ru   ru   rx   r   -  s   r
   c                 C   r  )zUsed to spell the type of "self" in classes.

        Example::

          from typing import Self

          class ReturnsSelf:
              def parse(self, data: bytes) -> Self:
                  ...
                  return self

        r  r  rJ  ru   ru   rx   r
   D  s   rD   c                 C   r  )a  The bottom type, a type that has no members.

        This can be used to define a function that should never be
        called, or a function that never returns::

            from typing_extensions import Never

            def never_call_me(arg: Never) -> None:
                pass

            def int_or_str(arg: int | str) -> None:
                never_call_me(arg)  # type checker error
                match arg:
                    case int():
                        print("It's an int")
                    case str():
                        print("It's a str")
                    case _:
                        never_call_me(arg)  # ok, arg is of type Never

        r  r  rJ  ru   ru   rx   rD   Y  s   rG   c                 C   r8  )  A special typing construct to mark a key of a total=False TypedDict
        as required. For example:

            class Movie(TypedDict, total=False):
                title: Required[str]
                year: int

            m = Movie(
                title='The Matrix',  # typechecker error if key is omitted
                year=1999,
            )

        There is no runtime checking that a required key is actually provided
        when instantiating a related TypedDict.
        r3  r:  r5  ru   ru   rx   rG   x  s   c                 C   r8  )`  A special typing construct to mark a key of a TypedDict as
        potentially missing. For example:

            class Movie(TypedDict):
                title: str
                year: NotRequired[int]

            m = Movie(
                title='The Matrix',  # typechecker error if key is omitted
                year=1999,
            )
        r3  r:  r5  ru   ru   rx   rH     s   rH   c                   @   rr   )_RequiredFormc                 C   r8  Nr3  r:  r5  ru   ru   rx   r     r;  z_RequiredForm.__getitem__Nr0  ru   ru   ru   rx   rM    r   rM  rK  rL  c                 C   r8  )a  A special typing construct to mark an item of a TypedDict as read-only.

        For example:

            class Movie(TypedDict):
                title: ReadOnly[str]
                year: int

            def mutate_movie(m: Movie) -> None:
                m["year"] = 1992  # allowed
                m["title"] = "The Matrix"  # typechecker error

        There is no runtime checking for this property.
        r3  r:  r5  ru   ru   rx   rF     s   c                   @   rr   )_ReadOnlyFormc                 C   r8  rN  r:  r5  ru   ru   rx   r     r;  z_ReadOnlyForm.__getitem__Nr0  ru   ru   ru   rx   rO    r   rO  a  A special typing construct to mark a key of a TypedDict as read-only.

        For example:

            class Movie(TypedDict):
                title: ReadOnly[str]
                year: int

            def mutate_movie(m: Movie) -> None:
                m["year"] = 1992  # allowed
                m["title"] = "The Matrix"  # typechecker error

        There is no runtime checking for this propery.
        a  Type unpack operator.

The type unpack operator takes the child types from some container type,
such as `tuple[int, str]` or a `TypeVarTuple`, and 'pulls them out'. For
example:

  # For some generic class `Foo`:
  Foo[Unpack[tuple[int, str]]]  # Equivalent to Foo[int, str]

  Ts = TypeVarTuple('Ts')
  # Specifies that `Bar` is generic in an arbitrary number of types.
  # (Think of `Ts` as a tuple of an arbitrary number of individual
  #  `TypeVar`s, which the `Unpack` is 'pulling out' directly into the
  #  `Generic[]`.)
  class Bar(Generic[Unpack[Ts]]): ...
  Bar[int]  # Valid
  Bar[int, str]  # Also valid

From Python 3.11, this can also be done using the `*` operator:

    Foo[*tuple[int, str]]
    class Bar(Generic[*Ts]): ...

The operator can also be used along with a `TypedDict` to annotate
`**kwargs` in a function signature. For instance:

  class Movie(TypedDict):
    name: str
    year: int

  # This function expects two keyword arguments - *name* of type `str` and
  # *year* of type `int`.
  def foo(**kwargs: Unpack[Movie]): ...

Note that there is only some runtime checking of this operator. Not
everything the runtime allows may be accepted by static type checkers.

For more information, see PEP 646 and PEP 692.
c                 C   s   t | tu S r   )r/   r   r   ru   ru   rx   
_is_unpack!	  r  rQ  c                       s   e Zd Z fddZ  ZS )_UnpackSpecialFormc                    s   t  | t| _d S r   )r   r   _UNPACK_DOCr   r@  r   ru   rx   r   &	  s   
z_UnpackSpecialForm.__init__)r|   r}   r~   r   r   ru   ru   r   rx   rR  %	  s    rR  c                   @   s   e Zd ZejZedd ZdS )_UnpackAliasc                 C   sV   | j tu sJ t| jdksJ | j\}t|tjtjfr)|j t	ur&t
d|jS d S )Nr   z*Unpack[...] must be used with a tuple type)r   r   r   r   r   r   r   r   r   r   r   )rw   r0  ru   ru   rx   __typing_unpacked_tuple_args__-	  s   
z+_UnpackAlias.__typing_unpacked_tuple_args__N)r|   r}   r~   r   r   r   r'  rU  ru   ru   ru   rx   rT  *	  s    rT  c                 C       t || j d}t| |fS rN  r   r   r   rT  r5  ru   ru   rx   r   8	  s   r   c                 C   
   t | tS r   r   rT  rP  ru   ru   rx   rQ  =	  r   c                   @   s   e Zd ZejZdS )rT  N)r|   r}   r~   r   r   r   ru   ru   ru   rx   rT  A	  s    
c                   @   rr   )_UnpackFormc                 C   rV  rN  rW  r5  ru   ru   rx   r   E	  s   
z_UnpackForm.__getitem__Nr0  ru   ru   ru   rx   rZ  D	  r   rZ  c                 C   rX  r   rY  rP  ru   ru   rx   rQ  L	  r   )r   r   c                  G   sL   g }| D ]}t |dd }|d ur|r|d du s|| q|| q|S )NrU  r  .)r   r   r   )r   newargsr0  subargsru   ru   rx   _unpack_argsU	  s   r]  c                   @   s,   e Zd ZdZejZedddZdd Z	dS )r   zType variable tuple.r  c                   s2   t | t | t   fdd}| _ S )Nc                    s  | j }| }||d d  D ]}t|trtd|  qt|}t|}|}|| d }d }	d }
t|D ]+\}}t|tsbt|dd }|rbt|dkrb|d du rb|	d ur\td|}	|d }
q7|	d urvt	||	}t	|||	 d }n|| |krtd	|  d
| d|d  ||| kr 
 rt j}n||||  }g |d | |
g||  ||
g|| | | d  ||| d  R S )Nr   z(More than one TypeVarTuple parameter in rU  r  r  .z6More than one unpacked arbitrary-length tuple argumentr   r  r  z, expected at least )r  r  r   r   r   r   	enumerater   r   minr  r]  r  )r  r   r   typevartuple_indexparamalenplenleftrightvar_tuple_indexfillargr  r0  r\  replacementtvtru   rx   _typevartuple_prepare_substj	  s`   





z9TypeVarTuple.__new__.<locals>._typevartuple_prepare_subst)r   r   r  r  r  )r   r   r  rk  ru   ri  rx   r   e	  s   

-zTypeVarTuple.__new__c                 O   r  )N&Cannot subclass special typing classesr  rC  ru   ru   rx   rK  	  r  TypeVarTuple.__init_subclass__N)
r|   r}   r~   r   r   r   r  ra   r   rK  ru   ru   ru   rx   r   `	  s
    5c                   @   sT   e Zd ZdZejZdd ZedddZ	dd Z
d	d
 Zdd Zdd Zdd ZdS )r   a  Type variable tuple.

        Usage::

            Ts = TypeVarTuple('Ts')

        In the same way that a normal type variable is a stand-in for a single
        type such as ``int``, a type variable *tuple* is a stand-in for a *tuple*
        type such as ``Tuple[int, str]``.

        Type variable tuples can be used in ``Generic`` declarations.
        Consider the following example::

            class Array(Generic[*Ts]): ...

        The ``Ts`` type variable tuple here behaves like ``tuple[T1, T2]``,
        where ``T1`` and ``T2`` are type variables. To use these type variables
        as type parameters of ``Array``, we must *unpack* the type variable tuple using
        the star operator: ``*Ts``. The signature of ``Array`` then behaves
        as if we had simply written ``class Array(Generic[T1, T2]): ...``.
        In contrast to ``Generic[T1, T2]``, however, ``Generic[*Shape]`` allows
        us to parameterise the class with an *arbitrary* number of type parameters.

        Type variable tuples can be used anywhere a normal ``TypeVar`` can.
        This includes class definitions, as shown above, as well as function
        signatures and variable annotations::

            class Array(Generic[*Ts]):

                def __init__(self, shape: Tuple[*Ts]):
                    self._shape: Tuple[*Ts] = shape

                def get_shape(self) -> Tuple[*Ts]:
                    return self._shape

            shape = (Height(480), Width(640))
            x: Array[Height, Width] = Array(shape)
            y = abs(x)  # Inferred type is Array[Height, Width]
            z = x + x   #        ...    is Array[Height, Width]
            x.get_shape()  #     ...    is tuple[Height, Width]

        c                 c   s    | j V  d S r   )__unpacked__rv   ru   ru   rx   __iter__	  s   zTypeVarTuple.__iter__r  c                C   s4   || _ t| | t }|dkr|| _t|  | _d S )Nr  )r|   r  r   r'  r}   r   rn  )rw   r   r  r  ru   ru   rx   r   	  s   zTypeVarTuple.__init__c                 C   r$  r   r%  rv   ru   ru   rx   ry   	  r&  zTypeVarTuple.__repr__c                 C   r   r   r"  rv   ru   ru   rx   r   	  r   zTypeVarTuple.__hash__c                 C   r#  r   ru   r  ru   ru   rx   r   	  r  zTypeVarTuple.__eq__c                 C   r$  r   r%  rv   ru   ru   rx   r  	  r&  zTypeVarTuple.__reduce__c                 O   s   d|vrt dd S )Nr   rl  r  rC  ru   ru   rx   rK  	  s   rm  N)r|   r}   r~   r   r   r   r   ro  ra   r   ry   r   r   r  rK  ru   ru   ru   rx   r   	  s    ,r;   r   rD  c                C   s   t dt| jtjd | S )a  Reveal the inferred type of a variable.

        When a static type checker encounters a call to ``reveal_type()``,
        it will emit the inferred type of the argument::

            x: int = 1
            reveal_type(x)

        Running a static type checker (e.g., ``mypy``) on this example
        will produce output similar to 'Revealed type is "builtins.int"'.

        At runtime, the function prints the runtime type of the
        argument and returns it unchanged.

        zRuntime type is )file)printr   r|   r   stderrrP  ru   ru   rx   r;   	  s   _ASSERT_NEVER_REPR_MAX_LENGTHd   r&   r0  c                C   s2   t | }t|tkr|dt d }td| )a1  Assert to the type checker that a line of code is unreachable.

        Example::

            def int_or_str(arg: int | str) -> None:
                match arg:
                    case int():
                        print("It's an int")
                    case str():
                        print("It's a str")
                    case _:
                        assert_never(arg)

        If a type checker finds that a call to assert_never() is
        reachable, it will emit an error.

        At runtime, this throws an exception when called.

        Nz...z*Expected code to be unreachable, but got: )r  r   rs  AssertionError)r0  r  ru   ru   rx   r&   
  s   )
eq_defaultorder_defaultkw_only_defaultfrozen_defaultfield_specifiersrv  rw  rx  ry  rz  .r   c                    s    fdd}|S )a  Decorator that marks a function, class, or metaclass as providing
        dataclass-like behavior.

        Example:

            from typing_extensions import dataclass_transform

            _T = TypeVar("_T")

            # Used on a decorator function
            @dataclass_transform()
            def create_model(cls: type[_T]) -> type[_T]:
                ...
                return cls

            @create_model
            class CustomerModel:
                id: int
                name: str

            # Used on a base class
            @dataclass_transform()
            class ModelBase: ...

            class CustomerModel(ModelBase):
                id: int
                name: str

            # Used on a metaclass
            @dataclass_transform()
            class ModelMeta(type): ...

            class ModelBase(metaclass=ModelMeta): ...

            class CustomerModel(ModelBase):
                id: int
                name: str

        Each of the ``CustomerModel`` classes defined in this example will now
        behave similarly to a dataclass created with the ``@dataclasses.dataclass``
        decorator. For example, the type checker will synthesize an ``__init__``
        method.

        The arguments to this decorator can be used to customize this behavior:
        - ``eq_default`` indicates whether the ``eq`` parameter is assumed to be
          True or False if it is omitted by the caller.
        - ``order_default`` indicates whether the ``order`` parameter is
          assumed to be True or False if it is omitted by the caller.
        - ``kw_only_default`` indicates whether the ``kw_only`` parameter is
          assumed to be True or False if it is omitted by the caller.
        - ``frozen_default`` indicates whether the ``frozen`` parameter is
          assumed to be True or False if it is omitted by the caller.
        - ``field_specifiers`` specifies a static list of supported classes
          or functions that describe fields, similar to ``dataclasses.field()``.

        At runtime, this decorator records its arguments in the
        ``__dataclass_transform__`` attribute on the decorated object.

        See PEP 681 for details.

        c                    s    d| _ | S )N)rv  rw  rx  ry  rz  r   )__dataclass_transform__)	cls_or_fnrv  rz  ry  rx  r   rw  ru   rx   	decorators
  s   z&dataclass_transform.<locals>.decoratorru   )rv  rw  rx  ry  rz  r   r~  ru   r}  rx   r)   *
  s   I
r)   r9   _F)r  c             	   C   r   )aH  Indicate that a method is intended to override a method in a base class.

        Usage:

            class Base:
                def method(self) -> None:
                    pass

            class Child(Base):
                @override
                def method(self) -> None:
                    super().method()

        When this decorator is applied to a method, the type checker will
        validate that it overrides a method with the same name on a base class.
        This helps prevent bugs that may occur when a base class is changed
        without an equivalent change to a child class.

        There is no runtime checking of these properties. The decorator
        sets the ``__override__`` attribute to ``True`` on the decorated object
        to allow runtime introspection.

        See PEP 698 for details.

        T)__override__r   r   r/  ru   ru   rx   r9   
  s   r*   _Tc                	   @   sP   e Zd ZdZedddedejeje	  de
ddfd	d
ZdedefddZdS )r*   a  Indicate that a class, function or overload is deprecated.

        When this decorator is applied to an object, the type checker
        will generate a diagnostic on usage of the deprecated object.

        Usage:

            @deprecated("Use B instead")
            class A:
                pass

            @deprecated("Use g instead")
            def f():
                pass

            @overload
            @deprecated("int support is deprecated")
            def g(x: int) -> int: ...
            @overload
            def g(x: str) -> int: ...

        The warning specified by *category* will be emitted at runtime
        on use of deprecated objects. For functions, that happens on calls;
        for classes, on instantiation and on creation of subclasses.
        If the *category* is ``None``, no warning is emitted at runtime.
        The *stacklevel* determines where the
        warning is emitted. If it is ``1`` (the default), the warning
        is emitted at the direct caller of the deprecated object; if it
        is higher, it is emitted further up the stack.
        Static type checker behavior is not affected by the *category*
        and *stacklevel* arguments.

        The deprecation message passed to the decorator is saved in the
        ``__deprecated__`` attribute on the decorated object.
        If applied to an overload, the decorator
        must be after the ``@overload`` decorator for the attribute to
        exist on the overload as returned by ``get_overloads()``.

        See PEP 702 for details.

        r   categoryr  messager  r  rD  Nc               C   s4   t |tstdt|j|| _|| _|| _d S )Nz2Expected an object of type str for 'message', not )r   r   r   r   r|   r  r  r  )rw   r  r  r  ru   ru   rx   r   
  s   

zdeprecated.__init__r0  c                   s0  | j | j| jd u r _ S t trsdd l}ddlm}  j	|
 fdd}t| _	 jt|rWj|
fdd}t| _n|
fdd}| _  _|_|_ S t rdd l}|
  fdd	}  _|_|S td
 )Nr   )
MethodTypec                    sh   |  u rt jd d tjur| g|R i |S | jtju r0|s(|r0t| j d| S )Nr   r  z() takes no arguments)r  r  r   r   r   r   r|   r   )r0  r  r   original_newr  ru   rx   r   
  s   
z$deprecated.__call__.<locals>.__new__c                     "   t j d d | i |S Nr   r  r  r  r   r   r  r   original_init_subclassr  ru   rx   rK       z.deprecated.__call__.<locals>.__init_subclass__c                     r  r  r  r  r  ru   rx   rK    r  c                     s"   t jd d  | i |S r  r  r  )r0  r  r   r  ru   rx   wrapper"  r  z$deprecated.__call__.<locals>.wrapperzY@deprecated decorator with non-None category must be applied to a class or callable, not )r  r  r  __deprecated__r   r   r*  typesr  r   wrapsrk  rK  r   classmethodrR  r   )rw   r0  r*  r  r   rK  r  ru   )r0  r  r   r  r  r  rx   rh  
  sH   


zdeprecated.__call__)r|   r}   r~   r   r  r   r   rb   r   WarningrF  r   r  rh  ru   ru   ru   rx   r*   
  s    .
c                 C   s&  |s	t |  d|tu r!t| dr| jst |  dt| j}t|}||kr|}t| drodd | jD }tdd |D }|dkrM||| krMdS ||k rot|| d	ttur]dS td
d |D }||8 }d| }tj	dkrvdnd}t d||krdnd d| d|  d| d| 
dS )Check correct count for parameters of a generic cls (internal helper).

        This gives a nice error message in case of count mismatch.
        r  r  c                 S      g | ]}t |s|qS ru   rQ  r   ru   ru   rx   
<listcomp>G      "_check_generic.<locals>.<listcomp>c                 s   s    | ]}t |tV  qd S r   )r   r   r   ru   ru   rx   r   H  s    !_check_generic.<locals>.<genexpr>r   Nr  c                 s        | ]}t |d ttuV  qdS r  Nr   ra   r   ru   ru   rx   r   W      
r  r   	argumentsr   r  r  r   z for r  r  )
r   r  r  r  r   sumr   ra   r   rQ  )r   r   elenrb  
expect_valnum_tv_tuplesnum_default_tvthingsru   ru   rx   _check_generic8  sB   


r  c              	   C   s   |s	t |  dt|}||krX|}t| drBdd | jD }||k rBt|| dttur0dS tdd |D }||8 }d	| }t d
||krJdnd d|  d| d| dS )r  r  r  c                 S   r  ru   r  r   ru   ru   rx   r  o  r  r  r  Nc                 s   r  r  r  r   ru   ru   rx   r   |  r  r  r  r  r  r  r  r  r  )r   r   r  r  r   ra   r  )r   r   r  rb  r  r  ru   ru   rx   r  d  s2   

c               	   C   sd   zt d} W n ttfy   Y dS w | jddkrdS | jd}|tju p1|t	u p1|tj	u S )Nr  Fr|   r   r   )
r   r!  r   r$  r"  r#  f_localsr   rS   r:   )framer   ru   ru   rx   "_has_generic_or_protocol_as_origin  s   r  c                 C   s<   t | turdS t| }t|ot|dkot|d tv S )NFr   r   )r/   r   r.   r  r   r   _TYPEVARTUPLE_TYPES)xr   ru   ru   rx   _is_unpacked_typevartuple  s   
r  _collect_type_varsc                    s   |du rt j}g  t }d}d}| D ]G}t|rd}n-t||rH| vrH|rCt|dttu}|r9|r6tdd}n
|rCtd|d | t	|rY 
 fdd	|jD  qt S )
zCollect all type variable contained in types in order of
        first appearance (lexicographic order). For example::

            _collect_type_vars((T, List[S, T])) == (T, S)
        NFTr  2Type parameter with a default follows TypeVarTupleType parameter 8 without a default follows type parameter with a defaultc                    s   g | ]}| vr|qS ru   ru   )r   r   tvarsru   rx   r    r  z&_collect_type_vars.<locals>.<listcomp>)r   r   r  r  r   r   ra   r   r   r   r   r  r   )r  typevar_typesenforce_default_orderingdefault_encounteredtype_var_tuple_encounteredr   r  ru   r  rx   r    s.   
c           	      C   s   g }t  }d}d}| D ]l}t|trqt|tr/|D ]}t|gD ]}||vr,|| q!qqt|dr_||vr^|rYt|dttu}|rJ|rJt	d|rOd}n
|rYt	d|d|| qt
|red}t|dd	D ]}||vrv|| qkqt|S )
zCollect all type variables and parameter specifications in args
        in order of first appearance (lexicographic order).

        For example::

            assert _collect_parameters((T, Callable[P, T])) == (T, P)
        F__typing_subst__r  r  Tr  r  r  ru   )r  r   r   r   _collect_parametersr   r  r   ra   r   r  )	r   r   r  r  r  r   r  	collectedr  ru   ru   rx   r    sH   





r  c                 C   sP   dd |D }dd |D }t j| |||d}| |_|j_tjdk r&||_|S )Nc                 S   s   g | ]\}}|qS ru   ru   r   r  r   ru   ru   rx   r        z!_make_nmtuple.<locals>.<listcomp>c              	   S   s&   i | ]\}}|t |d | dqS )zfield z annotation must be a typer   r  ru   ru   rx   r    s    z!_make_nmtuple.<locals>.<dictcomp>r   rr  r   )rG  
namedtupler  r   r   rQ  _field_types)r   r  rr  r   r  r  nm_tplru   ru   rx   _make_nmtuple  s   
r  >   r|   r}   r  c                   @   rr   )_NamedTupleMetac                    s  t |v sJ |D ]}|t ur|tjurtdqtdd |D }d v r* d }nd v r5 d d}ni }g }|D ]&}| v rG|| q;|ratd| dt|dkrVd	nd
 dd| q;t||	  fdd|D  d d}||_
tj|v rttdrttj|_n
tjjj}	t|	|_ 	 D ]c\}
}|
tv rtd|
 |
tvr|
|jvrt||
 |
  zt|j}W n	 ty   Y qw z||||
 W q ty } zdt|jd|
d|}tjdkr||  t||d }~ww qtj|v r|  |S )Nz3can only inherit from a NamedTuple type and Genericc                 s   s     | ]}|t u r
tn|V  qd S r   )_NamedTupler   )r   r  ru   ru   rx   r   /  s    z*_NamedTupleMeta.__new__.<locals>.<genexpr>r  r|  r   zNon-default namedtuple field z cannot follow default fieldsr  r  r  c                    s   g | ]} | qS ru   ru   )r   r  r  ru   rx   r  B  r  z+_NamedTupleMeta.__new__.<locals>.<listcomp>r}   r  _generic_class_getitemz&Cannot overwrite NamedTuple attribute zError calling __set_name__ on z
 instance z in rV  )r  r   rS   r   r   r   r   r  r  r  rM  r  r  r  r  r   _prohibited_namedtuple_fieldsr   _special_namedtuple_fields_fieldsr   r   __set_name__BaseExceptionr|   r   rQ  add_noteRuntimeErrorrK  )r   r  r6  r  r  r  default_names
field_namer  class_getitemkeyr   set_namerU  r   ru   r  rx   r   )  s   







	

z_NamedTupleMeta.__new__N)r|   r}   r~   r   ru   ru   ru   rx   r  (  r   r  r   c                 C   s   t | v sJ tfS r   )r   r  r  ru   ru   rx   _namedtuple_mro_entriesp  s   r  c                K   s   |t u r|rd}d}n4d}d|  d| d}d| d }n"|d	u r9|r'td
d}d|  d| d}d| d }n|r?td|t u sG|d	u rXtj|j|ddtdd | }t| |t d}t	f|_
|S )ao  Typed version of namedtuple.

        Usage::

            class Employee(NamedTuple):
                name: str
                id: int

        This is equivalent to::

            Employee = collections.namedtuple('Employee', ['name', 'id'])

        The resulting class has an extra __annotations__ attribute, giving a
        dict that maps field names to types.  (The field names are also in
        the _fields attribute, which is part of the namedtuple API.)
        An alternative equivalent functional syntax is also accepted::

            Employee = NamedTuple('Employee', [('name', str), ('id', int)])
        z3Creating NamedTuple classes using keyword argumentszq{name} is deprecated and will be disallowed in Python {remove}. Use the class-based or functional syntax instead.r  r  z = NamedTuple(z, [])`z{name} is deprecated and will be disallowed in Python {remove}. To create a NamedTuple class with 0 fields using the functional syntax, pass an empty list, e.g. r;  Nz\Cannot pass `None` as the 'fields' parameter and also specify fields using keyword argumentsr  zIEither list of fields or keywords can be provided to NamedTuple, not bothz3.15)r   r   r  r  r}  )r  r   r  r  formatr  r  r  r'  r   r{  )r  r  r   r  r  r  ntru   ru   rx   r   t  sH   c                   @   s   e Zd ZdZdS )r   a  Base class for classes that implement the buffer protocol.

        The buffer protocol allows Python objects to expose a low-level
        memory buffer interface. Before Python 3.12, it is not possible
        to implement the buffer protocol in pure Python code, or even
        to check whether a class implements the buffer protocol. In
        Python 3.12 and higher, the ``__buffer__`` method allows access
        to the buffer protocol from Python code, and the
        ``collections.abc.Buffer`` ABC allows checking whether a class
        implements the buffer protocol.

        To indicate support for the buffer protocol in earlier versions,
        inherit from this ABC, either in a stub file or at runtime,
        or use ABC registration. This ABC provides no methods, because
        there is no Python-accessible methods shared by pre-3.12 buffer
        classes. It is useful primarily for static checks.

        N)r|   r}   r~   r   ru   ru   ru   rx   r     s    r0   c                C   s8   z	| j d| jW S  ty   tdt| jdw )a  Return the class's "original" bases prior to modification by `__mro_entries__`.

        Examples::

            from typing import TypeVar, Generic
            from typing_extensions import NamedTuple, TypedDict

            T = TypeVar("T")
            class Foo(Generic[T]): ...
            class Bar(Foo[int], float): ...
            class Baz(list[str]): ...
            Eggs = NamedTuple("Eggs", [("a", int), ("b", str)])
            Spam = TypedDict("Spam", {"a": int, "b": str})

            assert get_original_bases(Bar) == (Foo[int], float)
            assert get_original_bases(Baz) == (list[str],)
            assert get_original_bases(Eggs) == (NamedTuple,)
            assert get_original_bases(Spam) == (TypedDict,)
            assert get_original_bases(int) == (object,)
        r{  z"Expected an instance of type, not N)r  r#  rM  r   r   r   r|   rE  ru   ru   rx   r0     s   c                   @   sV   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Ze	j
dkr)dd Zdd ZdS dS )r7   aL  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 callable 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                C   s   |S r   ru   r   ru   ru   rx   rh    rz   zNewType.__call__c                 C   sD   || _ d|v r|dd }|| _|| _t }|dkr || _d S d S )Nr;  r  r  )r~   
rpartitionr|   __supertype__r'  r}   )rw   r   r  r  ru   ru   rx   r     s   
zNewType.__init__c                    s   | j  G  fddd}|fS )Nc                       s   e Zd Z fddZdS )z&NewType.__mro_entries__.<locals>.Dummyc                    s"   | j }td| d|d  d)NzGCannot subclass an instance of NewType. Perhaps you were looking for: `z = NewType(r  z)`)r|   r   )r   subcls_namesupercls_nameru   rx   rK    s   z8NewType.__mro_entries__.<locals>.Dummy.__init_subclass__N)r|   r}   r~   rK  ru   r  ru   rx   Dummy  s    r  r%  )rw   r6  r  ru   r  rx   ri    s   	zNewType.__mro_entries__c                 C   s   | j  d| j S )Nr;  )r}   r~   rv   ru   ru   rx   ry   %  r   zNewType.__repr__c                 C   r$  r   )r~   rv   ru   ru   rx   r  (  r&  zNewType.__reduce__r   c                 C   rE  r   rF  r  ru   ru   rx   rG  /  r  zNewType.__or__c                 C   rH  r   rF  r  ru   ru   rx   rI  2  r  zNewType.__ror__N)r|   r}   r~   r   rh  r   ri  ry   r  r   rQ  rG  rI  ru   ru   ru   rx   r7     s    

r7   r@   c                 C   s   | du pt | ttjtjtfS )z:Corresponds to is_unionable() in unionobject.c in CPython.N)r   r   r   r   r   r@   rP  ru   ru   rx   _is_unionable9  s   r  c                       s   e Zd ZdZdddefddZdededd	f fd
dZdedefddZ	dedefddZ
defddZdd Zdd Zdd Zdd ZejdkrWdd Zdd Z  ZS   ZS )r@   a  Create named, parameterized type aliases.

        This provides a backport of the new `type` statement in Python 3.12:

            type ListOrSet[T] = list[T] | set[T]

        is equivalent to:

            T = TypeVar("T")
            ListOrSet = TypeAliasType("ListOrSet", list[T] | set[T], type_params=(T,))

        The name ListOrSet can then be used as an alias for the type it refers to.

        The type_params argument should contain all the type parameters used
        in the value of the type alias. If the alias is not generic, this
        argument is omitted.

        Static type checkers should only support type aliases declared using
        TypeAliasType that follow these rules:

        - The first argument (the name) must be a string literal.
        - The TypeAliasType instance must be immediately assigned to a variable
          of the same name. (For example, 'X = TypeAliasType("Y", int)' is invalid,
          as is 'X, Y = TypeAliasType("X", int), TypeAliasType("Y", int)').

        ru   )type_paramsr   c                C   st   t |ts	td|| _|| _g }|D ]}t |tr || q|| qt|| _	t
 }|dkr5|| _|| _d S )Nz#TypeAliasType name must be a stringr  )r   r   r   	__value____type_params__r   r   r   r   r  r'  r}   r|   )rw   r   r  r  r   r  r  ru   ru   rx   r   ^  s   



zTypeAliasType.__init__r  rD  Nc                   s&   t | dr
| | t || d S )Nr|   )r  _raise_attribute_errorr   r   )rw   r   r  r   ru   rx   r   q  s   

zTypeAliasType.__setattr__c                C   s   |  | d S r   )r  rw   r   ru   ru   rx   __delattr__v  r  zTypeAliasType.__delattr__c                 C   s8   |dkrt d|dv rt d| dt d| d)Nr|   zreadonly attribute>   r  r}   r  r  zattribute 'z3' of 'typing.TypeAliasType' objects is not writablez0'typing.TypeAliasType' object has no attribute '')r   r  ru   ru   rx   r  y  s   

z$TypeAliasType._raise_attribute_errorc                 C   r$  r   r%  rv   ru   ru   rx   ry     r&  zTypeAliasType.__repr__c                    s2   t |ts|f} fdd|D }t t|S )Nc                    s"   g | ]}t |d  j dqS )zSubscripting z requires a type.)r   r   r|   )r   r6  rv   ru   rx   r    s    z-TypeAliasType.__getitem__.<locals>.<listcomp>)r   r   r   r   r  ru   rv   rx   r     s   

zTypeAliasType.__getitem__c                 C   r$  r   r%  rv   ru   ru   rx   r    r&  zTypeAliasType.__reduce__c                 O   r  )NzEtype 'typing_extensions.TypeAliasType' is not an acceptable base typer  r   ru   ru   rx   rK    s   zTypeAliasType.__init_subclass__c                 C   r  )NzType alias is not callabler  rv   ru   ru   rx   rh    r  zTypeAliasType.__call__r   c                 C   s   t |stS tj| |f S r   r  r   r   rj   )rw   re  ru   ru   rx   rG    s   zTypeAliasType.__or__c                 C   s   t |stS tj|| f S r   r  )rw   rd  ru   ru   rx   rI    s   zTypeAliasType.__ror__)r|   r}   r~   r   r   r   r   r   rD   r  r  ry   r   r  rK  rh  r   rQ  rG  rI  r   ru   ru   r   rx   r@   B  s    
r4   r  c                C   s(   t | tot| ddo| tuo| tjuS )aZ  Return True if the given type is a Protocol.

        Example::

            >>> from typing_extensions import Protocol, is_protocol
            >>> class P(Protocol):
            ...     def a(self) -> str: ...
            ...     b: int
            >>> is_protocol(P)
            True
            >>> is_protocol(int)
            False
        r,  F)r   r   r   r:   r   r  ru   ru   rx   r4     s   

c                C   s6   t | st| dt| drt| jS tt| S )a  Return the set of members defined in a Protocol.

        Example::

            >>> from typing_extensions import Protocol, get_protocol_members
            >>> class P(Protocol):
            ...     def a(self) -> str: ...
            ...     b: int
            >>> get_protocol_members(P)
            frozenset({'a', 'b'})

        Raise a TypeError for arguments that are not Protocols.
        z is not a Protocolr  )r4   r   r  r   r  r  r  ru   ru   rx   r1     s
   

r1   r+   c                   @   sP   e Zd ZdZdeddfddZdefddZdefd	d
Zde	de
fddZdS )r+   af  Define the documentation of a type annotation using ``Annotated``, to be
         used in class attributes, function and method parameters, return values,
         and variables.

        The value should be a positional-only string literal to allow static tools
        like editors and documentation generators to use it.

        This complements docstrings.

        The string value passed is available in the attribute ``documentation``.

        Example::

            >>> from typing_extensions import Annotated, Doc
            >>> def hi(to: Annotated[str, Doc("Who to say hi to")]) -> None: ...
        documentationrD  Nc                C   r  r   r  )rw   r  ru   ru   rx   r     r   zDoc.__init__c                 C   s   d| j dS )NzDoc()r  rv   ru   ru   rx   ry     r  zDoc.__repr__c                 C   s
   t | jS r   )r   r  rv   ru   ru   rx   r     r   zDoc.__hash__r   c                 C   r  r   )r   r+   r   r  r  ru   ru   rx   r     r  z
Doc.__eq__)r|   r}   r~   r   r   r   ry   rF  r   r   r  r   ru   ru   ru   rx   r+     s    CapsuleTypeCAPI)r  )ro   )NNFr   )ru   )r)  rG  collections.abcr  r*  r@  r  r   r  r   r   r  __all__PEP_560r   GenericMetarQ  _PEP_696_IMPLEMENTEDrs   r  r   rE   r   r   r   r   r   r   r   r   r   r>  r   r   r-   r3   r6   r   r   r   r   r   r   r  r8   r,   r(   defaultdictpartialr  r   r   r   r   r   r   r   r   r   r   r   r>   rC   r   r   r   rR   r   r   r   r   	_NoneTyper  rb   r  r  r3  r   EXCLUDED_ATTRIBUTESr  r  r'  r:   r+  r.  r1  r2  r  r=  rS   r=   r<   r#   r!   r    r   r"   r   r$   rq  _PEP_728_IMPLEMENTEDr   rw  r5   	signaturer   r   r  rv  r   r  r  r'   r2   r  r%   r  r/   r.   r  ImportErrorr   r  r?   ra   r  r  r  r  r  r  r   r	   r  r   r   r(  r  r+  r   r/  rA   r7  rB   r=  _Finalr   r
   rD   rG   rH   rM  rF   rO  rS  r   rQ  rR  rT  rZ  r   r]  r;   rs  r&   r)   ri   rj   rL   r9   r  r*   r  r  r  r  r  r  r  r   r  _prohibitedr  r  r  r  r  r   ABCregister
memoryview	bytearrayrb  r0   r7   r@   r  r4   r1   rQ   r   r+   _CapsuleType_socket_CAPIr  r   rI   rJ   rK   rM   rN   rO   rP   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   rc   rd   re   rf   rg   rh   rk   rl   rm   rn   ru   ru   ru   rx   <module>   s   |









 



(2

	
	d
5
y
X,'=

'
1f!
/.))+



*


>N 

V$
 
,"&8FB



<	n 



