Viewing File: /opt/alt/python37/lib/python3.7/site-packages/__pycache__/typing_extensions.cpython-37.pyc

B

E�_G�@s
ddlZddlZddlZddlZddlZddlmZddlZddlmZm	Z	m
Z
mZejdd�dkZ
e
rteZZnddlmZmZdZyddlmZmZmZWnek
r�dZYnXydd	lmZdZWnek
r�dZYnXydd
lmZWnek
�rdd�ZYnXydd
lmZmZWn2ek
�r^Gdd�d�ZGdd�d�ZYnXdd�Zdd�Zeed��r�ejZndd�Zeed��r�ddlmZdZ ndZdZ ejdd�dk�r�ddl!Z!e!j"Z#ndd�Z#ddd d!d"d#d$d%d&d'd(d)d*d+d,d-gZ$e
�p
eZ%e
�r"e$�&d.d/d0g�e%�r2e$�'d1�ejdd�d2kZ(e(�rZe$�&d3d4d5g�eed6��rnej)Z)nXeed7��r�Gd8d9�d9ej*dd:�Z+e+dd:�Z)n*Gd;d<�d<ej�Z,Gd=d6�d6ej-e,dd>�Z)e�
d?�Z.e�
d@�Z/e�
dA�Z0ej
dBddC�Z1ej
dDddC�Z2ej
dEddC�Z3ej
dFddG�Z4eed��r0ej5Z5nXeed7��r^GdHdI�dIej*dd:�Z6e6dd:�Z5n*GdJdK�dKej�Z7GdLd�dej-e7dd>�Z5eed��r�ejdd�dMk�r�ej-Z-n�ejdd�dMk�r�GdNdO�dOej8dd:�Z9e9ddPdQ�Z-nXeed7��rGdRdS�dSej*dd:�Z:e:dd:�Z-n*GdTdU�dUej�Z;GdVd�dej-e;dd>�Z-eed'��rTej<Z<ndWd'�Z<dXd(�Z=eed)��rxej>Z>n�ejdd�dMk�r�GdYdZ�dZej8dd:�Z?e?d)d[dQ�Z>nXeed7��r�Gd\d]�d]ej*dd:�Z@e@dd:�Z>n*Gd^d_�d_ej�ZAGd`d)�d)ej-eAdd>�Z>dadb�ZBdcd+�ZCeed ��r,ejDZDn*ej
dddede�ZEGdfd �d ejeEedg�ZDdhdi�ZFGdjdk�dke�ZGeFdl��r�Gdmdl�dleje1eGejHdn�ZHeFdo��r�Gdpdo�doeHe2eje1e4e2feGejIdn�ZIeFdq��r�Gdrdq�dqeje1eGejJdn�ZJeFds��rGdtds�dseJe1eGejKdn�ZKeed#��r,ejLZLnLe �rVGdud#�d#ejMejNe.eGejMdn�ZLn"Gdvd#�d#ejMejNe.eGejMdn�ZLeed!��r�ejOZOnBeedw��r�Gdxd!�d!eje1eGejPdn�ZOnGdyd!�d!eje1�ZOeedz��r�ejQZQe$�'dz�nReed{��r"Gd|dz�dzeje1eGejRdn�ZQe$�'dz�nejdd�d}k�r>eSd~�eed$��rRejTZTnTe �r�Gdd$�d$ejUejVe/e0feGejUdn�ZTn&Gd�d$�d$ejUejVe/e0feGejUdn�ZTeed"��r�ejWZWn�d2ejdd�k�r�d�k�r.nnNe �s�tX�e�
d��ZYGd�d��d�ej�ZZGd�d"�d"ejWej[e.e\feZejWdn�ZWnTe �r\Gd�d"�d"ejWej[e.e\feGejWdn�ZWn&Gd�d"�d"ejWej[e.e\feGejWdn�ZWeed���r�ej]Z]e$�'d��njeed���	r
e �r�Gd�d��d�ej]ejVe/e0feGej]dn�Z]n&Gd�d��d�ej]ejVe/e0feGej]dn�Z]e$�'d��eFd���	r<Gd�d��d�eKe1eje1e4feGej^dn�Z^eed*��	rPej_Z_nd�d*�Z_eed,��	rlej`Z`neaZ`eed-��	r�ejbZbndZbd�d��Zce�	r�d�d��Zd�dld�d�dqdsd�d�d�d�d�d!dzg
Zdd�d��Zed�d��Zfeed3��	r�ejgZgn�e(�
r6e
�
s6Gd�d��d�e�ZhGd�d3�d3ehd��Zgegjidk	�
rtegjijje�
r*d�nd�d��eg_in>e
�
rtdd�lmZmkZkmlZlGd�d��d�ejm�ZhGd�d3�d3ehd��Zgeed5��
r�ejnZnne(�
r�d�d5�Zne(�
r�enZoeed&��
r�ejpZpne(�
r�enGd�d&�d&eg��Zpejdd�d�k�
r�ejqZqnTd�d��Zrd�d��Zsd�es_tdd��d�d��Zud�eu_tGd�d��d�e�Zvevd%ewfi�Zqexeq_yd�eq_ieed1��r^ejzZzej{Z{ej|Z|npe
�r�Gd�d��d�ejkdd:�Z|Gd�d1�d1�Zzd�d��Z}d�d�d0�Z{n2e%�r�d�d��Z~Gd�d��d�ej�ZGd�d1�d1ed��Zzejdd�d�k�r�ej�Z�ej�Z�n"e
�rdd�lmkZkd�d/�Z�d�d.�Z�eedŃ�r&ej�Z�n�ejdd�d�k�r^Gd�dDŽd�ej8dd:�Z�e�d�dń�Z�n�ejdd�dMk�r�Gd�dDŽd�ej8dd:�Z�e�d�d�dQ�Z�nheed7��r�Gd�d̄d�ej�Z�Gd�d΄d�ej*e�dd>�Z�e�dd:�Z�n&Gd�d̄d�ej�Z�Gd�dńd�e�dd>�Z�dS)��N)�Generic�Callable�TypeVar�Tuple�)r�r)�GenericMeta�
TypingMetaF)�
_type_vars�_next_in_mro�_type_checkT)�
_subs_tree)�	_tp_cachecCs|S)N�)�xrr�B/opt/alt/python37/lib/python3.7/site-packages/typing_extensions.pyr$sr)�_TypingEllipsis�_TypingEmptyc@seZdZdS)rN)�__name__�
__module__�__qualname__rrrrr)src@seZdZdS)rN)rrrrrrrr,srcCs2t|�}d|kr.x|dD]}|�|d�qW|S)N�	__slots__)�dict�pop)�dctZ	dict_copyZslotrrr�_no_slots_copy4s
rcCsX|jstdt|���t|�}t|j�}||krTtd||kr@dndt|�||f��dS)Nz%s is not a generic classz0Too %s parameters for %s; actual %s, expected %s�many�few)�__parameters__�	TypeError�repr�len)�cls�
parameters�alen�elenrrr�_check_generic<s
r&�_generic_newcOs|j|f|�|�S)N)�__new__)Zbase_clsr"�args�kwargsrrrr'Vs�_geqv)r+�)r�cGsH|j}x<|D]4}x.|D]"}||jkr|j|dkr6tSPqWtSqWdS)NT)�__mro__�__dict__�NotImplemented)�C�methods�mro�method�Brrr�_check_methods_in_mroes


