o �J�h3 �@s.ddlZddlZddlZddlZddlZddlZddlZddlZddlZ ddl Z ddl Z gd�Z dZ eZejdkZGdd�d�Ze�ZejdkrMdd �Znejd krWd d �Znd d �Ze jZe �d �Ze �d�Ze �d�Ze jddd�Ze jddd�Zejdkr�ddl mZnGdd�de�ZGdd�ded�Ze jZGdd�de jdd�Z e j!Z!ejdkr�e j"Z"ndd�Z"d d!�Z#ejd"kr�e j$Z$n"d#d$�Z%d%d&�Z&Gd'd(�d(e j'dd�Z(Gd)d*�d*e dd�Z)e)d+d,�Z$e j*Z*e+e d-�r�e j,Z,e j-Z-e j.Z.ne�/e�0ej/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>ejdk�rDdd3l m?Z?m@Z@mAZAmBZBnHd4d5�ZCeDe d6e j'�ZEGd7d6�d6eEdd�ZFed�ZGeFejjBd8eGeGfd9�ZBeFejj@d:eGfd9�Z@eFejHd:d;e jIeJfd<�ZAeFejKd:d=e jIeJfd<�Z?gd>�d?d@gdAgdB�ZLeMe jN�hdC�BZOdDdE�ZP�ddFdG�ZQejdHk�r�e jRZRn*�d dIdJ�ZSdKdL�ZTdMdN�ZUGdOdP�dPee jR��ZVeWdQdR��ZXGdSdT�dTe jYeVd�ZRejdHk�r�e jZZZndUdV�ZZeZZ[ejdWk�r e j\Z\e j]Z]e j^Z^e j_Z_e j`Z`e jaZae jbZbnJeZGdXdY�dYeR��Z\eZGdZd[�d[eR��Z]eZGd\d]�d]eR��Z^eZGd^d_�d_eR��Z_eZGd`da�daeR��Z`eZGdbdc�dceRe��ZaeZGddde�deeRe��Zbdfdg�ZcdhZded�rge jeZee jfZfe jgZgn@die�he ji�jjvZkdjdk�ZlGdldm�dme�Zfe�mefdndoi�Znecdpdq��efddhdr�dsdn��Zee+e dm��r�e jfeffZoneffZodtdu�Zge+e dv��r�e jpZpndwdv�Zpe+e dx��r�e jqZqn dydz�Zr�d!d{d|�Zqe+e d}��r�e jsZse jtZtnGd~d�de j'dd�ZtGd�d}�d}�Zsejdd:�dk�r�e juZue jvZvn4zdd�l mwZwWn ex�ye j'ZwYnwzdd�l myZzWn ex�y$e j'ZzYnwd�d��Zud�d��Zve+e d���r7e j{Z{nejdd:�d k�rHe d�d���Z{ne d�d�d,�Z{e+e d���rXe j|Z|nGd�d��d�e�Z}Gd�d��d�e}d�Z~e~�Z|[~[}d�d��Zd�d��Z�Gd�d��d��Z�Gd�d��d�e�Z�e�r�dd�l mZn Gd�d��d�e�d�Ze+e d���r�e j�Z�e j�Z�nGd�d��d��Z�Gd�d��d�e��Z�Gd�d��d�e��Z�e�r�dd�l m�Z�ne+e d���r�Gd�d��d�e�d�Z�n Gd�d��d�e�e��Z�e+e d���s�Gd�d��d�e��Z�e j�d�d���Z�e+e d���re j�Z�e j�Z�n!ejdd:�d k�re d�d���Z�nGd�d��d�e dd�Z�e�d�d�d,�Z�e+e d���r,e j�Z�n!ejdd:�d k�r=e d�d���Z�nGd�d��d�e dd�Z�e�d�d�d,�Z�e+e d���rWe j�Z�n!ejdd:�d k�rhe d�d���Z�nGd�d��d�e dd�Z�e�d�d�d,�Z�Gd�d��d�e j�dd�Ze+e d���r�e j�Z�ned�d���Z�e+e d���r�e j�Z�ned�d���Z�e+e d���r�e j�Z�ned�d���Z�e+e d���r�e j�Z�e j�Z�n-ejdd:�d k�r�e d�d���Z�e d�d„�Z�nGd�dĄd�e dd�Z�e�d�d�d,�Z�e�d�d�d,�Z�e+e dx��r�e j�Z�n!ejdd:�d k�re d�dx��Z�nGd�dɄd�e dd�Z�e�dxd�d,�Z�d�Z�ejdWk�r(e j�Z�d�d̈́Z�nIejdd:�d k�rRGd�dτd�e dd�Z�Gd�dфd�e j'dd�Z�e�d�dӄ�Z�d�d̈́Z�nGd�dфd�e j'dd�Z�Gd�dׄd�e dd�Z�e�d�e�d,�Z�d�d̈́Z�e�r{dd�l m�Z�ne+e dڃ�r�d�d܄Z�Gd�dڄd�e�d�Z�nGd�dڄd�e��Z�e+e d߃�r�e j�Z�n d�ed�efd�d߄Z�e+e d��r�e j�Z�nd�Z�e+e d��r�e j�Z�n d�e�d�e�fd�d�Z�ejdWk�r�e j�Z�n5ddhdhdhdod�d�eJd�eJd�eJd�eJd�e j�e j�e j3e je j�d�e jffd�fd�e jd�e j�egeffd�d�Z�e+e d��re j�Z�ne jd�e j�d�e jfd�Z�d�e�d�e�fd�d�Z�e+e d���r2e j�Z�n e �d��Z�Gd�d��d��Z�e+e dڃ�sKefd�d��Z�nd�d��Z�e�sUe�e _�d�eJfd�d��Z�e�eDe d�d�hZ�d�eJfd�d��Z�e+e �d��r~�d"�d�d�Z�e�e _�n �d�d�Z�e�s�e�e _�ejdHk�r�e j�Z�n8�d#�d�d�Z�e j�Z�eMh�d��Z�G�d�d��de�Z�e�me��d doi�Z��d �d �Z�ece��ef�d �d ��Z�e+ejdA��r�ejj�Z�nG�d dA�dAej��Z�e���e��e���e��e���e��e+e �d��r�e j�Z�n�d�d�Z�ejdk�r e j�Z�n G�d�d��d�Z�e+e �d��r!e j�Z�n�d�d�Z�G�d�d��d�Z�e+e �d��r?e j�Z�e j�Z�n�ded�eJf�d�d�ZŐded�e j�e�f�d�d�Z�e+e �d��ree j�Z�n G�d�d��d�Z�eDe �dd�Z�e�du�r�zddl�Z�Wn ex�y�YnweDeːdd�Z�e�du�r�eẽZ�e�du�r�e�Z�e �ΐd�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e jYZYe j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e jIZIe j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�e j�Z�dS($�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@�eZdZdd�ZdS)� _SentinelcC�dS)Nz <sentinel>���selfruru�OC:\pinokio\api\whisper-webui.git\app\env\lib\site-packages\typing_extensions.py�__repr__��z_Sentinel.__repr__N��__name__� __module__� __qualname__ryrurururxrs�� rs�ro� cCst|tjtjtjf�S�N)� isinstance�typing� _GenericAlias�_types� GenericAlias� UnionType��trururx�_should_collect_from_parameters�s�r��ro� cCst|tjtjf�Sr�)r�r�r�r�r�r�rururxr���cCst|tj�o |j Sr�)r�r�r��_specialr�rururxr����T�KT�VT�T_co)� covariant�T_contra)� contravariant)ro� )rcs(eZdZ�fdd�Z�fdd�Z�ZS)�_AnyMetacs|turtd��t��|�S)Nz6typing_extensions.Any cannot be used with isinstance())r� TypeError�super�__instancecheck__�rw�obj�� __class__rurxr��s z_AnyMeta.__instancecheck__cs|turdSt���S)Nztyping_extensions.Any)rr�ryrvr�rurxry�s z_AnyMeta.__repr__)r|r}r~r�ry� __classcell__rurur�rxr��s r�cs eZdZdZ�fdd�Z�ZS)raqSpecial 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. cs*|turtd��t�j|g|�Ri|��S)NzAny cannot be instantiated)rr�r��__new__��cls�args�kwargsr�rurxr��sz Any.__new__)r|r}r~�__doc__r�r�rurur�rxr�sr)� metaclassc@rr)�_ExtensionsSpecialFormcCs d|jS�Nztyping_extensions.��_namervrururxry�� z_ExtensionsSpecialForm.__repr__Nr{rurururxr��rr�)�_rootc C�&zd|_W|SttfyY|Sw)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�)�frururxr-�s��r-cC� t�|�Sr�)r�r )�namerururxr3�r�r3)ror��cCs8g}|D]}t|t�r|�|j�q|�|�qt|�S)zJAn internal helper for Literal creation: flatten Literals among parameters)r��_LiteralGenericAlias�extend�__args__�append�tuple)� parameters�params�prururx�_flatten_literal_paramss   r�ccs�|D] }|t|�fVqdSr�)�type)r�r�rururx�_value_and_type_iters��r�c@seZdZdd�Zdd�ZdS)r�cCs2t|t�stStt|j��}tt|j��}||kSr�)r�r��NotImplemented�setr�r�)rw�otherZthese_args_dedupedZother_args_dedupedrururx�__eq__s z_LiteralGenericAlias.__eq__cCsttt|j���Sr�)�hash� frozensetr�r�rvrururx�__hash__r�z_LiteralGenericAlias.__hash__N)r|r}r~r�r�rurururxr�s r�c@s"eZdZdefdd�Zdd�ZdS)� _LiteralForm�doccCsd|_||_|_dS)Nr6)r�Z_docr�)rwr�rururx�__init__!sz_LiteralForm.__init__cCs�t|t�s|f}t|�}tt|��}zt|�}Wn ty!Yn*wt|�t|�krKg}|D]}||vr@|�|d�|� |�q.|rGJ|��t|�}t ||�S)Nr) r�r�r��listr�r�r��lenr��remover�)rwr�Zval_type_pairsZ deduped_pairsZnew_parameters�pairrururx� __getitem__%s&    � �  z_LiteralForm.__getitem__N)r|r}r~�strr�r�rurururxr� 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,cCs@t|d|�}z|t|j|j|jj<WtStyYtSw)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�rururxr8Zs �� ��r8cCsDt|d|�}|jtvr gSt|j}|j|vrgSt||j���S)z6Return all defined overloads for *func* as a sequence.r�)r�r}r�r~r��values)r�r��mod_dictrururxr,�s    cCs t��dS)z$Clear all overloads in the registry.N)r��clearrurururxr(�� r()rrrrRcCs|�d�o |�d�S)N�__)� startswith�endswith)�attrrururx� _is_dunder�r�r��_SpecialGenericAliascs<eZdZdddd��fdd� Zdd�Zejd d ��Z�ZS) r�TNru)�instr��defaultscsLttjur||_||_t�j||d||d�n t�j||||d�||_dS)NT)Zspecialr�r�)r�r�)�_special_generic_alias_baser�r�� __origin__�_nparamsr�r�� _defaults)rw�origin�nparamsr�r�r�r�rurxr��s  z_SpecialGenericAlias.__init__cCsPhd�}ttjur|�d�t|�s||vrt�|||�dSt|j||�dS)N>�_instr�r�r�r�) r�r�r��addr��object� __setattr__�setattrr�)rwr��valZ allowed_attrsrururxr��s   z _SpecialGenericAlias.__setattr__c s�t|t�s|f}d�t�fdd�|D��}|jr<t|�|jkr<t|�t|j�|jkr<g|�|jt|�|jd��R}t|�}||jkrz|jrTd|jt|j���}nt|j�}|jsct|�d���td||jkrldnd�d |�d |�d |����|�|�S) Nz*Parameters to generic types must be types.c3��|] }t�|��VqdSr��r�� _type_check��.0r���msgrurx� <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)rwr�Z actual_len�expectedrur�rxr��s4 �"  ���� z _SpecialGenericAlias.__getitem__) r|r}r~r�r�r�� _tp_cacher�r�rurur�rxr��s   ro)r��r)r�r�r) rLrrWrXrrTrgrNrMrdr�AbstractContextManager�AbstractAsyncContextManagerr)zcollections.abc� contextlib�typing_extensions>�__non_callable_proto_members__r��__match_args__�__protocol_attrs__cCsht�}|jdd�D]'}|jdvrq t|di�}g|j�|�RD]}|�d�s0|tvr0|�|�q q |S)N�����>rSr:�__annotations__�_abc_)r��__mro__r|r��__dict__r��_EXCLUDED_ATTRSr�)r��attrs�base� annotationsr�rururx�_get_protocol_attrss   ��rc Cs0z t�|�j�dd�WSttfyYdSw)Nr|�__main__)�sys� _getframe� f_globals�getr�� ValueError��depthrururx�_callers �r�rorpcCs t|�dvS)z�Allow 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. >�abcN� functools)rrrururx�_allow_reckless_class_checkss r"cOst|�jr td��dS)Nz Protocols cannot be instantiated)r�� _is_protocolr��rwr�r�rururx�_no_init%s �r%cCst|t�s td��dS)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���argrururx�_type_check_issubclass_arg_1)s �r(c@sBeZdZdd�Zdd�Zdd�Zdd�Zd d �Zd efd d �Z dS)� _ProtocolMetacKs�|dkr t|�dkr n-ttjht|�@r8|D]!}|ttjttjhvs7|jt�|j g�vs7t |�s7t d|����qt j j||||fi|��S)Nr:rz5Protocols can only inherit from other protocols, got )r�r:r�r�r�rSr|�_PROTO_ALLOWLISTrr}r4r�r �ABCMetar�)�mclsr��bases� namespacer�rrururxr�Cs����z_ProtocolMeta.__new__cOs8tjj|g|�Ri|��t|dd�rt|�|_dSdS)Nr#F)r r+r�r�rr r�rururxr�Ss �z_ProtocolMeta.__init__cCs�|tur t�||�St|dd�rCt�sCt|dd�s!t|�td��|jrC|j� d�t urCt|�t |j�}tdt |�dd��d ���t j�||�S) Nr#F�_is_runtime_protocol�LInstance 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"r(r�r rr� _proto_hook�sortedr�r r+)r�r�Znon_method_attrsrururxr3Xs,  �� �� ��z_ProtocolMeta.__subclasscheck__c Cs�|tur t�||�St|dd�stj�||�St|dd�s$t�s$td��tj�||�r-dS|jD]"}zt � ||�}Wn t yEYdSw|durR||j vrRdSq0dS)Nr#Fr/r0T) r:r�r�r�r r+r"r�r �inspect�getattr_staticr�r )r��instancer�r�rururxr�rs.   ��  ���z_ProtocolMeta.__instancecheck__cCs(tj�||�dur dS|tuo|tjuS)NT)r r+r�r:r��r�r�rururxr��sz_ProtocolMeta.__eq__�returncCr�r�)r�r��r�rururxr��r�z_ProtocolMeta.__hash__N) r|r}r~r�r�r3r�r��intr�rurururxr)<s  r)cCs�|j�dd�s tS|jD]7}|jD]-}||jvr'|j|dur%tSnt|di�}t|tjj �r>||vr>t |�r>nqtSq dS)Nr#Fr T) rrr�r rr�r�� collectionsr r[r4)r�r�r�rrrururxr4�s&      ����r4cs0eZdZejjZdZdZdZ�fdd�Z �Z S)r:ruTFcsjt�j|i|��|j�dd�stdd�|jD��|_d|jvr#t|_|jr1|j t j ur3t |_ dSdSdS)Nr#Fcss�|]}|tuVqdSr�)r:�r��brururxr����z-Protocol.__init_subclass__.<locals>.<genexpr>r1) r��__init_subclass__rr�any� __bases__r#r4r1r�r:r%r�r�rurxrA�s  �zProtocol.__init_subclass__) r|r}r~r�r:r�� __slots__r#r/rAr�rurur�rxr:�s r:c Cs�t|tj�r t|dd�std|����d|_t|t�s tj dkrRt �|_ |j D]*}z t t||d��}WntyH}z td|�d��|�d}~ww|sQ|j �|�q'|S) ajMark 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� rNz,Failed to determine whether protocol member z is a method member)� issubclassr�rSr�r�r/r�r)r� version_infor�r r �callable� Exceptionr�)r�r�� is_callable�erururxr=�s,�   ���� �r=�rorEc@�(eZdZdZdZejdefdd��ZdS)r#z(An ABC with one abstract method __int__.rur:cC�dSr�rurvrururx�__int__�zSupportsInt.__int__N) r|r}r~r�rDr �abstractmethodr<rOrurururxr#� r#c@rM)r!z*An ABC with one abstract method __float__.rur:cCrNr�rurvrururx� __float__"rPzSupportsFloat.__float__N) r|r}r~r�rDr rQ�floatrSrurururxr!rRr!c@rM)r z,An ABC with one abstract method __complex__.rur:cCrNr�rurvrururx� __complex__+rPzSupportsComplex.__complex__N) r|r}r~r�rDr rQ�complexrUrurururxr &rRr c@rM)rz*An ABC with one abstract method __bytes__.rur:cCrNr�rurvrururx� __bytes__4rPzSupportsBytes.__bytes__N) r|r}r~r�rDr rQ�bytesrWrurururxr/rRrc@s$eZdZdZejdefdd��ZdS)r"rur:cCrNr�rurvrururx� __index__<rPzSupportsIndex.__index__N)r|r}r~rDr rQr<rYrurururxr"8sr"c@rM)rz_ An ABC with one abstract method __abs__ that is covariant in its return type. rur:cCrNr�rurvrururx�__abs__GrPzSupportsAbs.__abs__N) r|r}r~r�rDr rQr�rZrurururxr@s rc@s.eZdZdZdZejd dedefdd��Z dS) r$za An ABC with one abstract method __round__ that is covariant in its return type. rur�ndigitsr:cCrNr�ru)rwr[rururx� __round__RrPzSupportsRound.__round__N)r) r|r}r~r�rDr rQr<r�r\rurururxr$Ks r$cs�fdd�}|S)NcsNtjjdkr"tjdkr"t|�t��d�}t|jd|�}t�|�|�S�|_ |S)N�pypyr�)�__call__�__mro_entries__ru) r�implementationr�rG� staticmethodr�r|r!�update_wrapperr_)r��cls_dictr��� mro_entriesrurx�innerXs�z#_ensure_subclassable.<locals>.innerru)rerfrurdrx�_ensure_subclassableWs  rgF�moduleccs�� t|�}|turt|�}|r|d}n+dS|tur$tVt|�\}n|tur1tVt|�\}n|tur>tVt|�\}ndSq)NTr)r/r%r.rGrHrF)�annotation_typeZannotation_originZannotation_argsrururx�_get_typeddict_qualifiers~s&�    �rjc@s,eZdZddd�dd�ZeZdd�ZeZdS) �_TypedDictMetaTF��total�closedcs�|D]}t|�tur|tjurtd��qtdd�|D��r"tjf}nd}t�tdg|�t�R|��|�_�j dkr<|�_ t �d�sD|�_ i}d|vrO|d} n d|vrZ|dd �} ni} d �t rm��fd d �| � �D�} n �fd d �| � �D�} t�} t�} t�} t�} d}|D]>}|j}|�|�di��| �|�dd��| �|�dd��| �|�dd��| �|�dd��|�dd�}|dur�|}q�|r�|dur�t}|r�d| vr�| �d�}tt|��}t|vr�td��t|vr�td��|}|�| �| � �D]H\}}tt|��}t|v�r| �|�nt|v�r| �|�n|�r$| �|�n| �|�t|v�r9| �|�| �|�q�| �|�| �|�q�|�_t| ��_t| ��_t| ��_t| ��_t �d��sd|�_ |�_!|�_"�S)aICreate 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 classcss�|] }t|tj�VqdSr�)rFr�rSr>rururxr��r�z)_TypedDictMeta.__new__.<locals>.<genexpr>rur:�__orig_bases__r � __annotate__r�z?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typecs$i|]\}}|tj|��jd��qS)�rh)r�r�r}�r��n�tp�r��tp_dictrurx� <dictcomp>�s��z*_TypedDictMeta.__new__.<locals>.<dictcomp>csi|] \}}|t�|���qSrur�rrr�rurxrw�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�rkr�rSr�rBr��dictr|r~�hasattrro� _TAKES_MODULE�itemsr�r�updaterrD�poprjrGrHr�rF�discardr r�rxryrzr{r}Z __closed__r|)r�r�r-�nsrmrnr� generic_baser�own_annotations� required_keys� optional_keysZ readonly_keysZ mutable_keysZextra_items_typeZ base_dictZbase_extra_items_typeriZ qualifiersZannotation_keyrururxr��s��     � � �    ��                  z_TypedDictMeta.__new__cC�td��)Nz4TypedDict does not support instance and class checks�r�r9rururxr3�z _TypedDictMeta.__subclasscheck__N)r|r}r~r�r~r^r3r�rurururxrk�s prkrrucCstfSr�)� _TypedDict�r-rururx�<lambda>sr�rlc Ks�|tus|dur<|turd}nd}d|�d|�d�}|�d�|d}tj|td d �|d ur9|d ur9||d <d }|}n|rBtd��|rUtjdkrMtd��tjdtd d �dt|�i}t�} | durf| |d<t |d|||d�} t f| _ | S)aqA 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. N�2Failing 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. r2r�� stacklevelFTrnz@TypedDict takes either a dict or keyword arguments, but not bothrz$TypedDict takes no keyword argumentsz�The 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}rurl) �_marker�warnings�warn�DeprecationWarningr�rrGr~rrkrro) �typename�fieldsrmrnr��deprecated_thing�example�deprecation_msgr�rh�tdrururxrs@0�� � cCs"ttd�r |tjur dSt|t�S)aCheck 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 rF)rr�rr��_TYPEDDICT_TYPES�rtrururxr5ls  r5r'cC�|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��typrururxr'�s rFcCst|t�r t|j�St|d�r|jtttfvrt|jd�St|t j �r:t dd�|jD��}||jkr5|S|� |�Stt d�r]t|t j�r]t dd�|jD��}||jkrV|St �|j|�Stt d�r�t|t j�r�t dd�|jD��}||jkry|St�tj|�S|S) z=Strips Annotated, Required and NotRequired from a given type.r�rcs��|]}t|�VqdSr��� _strip_extras�r��arururxr��r@z _strip_extras.<locals>.<genexpr>r�csr�r�r�r�rururxr��r@r�csr�r�r�r�rururxr��r@)r��_AnnotatedAliasr�r�rrGrHrFr�r�r�r�rr�r�r�r!�reduce�operator�or_)r�� stripped_argsrururxr��s(       r�cCsHttd�rtj|||dd�}ntj|||d�}|r|Sdd�|��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�cSsi|] \}}|t|��qSrur�)r��kr�rururxrw�sz"get_type_hints.<locals>.<dictcomp>)rr�r2r�)r�r�r�r��hintrururxr2�s �r2r%csHeZdZdZ�fdd�Zdd�Zdd�Zdd �Zd d �Zd d �Z �Z S)r�aKRuntime 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. cs2t|t�r |j|}|j}t��||�||_dSr�)r�r�� __metadata__r�r�r�)rwr��metadatar�rurxr��s   z_AnnotatedAlias.__init__cCs$t|�dksJ�|d}t||j�S)Nr�r)r�r�r�)rwr��new_typerururxr�s z_AnnotatedAlias.copy_withcCs,dt�|j��dd�dd�|jD���d�S)Nztyping_extensions.Annotated[�, csr�r�)�reprr�rururxr��r@z+_AnnotatedAlias.__repr__.<locals>.<genexpr>�])r�� _type_reprr��joinr�rvrururxry�s�z_AnnotatedAlias.__repr__cCstjt|jg|j�RffSr�)r��getitemr%r�r�rvrururx� __reduce__�s�z_AnnotatedAlias.__reduce__cCs*t|t�stS|j|jkrdS|j|jkS)NF)r�r�r�r�r��rwr�rururxr��s   z_AnnotatedAlias.__eq__cC�t|j|jf�Sr�)r�r�r�rvrururxr��z_AnnotatedAlias.__hash__) r|r}r~r�r�rryr�r�r�r�rurur�rxr��s r�c@s2eZdZdZdZdd�Zejdd��Zdd�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()] rucOr�)Nz&Type Annotated cannot be instantiated.r�r�rururxr�*�zAnnotated.__new__cCsnt|t�r t|�dkrtd��ttf}t|d�|vr |d}n d}t�|d|�}t|dd��}t ||�S)NrzUAnnotated[...] should be used with at least two arguments (a type and an annotation).rz$Annotated[t, ...]: t must be a type.r�) r�r�r�r�rrr/r�r�r�)r�r�Zallowed_special_formsr�r�r�rururx�__class_getitem__-s  zAnnotated.__class_getitem__cOstd|j�d���)N�Cannot subclass z .Annotated)r�r}r�rururxrA<s �zAnnotated.__init_subclass__N) r|r}r~r�rDr�r�rr�rArurururxr%s   )�_BaseGenericAlias)r�cCs>t|t�rtSt|tjttttf�r|j S|tj urtj SdS)a6Get 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�rr r�rSr�rururxr/Ts  � r/cCs|t|t�r |jg|j�RSt|tjtf�r<t|dd�rdS|j}t |�t j j ur:|dt ur:t|dd��|df}|SdS)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�FrurNr )r�r�r�r�r�r�r�r�r�r/r=r rL�Ellipsisr�)rt�resrururxr.ls  r.r?cC�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��rwr�rururxr?�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.rac@rr)�NoDefaultTypeMetacCstd|�d|j����)Nz cannot set z attribute of immutable type �r�r|)r�r��valuerururxr��s�zNoDefaultTypeMeta.__setattr__N)r|r}r~r�rurururxr��rr�c@s,eZdZdZdZdd�Zdd�Zdd�Zd S) � NoDefaultTypez$The type of the NoDefault singleton.rucCst��d�p t�|�S�Nra)�globalsrr�r�r;rururxr��szNoDefaultType.__new__cCrt)Nztyping_extensions.NoDefaultrurvrururxry�rzzNoDefaultType.__repr__cCrtr�rurvrururxr��rzzNoDefaultType.__reduce__N)r|r}r~r�rDr�ryr�rurururxr��s  r�cs�fdd�|_�|_dS)Ncs�tuSr�)raru��defaultrurxr��sz_set_default.<locals>.<lambda>)� has_default� __default__)� type_paramr�rur�rx� _set_default�s r�cCs tdd�}|dkr||_dSdS)Nrorr)rr})Z typevarlike�def_modrururx� _set_module�s  �r�c@seZdZdZdZeZdS)� _DefaultMixinzMixin for TypeVarLike defaults.ruN)r|r}r~r�rDr�r�rurururxr��sr�c@seZdZdedefdd�ZdS)�_TypeVarLikeMeta�_TypeVarLikeMeta__instancer:cCs t||j�Sr�)r��_backported_typevarlike)r�r�rururxr��� z"_TypeVarLikeMeta.__instancecheck__N)r|r}r~r�boolr�rurururxr��sr�)r c@s6eZdZdZejZdddedd�dd�Zd dd �Z dS) r zType variable.NF)�boundr�r�r��infer_variancec s�ttd�rtj|g|�R||||d���ntj|g|�R|||d���|r-|s)|r-td��|�_t�|�t���fdd�}|�_�S)Nr@�r�r�r�r��r�r�r�z1Variance cannot be specified with infer_variance.cs,���r|j���t|�kr|�jf7}|Sr�)r��__parameters__�indexr�r�)�aliasr��Ztypevarrurx�_tvar_prepare_subst�s � z,TypeVar.__new__.<locals>._tvar_prepare_subst)rr�r r�__infer_variance__r�r��__typing_prepare_subst__) r�r�r�r�r�r�r�� constraintsr�rur�rxr��s  ��   zTypeVar.__new__r:cC�tdt�d���)N�type 'z(.TypeVar' is not an acceptable base typer�r;rururxrAr�zTypeVar.__init_subclass__�r:N) r|r}r~r�r�r r�rar�rArurururxr �s �r rc@s$eZdZdZdZdd�Zdd�ZdS)� _Immutablez3Mixin to indicate that object should not be copied.rucCr�r�rurvrururx�__copy__rzz_Immutable.__copy__cCr�r�ru)rw�memorururx� __deepcopy__rzz_Immutable.__deepcopy__N)r|r}r~r�rDr�r�rurururxr� s  r�c@�(eZdZdZdd�Zdd�Zdd�ZdS) raQThe 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. cC� ||_dSr��r��rwr�rururxr�!r�zParamSpecArgs.__init__cC�|jj�d�S)Nz.args�r�r|rvrururxry$�zParamSpecArgs.__repr__cC�t|t�stS|j|jkSr�)r�rr�r�r�rururxr�'�  zParamSpecArgs.__eq__N�r|r}r~r�r�ryr�rurururxr�   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. cCr�r�r�r�rururxr�8r�zParamSpecKwargs.__init__cCr�)Nz.kwargsr�rvrururxry;r�zParamSpecKwargs.__repr__cCr�r�)r�r r�r�r�rururxr�>r�zParamSpecKwargs.__eq__Nr�rurururxr ,r�r )rrc@s6eZdZdZejZdddded�dd�Zd dd �Z dS) rzParameter specification.NF�r�r�r�r�r�cs`ttd�rtj|||||d��n tj||||d��|�_t�|�t���fdd�}|�_�S)Nr@r�r�cs�|j}|���}|t|�kr���rg|��j�}|t|�kr&td|����t|�dkr>t�|d�s>|dks9J�|f}|St||t �r\g|d|��t ||��||dd��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�Z paramspecrurx�_paramspec_prepare_substbs   �.z3ParamSpec.__new__.<locals>._paramspec_prepare_subst)rr�rr�r�r�r�)r�r�r�r�r�r�r�rrur�rxr�Ps ��  zParamSpec.__new__r:cCr�)Nr�z*.ParamSpec' is not an acceptable base typer�r;rururxrAur�zParamSpec.__init_subclass__r�) r|r}r~r�r�rr�rar�rArurururxrKs �%c@sleZdZdZejZedd��Zedd��Z dddde d�d d �Z d d �Z d d�Z dd�Zdd�Zdd�ZdS)ra'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. cC�t|�Sr�)rrvrururxr��r�zParamSpec.argscCrr�)r rvrururxr��r�zParamSpec.kwargsNFr�cCstt�||g�||_t|�|_t|�|_t|�|_|r#t�|d�|_ nd|_ t �||�t �}|dkr8||_ dSdS)NzBound must be a type.r) r�r�r|r�� __covariant__�__contravariant__r�r�r�� __bound__r�rr})rwr�r�r�r�r�r�r�rururxr��s     �zParamSpec.__init__cCs2|jrd}n|jr d}n|jrd}nd}||jS)N��+�-�~)r�rrr|)rw�prefixrururxry�s zParamSpec.__repr__cCr�r��r�r�rvrururxr��r�zParamSpec.__hash__cC�||uSr�rur�rururxr��r�zParamSpec.__eq__cC�|jSr��r|rvrururxr���zParamSpec.__reduce__cOrNr�rur$rururxr^�rzzParamSpec.__call__)r|r}r~r�r�r r��propertyr�r�rar�ryr�r�r�r^rurururxr|s/   �  rcsJeZdZejZdZ�fdd�Zdd�Zdd�Z dd �Z e d d ��Z �Z S) �_ConcatenateGenericAliasFcst��|�||_||_dSr�)r�r�r�r�)rwr�r�r�rurxr��s  z!_ConcatenateGenericAlias.__init__cs2tj��|j��dd��fdd�|jD���d�S)N�[r�c3s�|]}�|�VqdSr�ru)r�r'�r�rurxr��r@z4_ConcatenateGenericAlias.__repr__.<locals>.<genexpr>r�)r�r�r�r�r�rvrurrxry�s �z!_ConcatenateGenericAlias.__repr__cCr�r�)r�r�r�rvrururxr��r�z!_ConcatenateGenericAlias.__hash__cOrNr�rur$rururxr^�rzz!_ConcatenateGenericAlias.__call__cCstdd�|jD��S)Ncss$�|] }t|tjtf�r|VqdSr�)r�r�r r)r�rtrururxr��s �� �z:_ConcatenateGenericAlias.__parameters__.<locals>.<genexpr>)r�r�rvrururxr��s�z'_ConcatenateGenericAlias.__parameters__)r|r}r~r�r�r�r�r�ryr�r^rr�r�rurur�rxr�s rcsZ|dkrtd��t|t�s|f}t|dt�std��d�t�fdd�|D��}t||�S)Nruz&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.c3r�r�r�r�r�rurxr�r�z'_concatenate_getitem.<locals>.<genexpr>)r�r�r�rrr�rur�rx�_concatenate_getitems  rcC� 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. �rr�rururxrs c@rr)�_ConcatenateFormcCrr�rr�rururxr�)r�z_ConcatenateForm.__getitem__N�r|r}r~r�rurururxr(rrrrAcC� 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��rwr��itemrururxrA>s,c@rr)�_TypeGuardFormcC�"t�||j�d��}t�||f�S�Nz accepts only a single type�r�r�r�r�rrururxr�o� �z_TypeGuardForm.__getitem__NrrurururxrnrrrrBcCr)�zSpecial 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). rrrrururxrB�s&c@rr)� _TypeIsFormcCr r!r"rrururxr��r#z_TypeIsForm.__getitem__Nrrurururxr%�rr%r$c@sneZdZdZdd�Zdd�Zdd�Zdd �Zd d �Zd d �Z dd�Z dd�Z dd�Z dd�Z ejdd��ZdS)� _SpecialForm)r�r��_getitemcCs||_|j|_|j|_dSr�)r'r|r�r��rwr�rururxr�s z_SpecialForm.__init__cCs|dvr|jSt|��)N>r|r~)r�r�)rwrrururx� __getattr__sz_SpecialForm.__getattr__cC�td|����)Nr�r�)rwr-rururxr_ r�z_SpecialForm.__mro_entries__cCs d|j��Sr�r�rvrururxryr�z_SpecialForm.__repr__cCr r�r�rvrururxr�rz_SpecialForm.__reduce__cOr*)NzCannot instantiate r��rwr��kwdsrururxr^r�z_SpecialForm.__call__cC�tj||fSr��r�rjr�rururx�__or__r�z_SpecialForm.__or__cC�tj||fSr�r.r�rururx�__ror__r�z_SpecialForm.__ror__cCr�)Nz! cannot be used with isinstance()r�r�rururxr�r�z_SpecialForm.__instancecheck__cCr�)Nz! cannot be used with issubclass()r�)rwr�rururxr3"r�z_SpecialForm.__subclasscheck__cCs |�||�Sr�)r'r�rururxr�%r�z_SpecialForm.__getitem__N)r|r}r~rDr�r)r_ryr�r^r/r1r�r3r�rr�rurururxr&�sr&rcCr�)aDRepresents 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��rwr�rururxr-sr cCr�)z�Used 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�r2rururxr DsrDcCr�)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�r2rururxrDYsrGcCr )��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. rr"rrururxrGxscCr )�`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, ) rr"rrururxrH�srHc@rr)� _RequiredFormcCr �Nrr"rrururxr��r#z_RequiredForm.__getitem__Nrrurururxr5�rr5r3r4cCr )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. rr"rrururxrF�sc@rr)� _ReadOnlyFormcCr r6r"rrururxr��r#z_ReadOnlyForm.__getitem__Nrrurururxr7�rr7a�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. cCs t|�tuSr�)r/r�r�rururx� _is_unpack! r�r9cseZdZ�fdd�Z�ZS)�_UnpackSpecialFormcst��|�t|_dSr�)r�r�� _UNPACK_DOCr�r(r�rurxr�& s  z_UnpackSpecialForm.__init__)r|r}r~r�r�rurur�rxr:% sr:c@seZdZejZedd��ZdS)� _UnpackAliascCsV|jtusJ�t|j�dksJ�|j\}t|tjtjf�r)|jt ur&t d��|jSdS)Nr�z*Unpack[...] must be used with a tuple type) r�rr�r�r�r�r�r�r�r�r�)rwr'rururx�__typing_unpacked_tuple_args__- s z+_UnpackAlias.__typing_unpacked_tuple_args__N)r|r}r~r�r r�rr=rurururxr<* sr<cC� t�||j�d��}t||f�Sr6�r�r�r�r<rrururxr8 s rcC� t|t�Sr��r�r<r8rururxr9= r�c@seZdZejZdS)r<N)r|r}r~r�r r�rurururxr<A s c@rr)� _UnpackFormcCr>r6r?rrururxr�E s � z_UnpackForm.__getitem__NrrurururxrBD rrBcCr@r�rAr8rururxr9L r�)r r cGsLg}|D]}t|dd�}|dur|r|ddus|�|�q|�|�q|S)Nr=r .)r�r�r�)r�Znewargsr'�subargsrururx� _unpack_argsU s   rDc@s,eZdZdZejZed�dd�Zdd�Z dS)r zType variable tuple.r�cs2t�|��t�|�t���fdd�}|�_�S)Ncs�|j}|���}||dd�D]}t|t�rtd|����qt|�}t|�}|}||d}d} d} t|�D]+\} } t| t�sbt| dd�} | rbt| �dkrb| ddurb| dur\td��| } | d} q7| durvt || �}t ||| d�}n|||kr�td |�d |�d |d����|||kr��� �r�t �j �}n||||�}g|d|��| g||�|�| g||||d�|||d��RS) Nr�z(More than one TypeVarTuple parameter in r=rr .z6More than one unpacked arbitrary-length tuple argumentrr�r�z, expected at least ) r�r�r�r r�r�� enumerater�r��minr�rDr�)r�r�r�Ztypevartuple_index�param�alen�plen�left�rightZvar_tuple_indexZfillargr�r'rC� replacement�Ztvtrurx�_typevartuple_prepare_substj s`  ��   ��   ��  � ����z9TypeVarTuple.__new__.<locals>._typevartuple_prepare_subst)r�r r�r�r�)r�r�r�rNrurMrxr�e s   -zTypeVarTuple.__new__cOr�)N�&Cannot subclass special typing classesr�r+rururxrA� r��TypeVarTuple.__init_subclass__N) r|r}r~r�r�r r�rar�rArurururxr ` s  5c@sTeZdZdZejZdd�Zed�dd�Z dd�Z d d �Z d d �Z d d�Z dd�ZdS)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] ccs�|jVdSr�)� __unpacked__rvrururx�__iter__� s� zTypeVarTuple.__iter__r�cCs4||_t�||�t�}|dkr||_t||_dS)Nr)r|r�r�rr}rrQ)rwr�r�r�rururxr�� s  zTypeVarTuple.__init__cCr r�r rvrururxry� rzTypeVarTuple.__repr__cCr�r�r rvrururxr�� r�zTypeVarTuple.__hash__cCr r�rur�rururxr�� r�zTypeVarTuple.__eq__cCr r�r rvrururxr�� rzTypeVarTuple.__reduce__cOsd|vrtd��dS)Nr�rOr�r+rururxrA� s�rPN)r|r}r~r�r�r r�rRrar�ryr�r�r�rArurururxr � s,  r;r�r:cCstdt|�j��tjd�|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. zRuntime type is )�file)�printr�r|r�stderrr8rururxr;� s�_ASSERT_NEVER_REPR_MAX_LENGTH�dr&r'cCs2t|�}t|�tkr|dt�d}td|����)a1Assert 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�rV�AssertionError)r'r�rururxr& s )� eq_default� order_default�kw_only_default�frozen_default�field_specifiersrYrZr[r\r].r�c s������fdd�}|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. cs������d�|_|S)N)rYrZr[r\r]r�)Z__dataclass_transform__)Z cls_or_fn�rYr]r\r[r�rZrurx� decorators s�z&dataclass_transform.<locals>.decoratorru)rYrZr[r\r]r�r_rur^rxr)* sI r)r9�_F)r�c Cr�)aHIndicate 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)Z __override__r�r�r&rururxr9� s��r*�_Tc @sPeZdZdZedd�dedejeje de ddfd d �Z d e de fd d �Z dS)r*aIndicate 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��messagercr�r:NcCs4t|t�stdt|�j����||_||_||_dS)Nz2Expected an object of type str for 'message', not )r�r�r�r�r|rdrcr�)rwrdrcr�rururxr�� s �� zdeprecated.__init__r'cs0|j�|j�|j��dur��_�St�t�rsddl}ddlm}�j �|� �������fdd��}t |��_ �j �t�|�rW�j �|� ������fdd��}t|��_ n|� ������fdd��}|�_ ��_|_�|_�St��r�ddl}|� ������fdd ��}��_|_|Std �����) Nr)� MethodTypecsh|�urtj���dd��tjur�|g|�Ri|��S|jtjur0|s(|r0t|j�d����|�S)Nr�rbz() takes no arguments)r�r�r�r�r�r�r|r�)r'rcr�� original_newr�rurxr�� s z$deprecated.__call__.<locals>.__new__c�"tj���dd��|i|��S�Nr�rb�r�r��r�r��rcr��original_init_subclassr�rurxrA �z.deprecated.__call__.<locals>.__init_subclass__crgrhrirjrkrurxrA rmcs"tj���dd��|i|��Srhrirj)r'rcr�r�rurx�wrapper" rmz$deprecated.__call__.<locals>.wrapperzY@deprecated decorator with non-None category must be applied to a class or callable, not )rdrcr�Z__deprecated__r�r�r!�typesrer��wrapsrarAr�� classmethodrHr�)rwr'r!rer�rArnru)r'rcr�rlrfr�rxr^� sH       ��zdeprecated.__call__)r|r}r~r�r�r�r�rbr �Warningr<r�rar^rurururxr*� s.���� �c Cs&|s t|�d���|tur!t|d�r|jst|�d���t|j�}t|�}||kr�|}t|d�rodd�|jD�}tdd�|D��}|dkrM|||krMdS||krot||d t�tur]dStd d�|D��}||8}d |��}tj d krvd nd}td||kr�dnd�d|�d|�d|�d|�� ��dS)��Check correct count for parameters of a generic cls (internal helper). This gives a nice error message in case of count mismatch. r�r�cS�g|]}t|�s|�qSru�r9r�rururx� <listcomp>G ��"_check_generic.<locals>.<listcomp>css�|]}t|t�VqdSr�)r�r r�rururxr�H s��!_check_generic.<locals>.<genexpr>rNr�cs� �|] }t|dt�tuVqdS�r�N�r�rar�rururxr�W � � � �r�r�� argumentsr�r�r�r�� z for r�r) r�r�rr�r��sumr�rarrG)r�r��elenrH� expect_valZ num_tv_tuples�num_default_tvZthingsrururx�_check_generic8 sB  �� ����r�c Cs�|s t|�d���t|�}||krX|}t|d�rBdd�|jD�}||krBt||dt�tur0dStdd�|D��}||8}d |��}td ||krJd nd �d |�d|�d|����dS)rsr�r�cSrtrurur�rururxrvo rwrxr�Ncsrzr{r|r�rururxr�| r}ryr�r�r�r�r�r�r)r�r�rr�r�rar�)r�r�r�rHr�r�rururxr�d s2 �� ����c Csdzt�d�}Wn ttfyYdSw|j�d�dkrdS|j�d�}|tjup1|t up1|tj uS)NrFr|r�r�) rrr�rrr�f_localsr�rSr:)�framer�rururx�"_has_generic_or_protocol_as_origin� s� r�cCs<t|�turdSt|�}t|�ot|�dkot|d�tvS)NFr�r)r/rr.r�r�r��_TYPEVARTUPLE_TYPES)�xr�rururx�_is_unpacked_typevartuple� s  ��r��_collect_type_varscs�|durtj}g�t�}d}d}|D]G}t|�rd}n-t||�rH|�vrH|rCt|dt�tu}|r9|r6td��d}n |rCtd|�d�����|�t |�rY�� �fdd �|j D��qt ��S) z�Collect 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 defaultcsg|]}|�vr|�qSruru)r�r���tvarsrurxrv� rwz&_collect_type_vars.<locals>.<listcomp>) r�r r�r�r�r�rar�r�r�r�r�r�)ro� typevar_types�enforce_default_ordering�default_encountered�type_var_tuple_encounteredr�r�rur�rxr�� s. �c Cs�g}t�}d}d}|D]l}t|t�rq t|t�r/|D]}t|g�D] }||vr,|�|�q!qq t|d�r_||vr^|rYt|dt�tu}|rJ|rJt d��|rOd}n |rYt d|�d���|�|�q t |�red}t|dd �D] }||vrv|�|�qkq t|�S) z�Collect 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) FZ__typing_subst__r�r�Tr�r�r�ru) r�r�r�r��_collect_parametersr�rr�rar�r�) r�r�r�r�r�r�r�Z collectedr�rururxr�� sH   ��� � � ��r�cCsPdd�|D�}dd�|D�}tj||||d�}||_|j_tjdkr&||_|S)NcSsg|]\}}|�qSruru�r�rsr�rururxrv �z!_make_nmtuple.<locals>.<listcomp>c Ss&i|]\}}|t�|d|�d���qS)zfield z annotation must be a typer�r�rururxrw s�z!_make_nmtuple.<locals>.<dictcomp>�r�rhr�)r=� namedtupler r�rrGZ _field_types)r�rorhr�r�r�nm_tplrururx� _make_nmtuple s�� r�>r}r|r c@rr)�_NamedTupleMetac st|vsJ�|D]}|tur|tjurtd��qtdd�|D��}d�vr*�d}n d�vr5�dd�}ni}g}|D]&}|�vrG|�|�q;|ratd|�dt|�dkrVd nd �d d �|�����q;t||� ��fd d�|D��dd�}||_ tj|vr�t td�r�t tj �|_n tjjj} t | �|_�� �D]c\} } | tvr�td| ��| tvr�| |jvr�t|| �| �zt| �j} Wn ty�Yq�wz| | || �Wq�ty�} zdt| �j�d| �d|��}tjdkr�| �|��t|�| �d} ~ wwq�tj|v�r|��|S)Nz3can only inherit from a NamedTuple type and Genericcss �|] }|tur tn|VqdSr�)� _NamedTupler�)r�rrururxr�/ s�z*_NamedTupleMeta.__new__.<locals>.<genexpr>r rpr�zNon-default namedtuple field z cannot follow default field�srrr�csg|]}�|�qSruru)r�rs�r�rurxrvB r�z+_NamedTupleMeta.__new__.<locals>.<listcomp>r}r��_generic_class_getitemz&Cannot overwrite NamedTuple attribute zError calling __set_name__ on z instance z in rL)r�r�rSr�r�r�r�r�r�r�rCrrqr�r�r��_prohibited_namedtuple_fieldsr��_special_namedtuple_fields�_fieldsr�r�� __set_name__� BaseExceptionr|rrGZadd_note� RuntimeErrorrA)r�r�r-r�rro� default_names� field_namer�Z class_getitem�keyr��set_namerKr�rur�rxr�) s� ��   ����       ����  ��� z_NamedTupleMeta.__new__N)r|r}r~r�rurururxr�( rr�rcCst|vsJ�tfSr�)rr�r�rururx�_namedtuple_mro_entriesp s r�cKs�|tur|r d}d}n4d}d|�d|�d�}d|d}n"|d ur9|r'td ��d }d|�d|�d�}d|d}n|r?td ��|tusG|d urXtj|j|d d�tdd�|��}t||t�d�}t f|_ |S)aoTyped 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. r2Nz\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 bothz3.15)r�r�rr�rq) r�r�r�r��formatr�r�r�rrro)r�r�r�r�r�r��ntrururxrt sH������ �c@seZdZdZdS)ra�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�rurururxr� sr0cCs8z |j�d|j�WStytdt|�j���d�w)aReturn 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,) roz"Expected an instance of type, not N)rrrCr�r�r�r|r;rururxr0� s ���c@sVeZdZdZdd�Zdd�Zdd�Zdd �Zd d �Ze j d kr)d d�Z dd�Z dSdS)r7aLNewType 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 cCs|Sr�rur�rururxr^ rzzNewType.__call__cCsD||_d|vr|�d�d}||_||_t�}|dkr ||_dSdS)Nr2r r)r~� rpartitionr|� __supertype__rr})rwr�rtr�rururxr� s �zNewType.__init__cs|j�G�fdd�d�}|fS)NcseZdZ�fdd�ZdS)z&NewType.__mro_entries__.<locals>.Dummycs"|j}td|�d|�d��d���)NzGCannot subclass an instance of NewType. Perhaps you were looking for: `z = NewType(r�z)`)r|r�)r�Z subcls_name�Z supercls_namerurxrA s����z8NewType.__mro_entries__.<locals>.Dummy.__init_subclass__N)r|r}r~rArur�rurx�Dummy sr�r )rwr-r�rur�rxr_ s zNewType.__mro_entries__cCs|j�d|j��S)Nr2)r}r~rvrururxry% r�zNewType.__repr__cCr r�)r~rvrururxr�( rzNewType.__reduce__r�cCr-r�r.r�rururxr// r�zNewType.__or__cCr0r�r.r�rururxr12 r�zNewType.__ror__N) r|r}r~r�r^r�r_ryr�rrGr/r1rurururxr7� s    �r7r@cCs|dupt|ttjtjtf�S)z:Corresponds to is_unionable() in unionobject.c in CPython.N)r�r�r�r�r�r@r8rururx� _is_unionable9 s �r�cs�eZdZdZdd�defdd�Zdededd f�fd d � Zdedefd d �Z dedefdd�Z defdd�Z dd�Z dd�Z dd�Zdd�ZejdkrWdd�Zdd�Z�ZS�ZS)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�cCstt|t�s td��||_||_g}|D]}t|t�r |�|�q|�|�qt|�|_ t �}|dkr5||_ ||_ dS)Nz#TypeAliasType name must be a stringr) r�r�r�� __value__�__type_params__r r�r�r�r�rr}r|)rwr�r�r�r�r�r�rururxr�^ s      zTypeAliasType.__init__r�r:Ncs&t|d�r |�|�t��||�dS)Nr|)r�_raise_attribute_errorr�r�)rwr�r�r�rurxr�q s  zTypeAliasType.__setattr__cCs|�|�dSr�)r��rwr�rururx� __delattr__v r�zTypeAliasType.__delattr__cCs8|dkrtd��|dvrtd|�d���td|�d���)Nr|zreadonly attribute>r�r�r�r}z attribute 'z3' of 'typing.TypeAliasType' objects is not writablez0'typing.TypeAliasType' object has no attribute '�')r�r�rururxr�y s � �z$TypeAliasType._raise_attribute_errorcCr r�r rvrururxry� rzTypeAliasType.__repr__cs2t|t�s|f}�fdd�|D�}t��t|��S)Ncs"g|] }t�|d�j�d���qS)z Subscripting z requires a type.)r�r�r|)r�rrvrurxrv� s ���z-TypeAliasType.__getitem__.<locals>.<listcomp>)r�r�r�r�r�rurvrxr�� s  �zTypeAliasType.__getitem__cCr r�r rvrururxr�� rzTypeAliasType.__reduce__cOr�)NzEtype 'typing_extensions.TypeAliasType' is not an acceptable base typer�r�rururxrA� s�zTypeAliasType.__init_subclass__cCr�)NzType alias is not callabler�rvrururxr^� r�zTypeAliasType.__call__r�cCst|�stStj||fSr��r�r�r�rj)rwrKrururxr/� szTypeAliasType.__or__cCst|�stStj||fSr�r�)rwrJrururxr1� szTypeAliasType.__ror__)r|r}r~r�r�r�r�r�rDr�r�ryr�r�rAr^rrGr/r1r�rurur�rxr@B s  �r4rtcCs(t|t�ot|dd�o|tuo|tjuS)aZReturn 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�rururxr4� s  ���cCs6t|�s t|�d���t|d�rt|j�Stt|��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 )r4r�rr�r rr�rururxr1� s    r1r+c@sPeZdZdZdeddfdd�Zdefdd�Zdefd d �Zd e de fd d �Z dS)r+afDefine 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: ... � documentationr:NcCr�r��r�)rwr�rururxr�� r�z Doc.__init__cCsd|j�d�S)NzDoc(�)r�rvrururxry� r�z Doc.__repr__cCs t|j�Sr�)r�r�rvrururxr�� r�z Doc.__hash__r�cCr�r�)r�r+r�r�r�rururxr�� r�z Doc.__eq__) r|r}r~r�r�r�ryr<r�r�r�r�rurururxr+� s � CapsuleType�CAPI)r)ro)NNFr�)ru)�r r=�collections.abcrr!r6r�rror�r�r��__all__ZPEP_560r�Z GenericMetarGZ_PEP_696_IMPLEMENTEDrsr�r�rEr r�r�r�r�r�rr�rr&r�rr-r3r6r�r�r�r�r�r�rr8r,r(� defaultdict�partialr~r�r rrrrrrrrrr>rCrrrrRr�r�r�r�Z _NoneTyperrbr�rr*r��EXCLUDED_ATTRIBUTESrrrr:r"r%r(r)rqr4rSr=r<r#r!r rr"rr$rgZ_PEP_728_IMPLEMENTEDrrkr5� signaturer�r�r�rjr�r�r�r'r2r�r%r�r/r.r�� ImportErrorr�r�r?rar�r�r�r�r�r�rr r�rr�rrrrrrArrBr%�_Finalrr rDrGrHr5rFr7r;rr9r:r<rBr rDr;rVr&r)rirjrLr9r`r*rar�r�r�r�r�r�rr�� _prohibitedr�r�r�r�r�r�ABC�register� memoryview� bytearrayrXr0r7r@r�r4r1rQr�r+Z _CapsuleType�_socketZ_CAPIr�r�rIrJrKrMrNrOrPrTrUrVrWrXrYrZr[r\r]r^r_r`rcrdrerfrgrhrkrlrmrnrurururx�<module>s�|                �(  �2� � � � �   d  5    y  X     ,'= � �  �  '  1 f!   �  /� . )�) +        ��  � *      > N   ����� ��� � � V $  ," & 8  F B      <  n  �    
Memory