r6�ClassVar�Final�Type�ContextManager�Counter�Deque�DefaultDict�	TypedDict�
SupportsIndex�final�IntVar�Literal�NewType�overload�Text�
TYPE_CHECKING�get_args�
get_origin�get_type_hints�	Annotated)r�r�Protocol�runtime�runtime_checkable�NoReturn�_FinalTypingBasec@s$eZdZdZdZdd�Zdd�ZdS)�	_NoReturna7Special type indicating functions that never return.
        Example::

          from typing import NoReturn

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

        This type is invalid in other positions, e.g., ``List[NoReturn]``
        will fail in static type checkers.
        rcCstd��dS)Nz*NoReturn cannot be used with isinstance().)r)�self�objrrr�__instancecheck__�sz_NoReturn.__instancecheck__cCstd��dS)Nz*NoReturn cannot be used with issubclass().)r)rRr"rrr�__subclasscheck__�sz_NoReturn.__subclasscheck__N)rrr�__doc__rrTrUrrrrrQ�srQ)�_rootcs2eZdZdZd	�fdd�	Zdd�Zdd�Z�ZS)
�
_NoReturnMetazMetaclass for NoReturnFcst�j|||||d�S)N)rW)�superr()r"�name�bases�	namespacerW)�	__class__rrr(�sz_NoReturnMeta.__new__cCstd��dS)Nz*NoReturn cannot be used with isinstance().)r)rRrSrrrrT�sz_NoReturnMeta.__instancecheck__cCstd��dS)Nz*NoReturn cannot be used with issubclass().)r)rRr"rrrrU�sz_NoReturnMeta.__subclasscheck__)F)rrrrVr(rTrU�
__classcell__rr)r]rrX�srXc@seZdZdZdZdS)rOa7Special type indicating functions that never return.
        Example::

          from typing import NoReturn

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

        This type is invalid in other positions, e.g., ``List[NoReturn]``
        will fail in static type checkers.
        rN)rrrrVrrrrrrO�s)�	metaclassrW�T�KT�VT�T_co)�	covariant�V_co�VT_co�T_contra)�
contravariantcsNeZdZdZdZddd�Zdd�Zdd	�Z�fd
d�Zdd
�Z	dd�Z
�ZS)�	_ClassVara[Special type construct to mark class variables.

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

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

        ClassVar accepts only types and cannot be further subscribed.

        Note that ClassVar is not a class itself, and should not
        be used with isinstance() or issubclass().
        )�__type__NcKs
||_dS)N)rj)rR�tp�kwdsrrr�__init__�sz_ClassVar.__init__c	CsRt|�}|jdkr6|t�|d�|jdd���dd�Std�|jdd����dS)Nz{} accepts only single type.�T)rWz {} cannot be further subscripted)�typerj�typingr�formatrr)rR�itemr"rrr�__getitem__s
z_ClassVar.__getitem__cCs.t�|j||�}||jkr|St|�|dd�S)NT)rW)rp�
_eval_typerjro)rR�globalns�localns�new_tprrrrt
s
z_ClassVar._eval_typecs.t���}|jdk	r*|d�t�|j��7}|S)Nz[{}])rY�__repr__rjrqrp�
_type_repr)rR�r)r]rrrxs

z_ClassVar.__repr__cCstt|�j|jf�S)N)�hashrorrj)rRrrr�__hash__sz_ClassVar.__hash__cCs,t|t�stS|jdk	r$|j|jkS||kS)N)�
isinstancerir0rj)rR�otherrrr�__eq__s


z_ClassVar.__eq__)N)rrrrVrrmrsrtrxr|rr^rr)r]rri�s
	rics^eZdZdZd�fdd�	Zdd�Zdd	�Zd
d�Zdd
�Z�fdd�Z	dd�Z
dd�Z�ZS)�
_ClassVarMetazMetaclass for ClassVarNFcs(t�j|||||d�}|dk	r$||_|S)N)rW)rYr(rj)r"rZr[r\rkrWrR)r]rrr(%sz_ClassVarMeta.__new__cCstd��dS)Nz*ClassVar cannot be used with isinstance().)r)rRrSrrrrT+sz_ClassVarMeta.__instancecheck__cCstd��dS)Nz*ClassVar cannot be used with issubclass().)r)rRr"rrrrU.sz_ClassVarMeta.__subclasscheck__cCsbt|�}|jdk	r*td�|jdd����t�|d�|jdd���}||j|jt|j	�|dd�S)Nz {} cannot be further subscriptedrnz{} accepts only single type.T)rkrW)
rorjrrqrrpr�	__bases__rr/)rRrrr"�paramrrrrs1s

z_ClassVarMeta.__getitem__cCs@t�|j||�}||jkr|St|�|j|jt|j�|jdd�S)NT)rkrW)rprtrjrorr�rr/)rRrurvrwrrrrt=s
z_ClassVarMeta._eval_typecs.t���}|jdk	r*|d�t�|j��7}|S)Nz[{}])rYrxrjrqrpry)rRrz)r]rrrxEs

z_ClassVarMeta.__repr__cCstt|�j|jf�S)N)r{rorrj)rRrrrr|Ksz_ClassVarMeta.__hash__cCs,t|t�stS|jdk	r$|j|jkS||kS)N)r}r7r0rj)rRr~rrrrNs


z_ClassVarMeta.__eq__)NF)
rrrrVr(rTrUrsrtrxr|rr^rr)r]rr�"sr�c@seZdZdZdZdS)r7a[Special type construct to mark class variables.

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

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

        ClassVar accepts only types and cannot be further subscribed.

        Note that ClassVar is not a class itself, and should not
        be used with isinstance() or issubclass().
        N)rrrrVrjrrrrr7Us)rrc@seZdZdd�Zdd�ZdS)�
_FinalFormcCs
d|jS)Nztyping_extensions.)�_name)rRrrrrxnsz_FinalForm.__repr__cCs t�|d�|j��}t||f�S)Nz{} accepts only single type)rprrqr��
_GenericAlias)rRr#rrrrrrsqsz_FinalForm.__getitem__N)rrrrxrsrrrrr�lsr�aWA special typing construct to indicate that a name
                       cannot be re-assigned or overridden in a subclass.
                       For example:

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

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

                       There is no runtime checking of these properties.)�doccsNeZdZdZdZddd�Zdd�Zdd	�Z�fd
d�Zdd
�Z	dd�Z
�ZS)�_Finala�A special typing construct to indicate that a name
        cannot be re-assigned or overridden in a subclass.
        For example:

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

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

        There is no runtime checking of these properties.
        )rjNcKs
||_dS)N)rj)rRrkrlrrrrm�sz_Final.__init__c	CsRt|�}|jdkr6|t�|d�|jdd���dd�Std�|jdd����dS)Nz{} accepts only single type.rnT)rWz {} cannot be further subscripted)rorjrprrqrr)rRrrr"rrrrs�s
z_Final.__getitem__cCs.t�|j||�}||jkr|St|�|dd�S)NT)rW)rprtrjro)rRrurvrwrrrrt�s
z_Final._eval_typecs.t���}|jdk	r*|d�t�|j��7}|S)Nz[{}])rYrxrjrqrpry)rRrz)r]rrrx�s

z_Final.__repr__cCstt|�j|jf�S)N)r{rorrj)rRrrrr|�sz_Final.__hash__cCs,t|t�stS|jdk	r$|j|jkS||kS)N)r}r�r0rj)rRr~rrrr�s


z
_Final.__eq__)N)rrrrVrrmrsrtrxr|rr^rr)r]rr��s
	r�cs^eZdZdZd�fdd�	Zdd�Zdd	�Zd
d�Zdd
�Z�fdd�Z	dd�Z
dd�Z�ZS)�
_FinalMetazMetaclass for FinalNFcs(t�j|||||d�}|dk	r$||_|S)N)rW)rYr(rj)r"rZr[r\rkrWrR)r]rrr(�sz_FinalMeta.__new__cCstd��dS)Nz'Final cannot be used with isinstance().)r)rRrSrrrrT�sz_FinalMeta.__instancecheck__cCstd��dS)Nz'Final cannot be used with issubclass().)r)rRr"rrrrU�sz_FinalMeta.__subclasscheck__cCsbt|�}|jdk	r*td�|jdd����t�|d�|jdd���}||j|jt|j	�|dd�S)Nz {} cannot be further subscriptedrnz{} accepts only single type.T)rkrW)
rorjrrqrrprr�rr/)rRrrr"r�rrrrs�s

z_FinalMeta.__getitem__cCs@t�|j||�}||jkr|St|�|j|jt|j�|jdd�S)NT)rkrW)rprtrjrorr�rr/)rRrurvrwrrrrt�s
z_FinalMeta._eval_typecs.t���}|jdk	r*|d�t�|j��7}|S)Nz[{}])rYrxrjrqrpry)rRrz)r]rrrx�s

z_FinalMeta.__repr__cCstt|�j|jf�S)N)r{rorrj)rRrrrr|�sz_FinalMeta.__hash__cCs,t|t�stS|jdk	r$|j|jkS||kS)N)r}r8r0rj)rRr~rrrr�s


z_FinalMeta.__eq__)NF)
rrrrVr(rTrUrsrtrxr|rr^rr)r]rr��sr�c@seZdZdZdZdS)r8a�A special typing construct to indicate that a name
        cannot be re-assigned or overridden in a subclass.
        For example:

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

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

        There is no runtime checking of these properties.
        N)rrrrVrjrrrrr8�scCs|S)auThis decorator can be used to indicate to type checkers that
        the decorated method cannot be overridden, and decorated class
        cannot be subclassed. For example:

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

        There is no runtime checking of these properties.
        r)�frrrr@scCst|�S)N)r)rZrrrrAsc@seZdZdd�Zdd�ZdS)�_LiteralFormcCs
d|jS)Nztyping_extensions.)r�)rRrrrrx$sz_LiteralForm.__repr__cCs
t||�S)N)r�)rRr#rrrrs'sz_LiteralForm.__getitem__N)rrrrxrsrrrrr�"sr�aoA 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.csNeZdZdZdZddd�Zdd�Zdd	�Z�fd
d�Zdd
�Z	dd�Z
�ZS)�_Literala�A type that can be used to indicate to type checkers that the
        corresponding value has a value literally equivalent to the
        provided parameter. For example:

            var: Literal[4] = 4

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

        Literal[...] cannot be subclassed. There is no runtime checking
        verifying that the parameter is actually a value instead of a type.
        )�
__values__NcKs
||_dS)N)r�)rR�valuesrlrrrrmHsz_Literal.__init__cCsJt|�}|jdkr.t|t�s"|f}||dd�Std�|jdd����dS)NT)rWz {} cannot be further subscriptedrn)ror�r}�tuplerrqr)rRr�r"rrrrsKs

z_Literal.__getitem__cCs|S)Nr)rRrurvrrrrtTsz_Literal._eval_typecs6t���}|jdk	r2|d�d�ttj|j���7}|S)Nz[{}]z, )rYrxr�rq�join�maprpry)rRrz)r]rrrxWs

z_Literal.__repr__cCstt|�j|jf�S)N)r{rorr�)rRrrrr|]sz_Literal.__hash__cCs,t|t�stS|jdk	r$|j|jkS||kS)N)r}r�r0r�)rRr~rrrr`s


z_Literal.__eq__)N)rrrrVrrmrsrtrxr|rr^rr)r]rr�8s
	r�cs^eZdZdZd�fdd�	Zdd�Zdd	�Zd
d�Zdd
�Z�fdd�Z	dd�Z
dd�Z�ZS)�_LiteralMetazMetaclass for LiteralNFcs(t�j|||||d�}|dk	r$||_|S)N)rW)rYr(r�)r"rZr[r\r�rWrR)r]rrr(lsz_LiteralMeta.__new__cCstd��dS)Nz)Literal cannot be used with isinstance().)r)rRrSrrrrTrsz_LiteralMeta.__instancecheck__cCstd��dS)Nz)Literal cannot be used with issubclass().)r)rRr"rrrrUusz_LiteralMeta.__subclasscheck__cCsVt|�}|jdk	r*td�|jdd����t|t�s:|f}||j|jt|j	�|dd�S)Nz {} cannot be further subscriptedrnT)r�rW)
ror�rrqrr}r�r�rr/)rRrrr"rrrrsxs


z_LiteralMeta.__getitem__cCs|S)Nr)rRrurvrrrrt�sz_LiteralMeta._eval_typecs6t���}|jdk	r2|d�d�ttj|j���7}|S)Nz[{}]z, )rYrxr�rqr�r�rpry)rRrz)r]rrrx�s

z_LiteralMeta.__repr__cCstt|�j|jf�S)N)r{rorr�)rRrrrr|�sz_LiteralMeta.__hash__cCs,t|t�stS|jdk	r$|j|jkS||kS)N)r}rBr0r�)rRr~rrrr�s


z_LiteralMeta.__eq__)NF)
rrrrVr(rTrUrsrtrxr|rr^rr)r]rr�isr�c@seZdZdZdZdS)rBa�A type that can be used to indicate to type checkers that the
        corresponding value has a value literally equivalent to the
        provided parameter. For example:

            var: Literal[4] = 4

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

        Literal[...] cannot be subclassed. There is no runtime checking
        verifying that the parameter is actually a value instead of a type.
        N)rrrrVr�rrrrrB�scOstd��dS)z*Helper for @overload to raise when called.z�You should not call an overloaded function. A series of @overload-decorated functions outside a stub module should always be followed by an implementation that is not @overload-ed.N)�NotImplementedError)r)rlrrr�_overload_dummy�sr�cCstS)a
Decorator for overloaded functions/methods.

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

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

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

      @overload
      def utf8(value: None) -> None: ...
      @overload
      def utf8(value: bytes) -> bytes: ...
      @overload
      def utf8(value: str) -> bytes: ...
      def utf8(value):
          # implementation goes here
    )r�)�funcrrrrD�s�CT_co)rd�boundc@seZdZdZdZdS)r9a�A special construct usable to annotate class objects.

        For example, suppose we have the following classes::

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

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

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

        At this point the type checker knows that joe has type BasicUser.
        rN)rrrrVrrrrrr9�s)�extracCsHtt|�r(t�|�tt|�t�|<dStt|�r@t�|�dSdSdS)z�
    Returns True if the given type isn't defined in typing but
    is defined in collections_abc.

    Adds the type to __all__ if the collection is found in either
    typing or collection_abc.
    FTN)�hasattrrp�__all__�append�getattr�globals�collections_abc)Z	type_namerrr�
_define_guard�s



r�cseZdZ�fdd�Z�ZS)�_ExtensionsGenericMetacs�tjdd�dks$tjdd�dkrN|jdk	rNt�d�jddkrJtd��d	S|js`t��|�S|j�	|�}|t
k	rx|S|j|jkr�d
Sx,|j��D]}t
|t�r�q�t||�r�d
Sq�Wd	S)a*This mimics a more modern GenericMeta.__subclasscheck__() logic
        (that does not have problems with recursion) to work around interactions
        between collections, typing, and typing_extensions on older
        versions of Python, see https://github.com/python/typing/issues/501.
        Nr)rrKr)rrKrrnr)�abc�	functoolszCParameterized generics cannot be used with class or instance checksFT)�sys�version_info�
__origin__�	_getframe�	f_globalsr�	__extra__rYrU�__subclasshook__r0r.�__subclasses__r}r�
issubclass)rR�subclass�resZscls)r]rrrUs$$


z(_ExtensionsGenericMeta.__subclasscheck__)rrrrUr^rr)r]rr�sr��	Awaitablec@seZdZdZdS)r�rN)rrrrrrrrr�!s)r_r��	Coroutinec@seZdZdZdS)r�rN)rrrrrrrrr�'s�
AsyncIterablec@seZdZdZdS)r�rN)rrrrrrrrr�.s�
AsyncIteratorc@seZdZdZdS)r�rN)rrrrrrrrr�5sc@seZdZdZdd�ZdS)r<rcOs*t|t�rtj||�Sttj|f|�|�S)N)r+r<�collections�dequer')r"r)rlrrrr(Cs
z
Deque.__new__N)rrrrr(rrrrr<>sc@seZdZdZdd�ZdS)r<rcOs*|jtkrtj||�Sttj|f|�|�S)N)�_gorgr<r�r�r')r"r)rlrrrr(Ms
z
Deque.__new__N)rrrrr(rrrrr<Hs�AbstractContextManagerc@seZdZdZdS)r:rN)rrrrrrrrr:Vsc@s2eZdZdZdd�Zejdd��Zedd��Z	dS)	r:rcCs|S)Nr)rRrrr�	__enter__^szContextManager.__enter__cCsdS)Nr)rR�exc_type�	exc_value�	tracebackrrr�__exit__aszContextManager.__exit__cCs8|tkr4tdd�|jD��r4tdd�|jD��r4dStS)Ncss|]}d|jkVqdS)r�N)r/)�.0r5rrr�	<genexpr>msz2ContextManager.__subclasshook__.<locals>.<genexpr>css|]}d|jkVqdS)r�N)r/)r�r5rrrr�nsT)r:�anyr.r0)r"r1rrrr�es
zContextManager.__subclasshook__N)
rrrrr�r��abstractmethodr��classmethodr�rrrrr:[s�AsyncContextManager�AbstractAsyncContextManagerc@seZdZdZdS)r�rN)rrrrrrrrr�ws)rrKa�
class AsyncContextManager(typing.Generic[T_co]):
    __slots__ = ()

    async def __aenter__(self):
        return self

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

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

__all__.append('AsyncContextManager')
c@seZdZdZdd�ZdS)r=rcOs*t|t�rtj||�Sttj|f|�|�S)N)r+r=r��defaultdictr')r"r)rlrrrr(�s
zDefaultDict.__new__N)rrrrr(rrrrr=�sc@seZdZdZdd�ZdS)r=rcOs*|jtkrtj||�Sttj|f|�|�S)N)r�r=r�r�r')r"r)rlrrrr(�s
zDefaultDict.__new__N)rrrrr(rrrrr=�s)rrKrn�_TIntcs eZdZdZ�fdd�Z�ZS)�_CounterMetazMetaclass for Countercst��|tf�S)N)rYrs�int)rRrr)r]rrrs�sz_CounterMeta.__getitem__)rrrrVrsr^rr)r]rr��sr�c@seZdZdZdd�ZdS)r;rcOs*t|t�rtj||�Sttj|f|�|�S)N)r+r;r�r')r"r)rlrrrr(�s
zCounter.__new__N)rrrrr(rrrrr;�sc@seZdZdZdd�ZdS)r;rcOs*t|t�rtj||�Sttj|f|�|�S)N)r+r;r�r')r"r)rlrrrr(�s
zCounter.__new__N)rrrrr(rrrrr;�sc@seZdZdZdd�ZdS)r;rcOs*|jtkrtj||�Sttj|f|�|�S)N)r�r;r�r')r"r)rlrrrr(�s
zCounter.__new__N)rrrrr(rrrrr;�s�ChainMapc@seZdZdZdd�ZdS)r�rcOs*t|t�rtj||�Sttj|f|�|�S)N)r+r�r�r')r"r)rlrrrr(�s
zChainMap.__new__N)rrrrr(rrrrr��sc@seZdZdZdd�ZdS)r�rcOs*|jtkrtj||�Sttj|f|�|�S)N)r�r�r�r')r"r)rlrrrr(�s
zChainMap.__new__N)rrrrr(rrrrr��s�AsyncGeneratorc@seZdZdZdS)r�rN)rrrrrrrrr��scCsdd�}||_||_|S)aQNewType creates simple unique types with almost zero
        runtime overhead. NewType(name, tp) is considered a subtype of tp
        by static type checkers. At runtime, NewType(name, tp) returns
        a dummy function that simply returns its argument. Usage::

            UserId = NewType('UserId', int)

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

            UserId('user')          # Fails type check

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

            num = UserId(5) + 1     # type: int
        cSs|S)Nr)rrrr�new_typeszNewType.<locals>.new_type)r�
__supertype__)rZrkr�rrrrCscCs8t|t�st�t|d�r|jSx|jdk	r2|j}q W|S)z@This function exists for compatibility with old typing versions.r�N)r}r�AssertionErrorr�r�r�)r"rrrr�.s

r�cCsLt}xBt|jdd��D],\}}t|t�rt|�tkr|j|d}qW|S)z@This function exists for compatibility with old typing versions.N���rn)�object�	enumerater.r}rr�r)r"Znext_in_mro�i�crrrr9s
rr�Iterable�Iterator�Hashable�Sized�	Container�
Collection�
ReversiblecCszt�}xn|jdd�D]\}|jdkr&qt|di�}x>t|j���t|���D] }|�d�sN|dkrN|�|�qNWqW|S)Nr�)rLr�__annotations__�_abc_)�__abstractmethods__r��__weakref__�_is_protocol�_is_runtime_protocolr/�__args__r�__next_in_mro__rr��__orig_bases__r��
__tree_hash__rVr�rmr(r�_MutableMapping__markerr�)	�setr.rr��listr/�keys�
startswith�add)r"�attrs�base�annotations�attrrrr�_get_protocol_attrsHs
 r�cst�fdd�t��D��S)Nc3s|]}tt�|d��VqdS)N)�callabler�)r�r�)r"rrr�\sz,_is_callable_members_only.<locals>.<genexpr>)�allr�)r"r)r"r�_is_callable_members_only[sr�csZeZdZdZesd
�fdd�	Z�fdd�Z�fdd�Z�fd	d
�ZesRe	dd��Z
�ZS)�
_ProtocolMetaz�Internal metaclass for Protocol.

        This exists so Protocol classes can be generic without deriving
        from Generic.
        Nc	sL|dkst�|dk	r<|dk	s t�tdd�|D��s:t|��n�t|�}d}	xJ|D]B}
|
tkrbtd��t|
t�rN|
jttfkrN|	dk	r�td��|
j	}	qNW|	dkr�|}	njt
|�}t
|	��|�k�stdd��fdd�|D��tdd�|D��r�d	nd
d�dd�|	D��f��|	}|}|dk	�r>t
|�tjk�r>||k�r>|f|}tdd�|D��}td
d�|D���rvtdd�|D��}|�||d��tt|�j||||dd�}
tt|
��d|�s�|
nt|��||
_	|�r�tdd�|D��nd|
_t|
�|
_|dk�r||
_n|dk	�r|j|
_|j|
_t|
d��rH|�r8t|
���ntt|
���|
_ |
S)Ncss|]}t|t�VqdS)N)r}r)r��trrrr�psz(_ProtocolMeta.__new__.<locals>.<genexpr>z!Cannot inherit from plain GenericzACannot inherit from Generic[...] or Protocol[...] multiple times.z1Some type variables (%s) are not listed in %s[%s]z, c3s|]}|�krt|�VqdS)N)�str)r�r�)�gvarsetrrr��scss|]}|jtkVqdS)N)r�r)r��brrrr��srrLcss|]}t|�VqdS)N)r�)r��grrrr��scss$|]}t|t�rt|�n|VqdS)N)r}rr�)r�r�rrrr��scss |]}t|t�o|tk	VqdS)N)r}rr)r�r�rrrr��scss|]}|tk	r|VqdS)N)r)r�r�rrrr��s)r�r�T)rWr�css*|]"}|tkrdn|tkrdn|VqdS).rN)rr)r��arrrr��sr
)!r�r�r
rrr}rr�rLrr�r�r�ror��ABCMetar��updaterYr(�__setattr__r�r�rr�r��
_abc_registry�
_abc_cacher�r{r
r|r�)r"rZr[r\�tvarsr)�originr��
orig_bases�gvarsr��tvarsetZ
initial_basesrR)r])r�rr(isj











z_ProtocolMeta.__new__cs�t�j||��j�dd�s2tdd��jD���_�jr�xf�jdd�D]T}|tt	fksH|j
dkrl|jtksHt
|t�r||jsHt
|t�r�|jt	ksHtd|��qHWdd�}|�_�fd	d
�}d�jkr�|�_dS)Nr�css*|]"}|tkp t|t�o |jtkVqdS)N)rLr}r�r�)r�r�rrrr��sz)_ProtocolMeta.__init__.<locals>.<genexpr>rnzcollections.abcz7Protocols can only inherit from other protocols, got %rc_st|�jrtd��dS)Nz Protocols cannot be instantiated)ror�r)rRr)r*rrr�_no_init�s
z(_ProtocolMeta.__init__.<locals>._no_initcs��j�dd�stSt|t�s$td��xtt��D]h}xb|jD]T}||jkr\|j|dkrZtSPt|di�}t|t	j
�r:||kr:t|t�r:|jr:Pq:WtSq.WdS)Nr�z"issubclass() arg 1 must be a classr�T)
r/�getr0r}rorr�r.r�rp�Mappingr�r�)r~r�r�r�)r"rr�_proto_hook�s$


z+_ProtocolMeta.__init__.<locals>._proto_hookr�)rYrmr/rr�r�r�r.r�rrr�_PROTO_WHITELISTr}r	rr�rr�)r"r)r*r�r�r)r])r"rrm�s&




z_ProtocolMeta.__init__csZt�dd�rt��r$t�j��r$dS�jrJt��fdd�t��D��rJdStt���	��S)Nr�FTc3s8|]0}t�|�o.tt�|d��p.t�|�dk	VqdS)N)r�r�r�)r�r�)�instancerRrrr��sz2_ProtocolMeta.__instancecheck__.<locals>.<genexpr>)
r�r�r�r]r�r�r�rYrrT)rRr)r])rrRrrT�sz_ProtocolMeta.__instancecheck__cs�|jdk	r*t�d�jddkr&td��dS|j�dd�rf|j�dd�sft�d�jddkr^dStd	��|j�dd�r�t|�s�t�d�jddkr�tt	|��
|�Std
��tt	|��
|�S)Nrnr)r�r�zCParameterized generics cannot be used with class or instance checksFr�r�)r�r�rpzBInstance and class checks can only be used with @runtime protocolsz<Protocols with non-method members don't support issubclass())r�r�r�r�rr/rr�rYrrU)rRr")r]rrrU�s
z_ProtocolMeta.__subclasscheck__c
s,t|t�s|f}|s.t|�tk	r.td|j��d�t�fdd�|D��}|ttfkr�tdd�|D��srtd|��t	t
|��t	|�kr�td|��|}|}nP|ttfkr�t|�}|}n6|j
ttfkr�tdt|���nt||�t|�}|}|j
dkr�|fnd	}|j|j||jt|j�||||j|jd
�S)Nz)Parameter list to %s[...] cannot be emptyz*Parameters to generic types must be types.c3s|]}t|��VqdS)N)r)r��p)�msgrrr�sz,_ProtocolMeta.__getitem__.<locals>.<genexpr>css|]}t|t�VqdS)N)r}r)r�rrrrr�
sz0Parameters to %r[...] must all be type variablesz(Parameters to %r[...] must all be uniquez'Cannot subscript already-subscripted %sr)r�r)r�r�r�)r}r�r�rrrrrLr�r!r�rr
r�r r&r]rr�rr/r�r�)rR�paramsr�r)�prependr)rrrssD



z_ProtocolMeta.__getitem__)NNNNN)rrrrV�OLD_GENERICSr(rmrTrUrrsr^rr)r]rr�bs@/r�c@s eZdZdZdZdZdd�ZdS)rLa�Base class for protocol classes. Protocol classes are defined as::

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

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

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

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

          func(C())  # Passes static type check

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

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

          class GenProto({bases}):
              def meth(self) -> T:
                  ...
        rTcOsBt|�tkrtd��tr.tt|�|f|�|�St|j|f|�|�S)NzIType Protocol cannot be instantiated; it can be used only as a base class)r�rLrr	r'rr�)r"r)rlrrrr(Js
zProtocol.__new__N)rrrrVrr�r(rrrrrL*s)r_zProtocol, Generic[T]zProtocol[T])r[)rr��_collect_type_varscseZdZ�fdd�Z�ZS)r�csVt�dd�rt��r$t�j��r$dS�jrJt��fdd�t��D��rJdSt����S)Nr�FTc3s8|]0}t�|�o.tt�|d��p.t�|�dk	VqdS)N)r�r�r�)r�r�)r"rrrr�dsz2_ProtocolMeta.__instancecheck__.<locals>.<genexpr>)	r�r�r�r]r�r�r�rYrT)r"r)r])r"rrrT\sz_ProtocolMeta.__instancecheck__)rrrrTr^rr)r]rr�Yscs<eZdZdZdZdZ�fdd�Zedd��Zdd	�Z	�Z
S)
rLa�Base class for protocol classes. Protocol classes are defined as::

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

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

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

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

            func(C())  # Passes static type check

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

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

            class GenProto(Protocol[T]):
                def meth(self) -> T:
                    ...
        rTcs|tkrtd��t��|�S)NzIType Protocol cannot be instantiated; it can only be used as a base class)rLrrYr()r"r)rl)r]rrr(�szProtocol.__new__cs�t|t�s|f}|s,|tk	r,td�|j���d�t�fdd�|D��}|tkr�tdd�|D��s�d}xt||t�r~|d7}qfWtd�|d||���t	t
|��t	|�kr�td	��n
t||�t||�S)
Nz)Parameter list to {}[...] cannot be emptyz*Parameters to generic types must be types.c3s|]}t|��VqdS)N)r)r�r)rrrr��sz-Protocol.__class_getitem__.<locals>.<genexpr>css|]}t|t�VqdS)N)r}r)r�rrrrr��srrnzJParameters to Protocol[...] must all be type variables. Parameter {} is {}z.Parameters to Protocol[...] must all be unique)
r}r�rrrqrrLr�rr!r�r&r�)r"rr�r)rr�__class_getitem__�s(

zProtocol.__class_getitem__c
s�g}d�jkrt�jk}n
t�jk}|r0td��d�jk�rt�j�}d}xN�jD]D}t|t�rR|jtt	fkrR|jtkr|dnd}|dk	r�td��|j
}qRW|dkr�|}nZt|�}t|��|�ks�d��fdd�|D��}	d�d	d�|D��}
td
�
|	||
���|}t|��_
�j�dd��s2tdd��jD���_�fd
d�}d�jk�rP|�_�j�s\dSxV�jD]L}|ttfk�sd|jdk�r�|jtk�sdt|t��r�|j�sdtd|���qdWdd�}|�_dS)Nr�z!Cannot inherit from plain GenericrrLzECannot inherit from Generic[...] and/or Protocol[...] multiple types.z, c3s|]}|�krt|�VqdS)N)r�)r�r�)r�rrr��sz-Protocol.__init_subclass__.<locals>.<genexpr>css|]}t|�VqdS)N)r�)r�r�rrrr��sz1Some type variables ({}) are not listed in {}[{}]r�css|]}|tkVqdS)N)rL)r�r�rrrr��scs��j�dd�stSt�dd�s>t�d�jddkr6tStd��t��sft�d�jddkr^tStd��t	|t
�sxtd	��xtt��D]h}xb|jD]T}||jkr�|j|dkr�tSPt|d
i�}t	|t
j�r�||kr�t	|t�r�|jr�Pq�WtSq�WdS)Nr�r�Fr,r)r�r�zBInstance and class checks can only be used with @runtime protocolsz<Protocols with non-method members don't support issubclass()z"issubclass() arg 1 must be a classr�T)r/rr0r�r�r�r�rr�r}ror�r.rprr�r�)r~r�r�r�)r"rrr�s4


z/Protocol.__init_subclass__.<locals>._proto_hookr�zcollections.abcz7Protocols can only inherit from other protocols, got %rc_st|�jrtd��dS)Nz Protocols cannot be instantiated)ror�r)rRr)r*rrrr�
s
z,Protocol.__init_subclass__.<locals>._no_init)r/rr�r�rr
r}r�r�rLrr�r�rqr�rr�r�r�r�rrrr�rm)
r"r)r*r��errorr�r�Zthe_baser��s_vars�s_argsrr�r)r"r�r�__init_subclass__�sZ






zProtocol.__init_subclass__)rrrrVrr�r(rrrr^rr)r]rrLkscCs&t|t�r|jstd|��d|_|S)a4Mark a protocol class as a runtime protocol, so that it
        can be used with isinstance() and issubclass(). Raise TypeError
        if applied to a non-protocol class.

        This allows a simple-minded structural check very similar to the
        one-offs in collections.abc such as Hashable.
        zB@runtime_checkable can be only applied to protocol classes, got %rT)r}r�r�rr�)r"rrrrNs
c@s$eZdZdZejed�dd��ZdS)r?r)�returncCsdS)Nr)rRrrr�	__index__.szSupportsIndex.__index__N)rrrrr�r�r�rrrrrr?*s)r�	c	Cs>y t�d�jddkrtd��Wnttfk
r8YnXdS)Nrnr)r�r�rpz4TypedDict does not support instance and class checksF)r�r�r�r�AttributeError�
ValueError)r"r~rrr�_check_fails8srcOs,|std��|d|dd�}}t||�S)Nz)TypedDict.__new__(): not enough argumentsrrn)rr)r)r*�_rrr�	_dict_newCsrz,($cls, _typename, _fields=None, /, **kwargs))�totalc	OsX|std��|d|dd�}}|r>|d|dd�}}n4d|krj|�d�}ddl}|jdtdd�ntd��|r�y
|\}Wq�tk
r�td	�t|�d���Yq�Xn<d
|kr�t|�dkr�|�d
�}ddl}|jdtdd�nd}|dkr�|}n|�rtd��t|�|d
�}yt	�
d�j�dd�|d<Wnt
tfk
�rJYnXt|d|�S)Nz)TypedDict.__new__(): not enough argumentsrrnZ	_typenamez5Passing '_typename' as keyword argument is deprecatedr,)�
stacklevelzGTypedDict.__new__() missing 1 required positional argument: '_typename'zLTypedDict.__new__() takes from 2 to 3 positional arguments but {} were given�_fieldsz3Passing '_fields' as keyword argument is deprecatedz@TypedDict takes either a dict or keyword arguments, but not both)r��	__total__r�__main__rr)rr�warnings�warn�DeprecationWarningrrqr!rr�r�r�rr�_TypedDictMeta)rr)r*r�typenamer�fields�nsrrr�_typeddict_newKsB


r$z;($cls, _typename, _fields=None, /, *, total=True, **kwargs)cs&eZdZd�fdd�	ZeZZ�ZS)r Tcs|dkrtnt|d<tt|��||tf|�}i}|�di�}t|���}d��fdd�|�	�D�}t�}	t�}
xH|D]@}|�
|j�di��|	�
|j�dd��|
�
|j�d	d��qtW|�
|�|r�|	�
|�n
|
�
|�||_t
|	�|_t
|
�|_t|d
��s||_|S)Nr>r(r�z?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typecsi|]\}}t�|��|�qSr)rpr)r��nrk)rrr�
<dictcomp>�sz*_TypedDictMeta.__new__.<locals>.<dictcomp>�__required_keys__r�__optional_keys__r)r$rrYr r(rrr�r��itemsr�r/r��	frozensetr'r(r�r)r"rZr[r#rZtp_dictr�Zown_annotationsZown_annotation_keysZ
required_keysZ
optional_keysr�)r])rrr({s0





z_TypedDictMeta.__new__)T)rrrr(rrTrUr^rr)r]rr zs&r a�A simple typed name space. At runtime it is equivalent to a plain dict.

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

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

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

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

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

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

        The class syntax is only supported in Python 3.6+, while two other
        syntax forms work for Python 2.7 and 3.2+
        csHeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	�Z
S)�_AnnotatedAliasaKRuntime 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��||�||_dS)N)r}r+�__metadata__r�rYrm)rRr��metadata)r]rrrm�s


z_AnnotatedAlias.__init__cCs$t|�dkst�|d}t||j�S)Nrnr)r!r�r+r,)rRrr�rrr�	copy_with�sz_AnnotatedAlias.copy_withcCs&d�t�|j�d�dd�|jD���S)Nz#typing_extensions.Annotated[{}, {}]z, css|]}t|�VqdS)N)r )r�r�rrrr��sz+_AnnotatedAlias.__repr__.<locals>.<genexpr>)rqrpryr�r�r,)rRrrrrx�s
z_AnnotatedAlias.__repr__cCstjt|jf|jffS)N)�operator�getitemrJr�r,)rRrrr�
__reduce__�sz_AnnotatedAlias.__reduce__cCs*t|t�stS|j|jkrdS|j|jkS)NF)r}r+r0r�r,)rRr~rrrr�s

z_AnnotatedAlias.__eq__cCst|j|jf�S)N)r{r�r,)rRrrrr|�sz_AnnotatedAlias.__hash__)rrrrVrmr.rxr1rr|r^rr)r]rr+�sr+c@s0eZdZdZdZdd�Zedd��Zdd�Zd	S)
rJa�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()]
        rcOstd��dS)Nz&Type Annotated cannot be instantiated.)r)r"r)r*rrrr(szAnnotated.__new__cCsLt|t�rt|�dkrtd��d}t�|d|�}t|dd��}t||�S)Nr,zUAnnotated[...] should be used with at least two arguments (a type and an annotation).z$Annotated[t, ...]: t must be a type.rrn)r}r�r!rrprr+)r"rrr�r-rrrrszAnnotated.__class_getitem__cOstd�|j���dS)NzCannot subclass {}.Annotated)rrqr)r"r)r*rrrr&szAnnotated.__init_subclass__N)	rrrrVrr(rrrrrrrrJ�s
cCs\t|t�rt|j�St|tj�rXtdd�|jD��}||jkrB|S|�|�}|j	|_	|S|S)z2Strips the annotations from a given type.
        css|]}t|�VqdS)N)�_strip_annotations)r�r�rrrr�1sz%_strip_annotations.<locals>.<genexpr>)
r}r+r2r�rpr�r�r�r.�_special)r�Z
stripped_argsr�rrrr2+s



r2cCs*tj|||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, ...]' 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.
        )rurvcSsi|]\}}t|�|�qSr)r2)r��kr�rrrr&[sz"get_type_hints.<locals>.<dictcomp>)rprIr))rSrurvZinclude_extras�hintrrrrI9scCs t|�dko|�d�o|�d�S)z3Returns True if name is a __dunder_variable_name__.��__)r!r��endswith)rZrrr�
_is_dunder_sr9cs�eZdZdZ�fdd�Zedd��Zdd�Zd�fd	d
�	Zdd�Z	e
�fd
d��Zdd�Zdd�Z
�fdd�Zdd�Zdd�Z�ZS)�
AnnotatedMetazMetaclass for Annotatedcs8tdd�|D��r"tdtt���t�j||||f|�S)Ncss|]}|tk	VqdS)N)r�)r�r�rrrr�ksz(AnnotatedMeta.__new__.<locals>.<genexpr>zCannot subclass )r�rr�rJrYr()r"rZr[r\r*)r]rrr(jszAnnotatedMeta.__new__cCs|��dS)Nr,)r
)rRrrrr,oszAnnotatedMeta.__metadata__cCsP|\}}}t|t�s t�|�}n|d�|�}d�dd�|D��}d|||fS)Nrz, css|]}t|�VqdS)N)r )r��argrrrr�ysz+AnnotatedMeta._tree_repr.<locals>.<genexpr>z
%s[%s, %s])r}r�rpry�
_tree_reprr�)rR�treer"r�r-Ztp_reprZmetadata_reprsrrrr<ss

zAnnotatedMeta._tree_reprNcsh|tkrtSt�j||d�}t|dt�rd|ddtkrd|dd}|dd}t|||dfS|S)N)r�r)rnrr,)rJrYr
r}r�)rRr�r)r�Zsub_tpZ	sub_annot)r]rrr
|szAnnotatedMeta._subs_treecCsX|jdkrtd��|��}x"t|t�r<|dtkr<|d}qWt|t�rP|dS|SdS)z6Return the class used to create instance of this type.NzCCannot get the underlying type of a non-specialized Annotated type.rrn)r�rr
r}r�rJ)rRr=rrr�	_get_cons�s

zAnnotatedMeta._get_conscs�t|t�s|f}|jdk	r&t��|�St|t�r<t|�dkrFtd��n$d}t�|d|�}t|dd��}|j	|j
|jt|j
�t|f�||f|d�S)Nr,z]Annotated[...] should be instantiated with at least two arguments (a type and an annotation).z$Annotated[t, ...]: t must be a type.rrn)r�r)r�)r}r�r�rYrsr!rrprr]rr�rr/r
)rRrrrkr-)r]rrrs�s 


zAnnotatedMeta.__getitem__cOs6|��}|||�}y
||_Wntk
r0YnX|S)N)r>�__orig_class__r)rRr)r*Zcons�resultrrr�__call__�s

zAnnotatedMeta.__call__cCs,|jdk	r t|�s t|��|�St|��dS)N)r�r9r�r>r)rRr�rrr�__getattr__�szAnnotatedMeta.__getattr__csJt|�s|�d�r"t��||�n$|jdkr6t|��nt|��||�dS)Nr�)r9r�rYr�r�r�setattrr>)rRr��value)r]rrr��s


zAnnotatedMeta.__setattr__cCstd��dS)Nz+Annotated cannot be used with isinstance().)r)rRrSrrrrT�szAnnotatedMeta.__instancecheck__cCstd��dS)Nz+Annotated cannot be used with issubclass().)r)rRr"rrrrU�szAnnotatedMeta.__subclasscheck__)NN)rrrrVr(�propertyr,r<r
r>rrsrArBr�rTrUr^rr)r]rr:gs	
	r:c@seZdZdZdS)rJavAdd context specific metadata to a type.

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

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

        Details:

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

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

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

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

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

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

            OptimizedList = Annotated[List[T], runtime.Optimize()]
            OptimizedList[int] == Annotated[List[int], runtime.Optimize()]
        N)rrrrVrrrrrJ�s)r�cCs.t|t�rtSt|t�r|jS|tkr*tSdS)aGet 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
        N)r}r+rJr�r�r)rkrrrrH�s

cCsdt|t�r|jf|jSt|t�r`|j}t|�tjj	kr\|dt
k	r\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)
        rNr�r)r}r+r�r,r�r�rHr�r�r�Ellipsisr�)rkr�rrrrGs

�	TypeAliasc@seZdZdd�ZdS)�_TypeAliasFormcCs
d|jS)Nztyping_extensions.)r�)rRrrrrx sz_TypeAliasForm.__repr__N)rrrrxrrrrrHsrHcCstd�|���dS)a&Special marker indicating that an assignment should
        be recognized as a proper type alias definition by type
        checkers.

        For example::

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

        It's invalid when used anywhere except as in the example above.
        z{} is not subscriptableN)rrq)rRr#rrrrG#sc@seZdZdd�ZdS)rHcCs
d|jS)Nztyping_extensions.)r�)rRrrrrx3sz_TypeAliasForm.__repr__N)rrrrxrrrrrH2sa�Special marker indicating that an assignment should
                               be recognized as a proper type alias definition by type
                               checkers.

                               For example::

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

                               It's invalid when used anywhere except as in the example
                               above.c@seZdZdZdd�ZdS)�_TypeAliasMetazMetaclass for TypeAliascCsdS)Nztyping_extensions.TypeAliasr)rRrrrrxFsz_TypeAliasMeta.__repr__N)rrrrVrxrrrrrICsrIc@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�_TypeAliasBasea&Special marker indicating that an assignment should
        be recognized as a proper type alias definition by type
        checkers.

        For example::

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

        It's invalid when used anywhere except as in the example above.
        rcCstd��dS)Nz+TypeAlias cannot be used with isinstance().)r)rRrSrrrrTVsz _TypeAliasBase.__instancecheck__cCstd��dS)Nz+TypeAlias cannot be used with issubclass().)r)rRr"rrrrUYsz _TypeAliasBase.__subclasscheck__cCsdS)Nztyping_extensions.TypeAliasr)rRrrrrx\sz_TypeAliasBase.__repr__N)rrrrVrrTrUrxrrrrrJIs

rJc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rIzMetaclass for TypeAliascCstd��dS)Nz+TypeAlias cannot be used with isinstance().)r)rRrSrrrrTdsz _TypeAliasMeta.__instancecheck__cCstd��dS)Nz+TypeAlias cannot be used with issubclass().)r)rRr"rrrrUgsz _TypeAliasMeta.__subclasscheck__cOstd��dS)NzCannot instantiate TypeAlias)r)rRr)r*rrrrAjsz_TypeAliasMeta.__call__N)rrrrVrTrUrArrrrrIasc@seZdZdZdZdS)rGa&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.
        rN)rrrrVrrrrrrGms
)NNF)�r�r��
contextlibr�rp�collections.abcr�r/rrrrr�ZPEP_560rorr	r	r
rr�ImportErrorr
Z	SUBS_TREErrrrr&r�r'r+Z
_geqv_defined�_collections_abc�_check_methodsr6r�ZHAVE_ANNOTATED�extendr�ZHAVE_PROTOCOLSrOrPrQrXr8r`rarbrcrerfrgr7rir��_SpecialFormr�r�r�r@rArBr�r�r�r�rDr9r�r�r�r�r�r�r�r<r��MutableSequencer:r�r�r��execr=r��MutableMappingr;r�r�r��Dictr�r�r�rCrEr�rFr�rr�r�rLr�rVrqr�r
r�rNrMr?r>rr�__text_signature__r$r rrrrJrIr+r2r9r:rHrGrGrHrIrJrrrr�<module>sP








53 

43
/-	








	
	

&

	

	
	



	
I'&,))6$b"


Back to Directory File Manager