HEX
Server: LiteSpeed
System: Linux standart9.isimtescil.net 3.10.0-962.3.2.lve1.5.26.7.el7.x86_64 #1 SMP Wed Oct 2 07:53:12 EDT 2019 x86_64
User: karalev (5310)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/__pycache__/typing.cpython-37.pyc
B

phX�.@s�	ddlZddlmZmZddlZddlZddlZddlZddlZddl	Z	yddl
mZWnek
rtddlZYnXddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0g.Z
d1d2�Zd3d4�ZGd5d6�d6e�ZGd7d8�d8ed9d:�ZGd;d<�d<ed9d=�ZGd>d?�d?ed9d=�ZGd@dA�dAed9d=�ZdBdC�ZdDdE�ZdFdG�ZdHdI�ZdJdK�ZGdLdM�dMed9d=�Zed9d=�ZGdNd
�d
ed9d=�ZedO�ZedP�ZedQ�Z edRd9dS�Z!edTd9dS�Z"edUd9dS�Z#edVd9dW�Z$ed(e%e&�Z'dXdY�Z(d�dZd[�Z)d\d]�Z*d^d_�Z+gZ,d`da�Z-Gdbdc�dced9d=�Z.e.d9d=�Z/Gddde�deed9d=�Z0e0d9d=�Z1dfdg�Z2dhdi�Z3djdk�Z4dldm�Z5dndo�Z6dpdq�Z7Gdrds�dseej8�Z9dZ:dtdu�Z;Gdvd�de9dw�Z:Gdxdy�dy�Z<Gdzd{�d{�Z=Gd|d}�d}e9�Z>Gd~d�de?e?e>d�Z@Gd�d��d�e9�ZAGd�d�dejBeAd�ZBGd�d��d�ed9d=�ZCeCd9d=�ZDd�d)�ZEd�d��ZFd�d�d*�ZGd�d,�ZHd�d-�ZId�d��ZJd�d.�ZKGd�d��d�e9�ZLGd�d��d�eLdw�ZMejNZNeOed���r�Gd�d��d�e:e!ejPd��ZPe
�Qd��eOed���rGd�d��d�ePe"e:e!e$e"fejRd��ZRe
�Qd��eOed���rhGd�d��d�e:e!ejSd��ZSGd�d��d�eSe!ejTd��ZTe
�Qd��e
�Qd��Gd�d�de:e!ejUd��ZUGd�d�deUe!ejVd��ZVGd�d�deM�ZWGd�d�deM�ZXGd�d��d�eM�ZYGd�d��d�eM�ZZGd�d�deMe!�Z[Gd�d �d eMe!�Z\eOed��r,Gd�d�deUe!ej]d��Z]nGd�d�deMe!�Z]ej^Z^Gd�d�de:e!ej_d��Z_eOed���r�Gd�d��d�e^eUe!e_e!ej`d��Z`e
�Qd��eOed���r�Gd�d�de`e!ejad��Zbn"Gd�d�de^eUe!e_e!ejad��ZbGd�d�debeejcd��ZceOed���r.Gd�d�de`ee:ee#fejdd��Zdn,Gd�d�de^eUee_ee:ee#fejdd��ZdGd�d�dedee fejed��ZeeOed��r�eOed���r�Gd�d�de]e!e`e!ejfd��Zfn"Gd�d�de^e]e!e_e!ejfd��Zfn"Gd�d�de^eUe!e_e!ejfd��ZfGd�d�defeejgd��ZgGd�d
�d
efehejid��ZiGd�d#�d#ejegeejd��ZkGd�d$�d$eleceeld��ZaGd�d%�d%emebe!emd��ZnGd�d�de^eUe!ejod��ZoGd�d�deoeebeejpd��ZpGd�d�deoe@ee#febe@ee#fe:ee#fejqd��ZqGd�d�deoe#ejrd��ZreOed���r:Gd�d��d�e:e!ejsd��Zte
�Qd��Gd�d!�d!eueeee feud��ZvGd�d"�d"ejweeee fejwd��ZxeOed'��r�ejyZzne	j{ZzGd�d'�d'eVe!e:e!e$e"fezd��Zyed�d9edÍZ|Gd�d	�d	e:e|ed��Z}d�dƄZ~ejddDžd�kZ�Gd�dʄd�e�Z�Gd�d&�d&e�dw�Z�d�d+�Z�e&Z�d�Z�Gd�dτd�e:e'�Z�Gd�dфd�e�e%�Z�Gd�dӄd�e�e&�Z�Gd�dՄdՃZ�e�d�e�_�e�ej�e�j�<ed�e'ee��dء�d�dڄ�Z�ed�e'ee��d�dء�d�dڄ�Z�Gd�dބdރZe�d�e_�eej�ej�<dS)��N)�abstractmethod�abstractproperty�Any�Callable�ClassVar�Generic�Optional�Tuple�Type�TypeVar�Union�AbstractSet�
ByteString�	Container�Hashable�	ItemsView�Iterable�Iterator�KeysView�Mapping�MappingView�MutableMapping�MutableSequence�
MutableSet�Sequence�Sized�
ValuesView�
Reversible�SupportsAbs�
SupportsFloat�SupportsInt�
SupportsRound�Dict�DefaultDict�List�Set�	FrozenSet�
NamedTuple�	Generator�AnyStr�cast�get_type_hints�NewType�
no_type_check�no_type_check_decorator�overload�Text�
TYPE_CHECKINGcCs"tjdd�dkr|jS|jSdS)N�)�r3)�sys�version_info�__qualname__�__name__)�x�r9�
/typing.py�	_qualnameWsr;cCs"|�d�r|dkr|dd�}|S)N�_)�
_TypeAlias�_ForwardRef�_TypingBase�_FinalTypingBase�)�
startswith)Znmr9r9r:�
_trim_name_srCcsJeZdZdZdZdd��fdd�
Zdd�Zdd	�Zd
d�Zdd
�Z	�Z
S)�
TypingMetaa�Metaclass for most types defined in typing module
    (not a part of public API).

    This overrides __new__() to require an extra keyword parameter
    '_root', which serves as a guard against naive subclassing of the
    typing classes.  Any legitimate class defined using a metaclass
    derived from TypingMeta must pass _root=True.

    This also defines a dummy constructor (all the work for most typing
    constructs is done in __new__) and a nicer repr().
    F)�_rootcs2|s tdd�tt|��pd��t��||||�S)NzCannot subclass %sz, z())�	TypeError�join�map�
_type_repr�super�__new__)�cls�name�bases�	namespacerE)�	__class__r9r:rKuszTypingMeta.__new__cOsdS)Nr9)�self�args�kwdsr9r9r:�__init__{szTypingMeta.__init__cCs|S)a'Override this in subclasses to interpret forward references.

        For example, List['C'] is internally stored as
        List[_ForwardRef('C')], which should evaluate to List[C],
        where C is an object found in globalns or localns (searching
        localns first, of course).
        r9)rQ�globalns�localnsr9r9r:�
_eval_type~szTypingMeta._eval_typecCsdS)Nr9)rQ�tvarsr9r9r:�_get_type_vars�szTypingMeta._get_type_varscCstt|��}d|j|fS)Nz%s.%s)rCr;�
__module__)rQ�qnamer9r9r:�__repr__�szTypingMeta.__repr__)r7rZr6�__doc__�_is_protocolrKrTrWrYr\�
__classcell__r9r9)rPr:rDfs
rDcsLeZdZdZdZdd�Z�fdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
�ZS)r?z0Internal indicator of special typing constructs.r9cOsdS)Nr9)rQrRrSr9r9r:rT�sz_TypingBase.__init__cs@t|�dkr4t|dt�r4t|dt�r4td|��t��|�S)z�Constructor.

        This only exists to give a better error message in case
        someone tries to subclass a special typing object (not a good idea).
        r3rrAzCannot subclass %r)�len�
isinstance�str�tuplerFrJrK)rLrRrS)rPr9r:rK�s
z_TypingBase.__new__cCs|S)Nr9)rQrUrVr9r9r:rW�sz_TypingBase._eval_typecCsdS)Nr9)rQrXr9r9r:rY�sz_TypingBase._get_type_varscCs"t|�}tt|��}d|j|fS)Nz%s.%s)�typerCr;rZ)rQrLr[r9r9r:r\�sz_TypingBase.__repr__cOstdt|���dS)NzCannot instantiate %r)rFrd)rQrRrSr9r9r:�__call__�sz_TypingBase.__call__)r7rZr6r]�	__slots__rTrKrWrYr\rer_r9r9)rPr:r?�sr?T)�	metaclassrEcs2eZdZdZdZdd��fdd�
Zdd�Z�ZS)	r@z�Internal mix-in class to prevent instantiation.

    Prevents instantiation unless _root=True is given in class call.
    It is used to create pseudo-singleton instances Any, Union, Optional, etc.
    r9F)rEcs0t�j|f|�|�}|dkr |Std|��dS)NTzCannot instantiate %r)rJrKrF)rLrErRrSrQ)rPr9r:rK�sz_FinalTypingBase.__new__cCstt|�j�S)N)rCrdr7)rQr9r9r:�
__reduce__�sz_FinalTypingBase.__reduce__)r7rZr6r]rfrKrhr_r9r9)rPr:r@�sr@)rEcsTeZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Z�ZS)r>z-Internal wrapper to hold a forward reference.)�__forward_arg__�__forward_code__�__forward_evaluated__�__forward_value__cstt��|�t|t�s$td|f��yt|dd�}Wn"tk
rVtd|f��YnX||_||_d|_	d|_
dS)Nz,Forward reference must be a string -- got %rz<string>�evalz1Forward reference must be an expression -- got %rF)rJrTrarbrF�compile�SyntaxErrorrirjrkrl)rQ�arg�code)rPr9r:rT�s
z_ForwardRef.__init__cCsd|jr||k	r^|dkr(|dkr(i}}n|dkr6|}n|dkrB|}tt|j||�d�|_d|_|jS)Nz*Forward references must evaluate to types.T)rk�_type_checkrmrjrl)rQrUrVr9r9r:rW�s
z_ForwardRef._eval_typecCs&t|t�stS|j|jko$|j|jkS)N)rar>�NotImplementedrirl)rQ�otherr9r9r:�__eq__�s
z_ForwardRef.__eq__cCst|j|jf�S)N)�hashrirl)rQr9r9r:�__hash__�sz_ForwardRef.__hash__cCstd��dS)Nz4Forward references cannot be used with isinstance().)rF)rQ�objr9r9r:�__instancecheck__�sz_ForwardRef.__instancecheck__cCstd��dS)Nz4Forward references cannot be used with issubclass().)rF)rQrLr9r9r:�__subclasscheck__�sz_ForwardRef.__subclasscheck__cCsd|jfS)Nz_ForwardRef(%r))ri)rQr9r9r:r\�sz_ForwardRef.__repr__)
r7rZr6r]rfrTrWrurwryrzr\r_r9r9)rPr:r>�sr>c@sLeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)r=a:Internal helper class for defining generic variants of concrete types.

    Note that this is not a type; let's call it a pseudo-type.  It cannot
    be used in instance and subclass checks in parameterized form, i.e.
    ``isinstance(42, Match[str])`` raises ``TypeError`` instead of returning
    ``False``.
    )rM�type_var�	impl_type�type_checkercCsxt|t�stt|���t|t�s,tt|���t|t�rBtt|���t|ttf�s\tt|���||_||_||_	||_
dS)atInitializer.

        Args:
            name: The name, e.g. 'Pattern'.
            type_var: The type parameter, e.g. AnyStr, or the
                specific type, e.g. str.
            impl_type: The implementation type.
            type_checker: Function that takes an impl_type instance.
                and returns a value that should be a type_var instance.
        N)rarb�AssertionError�reprrdrDr?rMr{r|r})rQrMr{r|r}r9r9r:rTsz_TypeAlias.__init__cCsd|jt|j�fS)Nz%s[%s])rMrIr{)rQr9r9r:r\sz_TypeAlias.__repr__cCs�t|jt�std|��|jjrJt|t�rJt||jj�sJtd||jf��t|t�rj||jk	rjtd|��|�|j||j	|j
�S)Nz#%s cannot be further parameterized.z&%s is not a valid substitution for %s.z%s cannot be re-parameterized.)rar{rrF�__constraints__rd�
issubclassrPrMr|r})rQZ	parameterr9r9r:�__getitem__s
z_TypeAlias.__getitem__cCs&t|t�stS|j|jko$|j|jkS)N)rar=rsrMr{)rQrtr9r9r:ru+s
z_TypeAlias.__eq__cCst|j|jf�S)N)rvrMr{)rQr9r9r:rw0sz_TypeAlias.__hash__cCs t|jt�std��t||j�S)Nz<Parameterized type aliases cannot be used with isinstance().)rar{rrFr|)rQrxr9r9r:ry3sz_TypeAlias.__instancecheck__cCs t|jt�std��t||j�S)Nz<Parameterized type aliases cannot be used with issubclass().)rar{rrFr�r|)rQrLr9r9r:rz9sz_TypeAlias.__subclasscheck__N)r7rZr6r]rfrTr\r�rurwryrzr9r9r9r:r=�sr=cCs0x*|D]"}t|t�st|t�r|�|�qWdS)N)rarDr?rY)�typesrX�tr9r9r:rY@s
rYcCsg}t||�t|�S)N)rYrc)r�rXr9r9r:�
_type_varsFs
r�cCs$t|t�st|t�r |�||�S|S)N)rarDr?rW)r�rUrVr9r9r:rWLsrWcCs�|dkrtd�St|t�r"t|�}t|t�r:t|�jdksPt|ttf�sbt|�sbt|d|f��t|�jdkr|t|dd�r�t|t	�r�t
|�ttfkr�td|��|S)a�Check that the argument is a type, and return it (internal helper).

    As a special case, accept None and return type(None) instead.
    Also, _TypeAlias instances (e.g. Match, Pattern) are acceptable.

    The msg argument is a human-readable error message, e.g.

        "Union[arg, ...]: arg should be a type."

    We append the repr() of the actual value (truncated to 100 chars).
    N�	_ClassVarz Got %.100r.)�_Union�	_Optional�
__origin__z&Plain %s is not valid as type argument)
rdrarbr>r?r7�callablerF�getattrrD�_gorgr�	_Protocol)rp�msgr9r9r:rrRs
rrcCs^t|t�r8t|t�s8|jdkr&t|�Sd|jt|�fS|dkrDdSt|tj�rV|jSt|�S)a;Return the repr() of an object, special-casing types (internal helper).

    If obj is a type, we return a shorter version than the default
    type.__repr__, based on the module and qualified name, which is
    typically enough to uniquely identify a type.  For everything
    else, we fall back on repr(obj).
    �builtinsz%s.%s.z...)	rardrDrZr;r��FunctionTyper7r)rxr9r9r:rIms
rIc@s$eZdZdZdZdd�Zdd�ZdS)�_Anya`Special type indicating an unconstrained type.

    - Any is compatible with every type.
    - Any assumed to have all methods.
    - All values assumed to be instances of Any.

    Note that all the above statements are true from the point of view of
    static type checkers. At runtime, Any should not be used with instance
    or class checks.
    r9cCstd��dS)Nz%Any cannot be used with isinstance().)rF)rQrxr9r9r:ry�sz_Any.__instancecheck__cCstd��dS)Nz%Any cannot be used with issubclass().)rF)rQrLr9r9r:rz�sz_Any.__subclasscheck__N)r7rZr6r]rfryrzr9r9r9r:r��s
r�csNeZdZdZdZdddd��fdd�
Zdd	�Zd
d�Zdd
�Zdd�Z	�Z
S)ra�Type variable.

    Usage::

      T = TypeVar('T')  # Can be anything
      A = TypeVar('A', str, bytes)  # Must be str or bytes

    Type variables exist primarily for the benefit of static type
    checkers.  They serve as the parameters for generic types as well
    as for generic function definitions.  See class Generic for more
    information on generic types.  Generic functions work as follows:

      def repeat(x: T, n: int) -> List[T]:
          '''Return a list containing n references to x.'''
          return [x]*n

      def longest(x: A, y: A) -> A:
          '''Return the longest of two strings.'''
          return x if len(x) >= len(y) else y

    The latter example's signature is essentially the overloading
    of (str, str) -> str and (bytes, bytes) -> bytes.  Also note
    that if the arguments are instances of some subclass of str,
    the return type is still plain str.

    At runtime, isinstance(x, T) and issubclass(C, T) will raise TypeError.

    Type variables defined with covariant=True or contravariant=True
    can be used do declare covariant or contravariant generic types.
    See PEP 484 for more details. By default generic types are invariant
    in all type variables.

    Type variables can be introspected. e.g.:

      T.__name__ == 'T'
      T.__constraints__ == ()
      T.__covariant__ == False
      T.__contravariant__ = False
      A.__constraints__ == (str, bytes)
    )r7�	__bound__r��
__covariant__�__contravariant__NF)�bound�	covariant�
contravariantcs�t�j|f|�|||d��||_|r2|r2td��t|�|_t|�|_|rZ|dk	rZtd��|rrt|�dkrrtd��d�t	�fdd�|D��|_
|r�t|d	�|_nd|_dS)
N)r�r�r�z"Bivariant types are not supported.z-Constraints cannot be combined with bound=...rAz"A single constraint is not allowedz:TypeVar(name, constraint, ...): constraints must be types.c3s|]}t|��VqdS)N)rr)�.0r�)r�r9r:�	<genexpr>�sz#TypeVar.__init__.<locals>.<genexpr>zBound must be a type.)
rJrTr7�
ValueError�boolr�r�rFr`rcr�rrr�)rQrMr�r�r�Zconstraints)rP)r�r:rT�s 

zTypeVar.__init__cCs||kr|�|�dS)N)�append)rQrXr9r9r:rY�szTypeVar._get_type_varscCs&|jrd}n|jrd}nd}||jS)N�+�-�~)r�r�r7)rQ�prefixr9r9r:r\�szTypeVar.__repr__cCstd��dS)Nz0Type variables cannot be used with isinstance().)rF)rQ�instancer9r9r:ry�szTypeVar.__instancecheck__cCstd��dS)Nz0Type variables cannot be used with issubclass().)rF)rQrLr9r9r:rz�szTypeVar.__subclasscheck__)r7rZr6r]rfrTrYr\ryrzr_r9r9)rPr:r�s(	�T�KT�VT�T_co)r��V_co�VT_co�T_contra)r�cCsV|dkrg}t|d�r"|�||�St|t�rRx$t|�D]\}}||kr6||Sq6W|S)z�An internal helper function: replace arg if it is a type variable
    found in tvars with corresponding substitution from args or
    with corresponding substitution sub-tree if arg is a generic type.
    N�
_subs_tree)�hasattrr�rar�	enumerate)rprXrR�iZtvarr9r9r:�_replace_arg�s

r�c
Cs�|jdkr|S|j}g}x|jdk	r6|�|�|j}qWg}x |jD]}|�t|||��qDWx@|D]8}g}x*t|j�D]\}	}|�t||j|��qxW|}qdW|S)a�An internal helper function: calculate substitution tree
    for generic cls after replacing its type parameters with
    substitutions in tvars -> args (if any).
    Repeat the same following __origin__'s.

    Return a list of arguments with all possible substitutions
    performed. Arguments that are generic classes themselves are represented
    as tuples (so that no new classes are created by this function).
    For example: _subs_tree(List[Tuple[int, T]][str]) == [(Tuple, int, str)]
    N)r�r��__args__r�r��__parameters__)
rLrXrRZcurrentZ
orig_chain�	tree_argsrpZoclsZ
new_tree_argsr�r9r9r:r�
s 



r�cs(g}xn|D]f}t|t�r0|jtkr0|�|j�q
t|t�rft|�dkrf|dtkrf|�|dd��q
|�|�q
Wt	|��t��t|�kr�g}x(|D] }|�kr�|�|���
|�q�W|}�r�t���t	|��x>|D]6�t�t�s�q�t
�fdd���hD��r؈�
��q�Wt�fdd�|D��S)z�An internal helper for Union creation and substitution: flatten Union's
    among parameters, then remove duplicates and strict subclasses.
    rrANc3s6|].}t|t�r|jdk	st|t�o,t�|�VqdS)N)ra�GenericMetar�rdr�)r�Zt2)�t1r9r:r�Os
z'_remove_dups_flatten.<locals>.<genexpr>c3s|]}|�kr|VqdS)Nr9)r�r�)�
all_paramsr9r:r�Ts)rar�r�r�extendr�rcr`r��set�remover~rd�any)�
parameters�params�pZ
new_paramsr�r9)r�r�r:�_remove_dups_flatten.s0
"



r�cCsX|jstdt|���t|�}t|j�}||krTtd||kr@dndt|�||f��dS)Nz%s is not a generic classz0Too %s parameters for %s; actual %s, expected %sZmanyZfew)r�rFrr`)rLr�ZalenZelenr9r9r:�_check_genericWs
r�cs4t�����t��j�t�����fdd��}|S)zInternal wrapper caching __getitem__ of generic types with a fallback to
    original function for non-hashable arguments.
    cs*y
�||�Stk
rYnX�||�S)N)rF)rRrS)�cached�funcr9r:�innerls

z_tp_cache.<locals>.inner)�	functools�	lru_cache�	_cleanupsr��cache_clear�wraps)r�r�r9)r�r�r:�	_tp_cacheesr�cs�eZdZdZdZddd��fdd�Zdd	�Zd
d�Z�fdd
�Z�fdd�Z	e
dd��Zddd�Zdd�Z
dd�Zdd�Zdd�Z�ZS)r�a�Union type; Union[X, Y] means either X or Y.

    To define a union, use e.g. Union[int, str].  Details:

    - The arguments must be types and there must be at least one.

    - None as an argument is a special case and is replaced by
      type(None).

    - Unions of unions are flattened, e.g.::

        Union[Union[int, str], float] == Union[int, str, float]

    - Unions of a single argument vanish, e.g.::

        Union[int] == int  # The constructor actually returns int

    - Redundant arguments are skipped, e.g.::

        Union[int, str, int] == Union[int, str]

    - When comparing unions, the argument order is ignored, e.g.::

        Union[int, str] == Union[str, int]

    - When two arguments have a subclass relationship, the least
      derived argument is kept, e.g.::

        class Employee: pass
        class Manager(Employee): pass
        Union[int, Employee, Manager] == Union[int, Employee]
        Union[Manager, int, Employee] == Union[int, Employee]
        Union[Employee, Manager] == Employee

    - Similar for object::

        Union[int, object] == object

    - You cannot subclass or instantiate a union.

    - You can use Optional[X] as a shorthand for Union[X, None].
    )r�r�r��
__tree_hash__NF)rEcs�t�j|||f|�d|i�}|dkrHd|_d|_d|_ttd��|_|St|t	�sZt
d��|tkr~t|�}t
|�dkr~|dSt|�|_||_||_|��}t|t	�r�tt|��|_n
t|�|_|S)NrE)rzExpected parameters=<tuple>rAr)rJrKr�r�r�rv�	frozensetr�rarcrFrr�r`r�r�)rLr��originrErRrQZ	subs_tree)rPr9r:rK�s*



z_Union.__new__cs^|jdkr|St��fdd�|jD��}t|j���}||jkrN||jkrN|S|j||dd�S)Nc3s|]}t|���VqdS)N)rW)r�r�)rUrVr9r:r��sz$_Union._eval_type.<locals>.<genexpr>T)rE)r�rcrWr�rP)rQrUrV�ev_args�	ev_originr9)rUrVr:rW�s
z_Union._eval_typecCs|jr|jrt|j|�dS)N)r�r�rY)rQrXr9r9r:rY�sz_Union._get_type_varscs<|jdkrt���S|��}t|t�s.t|�S|d�|�S)Nr)r�rJr\r�rarcr�
_tree_repr)rQ�tree)rPr9r:r\�s


z_Union.__repr__cs`g}xB|dd�D]2}t|t�s0|�t|��q|�|d�|��qWt���dd�|�S)NrArz[%s]z, )rarcr�rIr�rJr\rG)rQr��arg_listrp)rPr9r:r��s
z_Union._tree_reprcsl|dkrtd��t|t�s |f}|jdkr0d�nd�t�fdd�|D��}|tk	r\t||�|j||dd�S)	Nr9z Cannot take a Union of no types.z)Union[arg, ...]: each arg must be a type.z*Parameters to generic types must be types.c3s|]}t|��VqdS)N)rr)r�r�)r�r9r:r��sz%_Union.__getitem__.<locals>.<genexpr>T)r�rE)rFrarcr�rr�rP)rQr�r9)r�r:r��s


z_Union.__getitem__cCs>|tkrtSt|||�}t|�}t|�dkr4|dStf|S)NrAr)rr�r�r`)rQrXrRr�r9r9r:r��sz_Union._subs_treecCs"t|t�s|��|kS|j|jkS)N)rar�r�r�)rQrtr9r9r:ru�s
z
_Union.__eq__cCs|jS)N)r�)rQr9r9r:rw�sz_Union.__hash__cCstd��dS)Nz(Unions cannot be used with isinstance().)rF)rQrxr9r9r:ry�sz_Union.__instancecheck__cCstd��dS)Nz(Unions cannot be used with issubclass().)rF)rQrLr9r9r:rzsz_Union.__subclasscheck__)NN)NN)r7rZr6r]rfrKrWrYr\r�r�r�r�rurwryrzr_r9r9)rPr:r�vs*
	
	r�c@s eZdZdZdZedd��ZdS)r�zEOptional type.

    Optional[X] is equivalent to Union[X, None].
    r9cCst|d�}t|td�fS)Nz#Optional[t] requires a single type.)rrrrd)rQrpr9r9r:r�s
z_Optional.__getitem__N)r7rZr6r]rfr�r�r9r9r9r:r�sr�cCs(t|t�st�x|jdk	r"|j}qW|S)z@Return the farthest origin of a generic class (internal helper).N)rar�r~r�)�ar9r9r:r�s
r�cCs(t|t�rt|t�st�t|�t|�kS)a6Return whether two generic classes are equivalent (internal helper).

    The intention is to consider generic class X and any of its
    parameterized forms (X[T], X[int], etc.) as equivalent.

    However, X is not equivalent to a subclass of X.

    The relation is reflexive, symmetric and transitive.
    )rar�r~r�)r��br9r9r:�_geqv!s
r�cCsLt}xBt|jdd��D],\}}t|t�rt|�tkr|j|d}qW|S)z�Helper for Generic.__new__.

    Returns the class after the last occurrence of Generic or
    Generic[...] in cls.__mro__.
    N���rA)�objectr��__mro__rar�r�r)rLZnext_in_mror��cr9r9r:�_next_in_mro0s
r�cCs>|tkrtd|��|jdk	r:t�d�jddkr:td��dS)z>An internal helper to prohibit isinstance([1], List[str]) etc.z5Class %r cannot be used with class or instance checksNr3r7)�abcr�zCParameterized generics cannot be used with class or instance checks)rrFr�r4�	_getframe�	f_globals)rLr9r9r:�_valid_for_check>s
r�cs,t�jtj�r�fdd�}n�fdd�}|S)z�Construct a __subclasshook__ callable that incorporates
    the associated __extra__ class in subclass checks performed
    against cls.
    csbt���j�|�}|tk	r |S�j|jkr0dSx,�j��D]}t|t�rLq<t||�r<dSq<WtS)NT)	r��	__extra__�__subclasshook__rsr��__subclasses__rar�r�)�subclass�resZscls)rLr9r:�
__extrahook__Rs

z)_make_subclasshook.<locals>.__extrahook__cs"t���jrt|�j�rdStS)NT)r�r�r�rs)r�)rLr9r:r�as)rar�r��ABCMeta)rLr�r9)rLr:�_make_subclasshookIsr�cCs2t|�}d|kr.x|dD]}|�|d�qW|S)z�Internal helper: copy class __dict__ and clean slots class variables.
    (They will be re-created if necessary by normal class machinery.)
    rfN)�dict�pop)ZdctZ	dict_copyZslotr9r9r:�_no_slots_copyis
r�cs�eZdZdZd�fdd�	Zdd�Zdd�Z�fd	d
�Z�fdd�Zdd
d�Z	dd�Z
dd�Zedd��Z
dd�Zdd�Z�ZS)r�zMetaclass for generic types.Nc	sh|dk	r0|dk	st�tdd�|D��s.t|��n�|dks@t|��|dksPt|��|dks`t|��t|�}d}	xF|D]>}
|
tkr�td��t|
t�rr|
jtkrr|	dk	r�td��|
j}	qrW|	dkr�|}	nRt	|�}t	|	��|�k�stdd�
�fdd�|D��d�
dd�|	D��f��|	}|}|dk	�rFt|�tj
k�rF||k�rF|f|}td	d�|D��}td
d�|D���r~tdd�|D��}t�j||||dd
�}
||
_|�r�tdd�|D��nd|
_||
_||
_t|
�|
_|dk�r�||
_d|k�r�|�s
t|
jd��r|
jjdk�rt|
�|
_t|tj
��r*|j|
_|�rDt|d��rD|j|
_|�rVt|
���n
t|
jf�|
_|
S)Ncss|]}t|t�VqdS)N)rar)r�r�r9r9r:r�|sz&GenericMeta.__new__.<locals>.<genexpr>z!Cannot inherit from plain Genericz0Cannot inherit from Generic[...] multiple types.z6Some type variables (%s) are not listed in Generic[%s]z, c3s|]}|�krt|�VqdS)N)rb)r�r�)�gvarsetr9r:r��scss|]}t|�VqdS)N)rb)r��gr9r9r:r��scss$|]}t|t�rt|�n|VqdS)N)rar�r�)r�r�r9r9r:r��scss |]}t|t�o|tk	VqdS)N)rar�r)r�r�r9r9r:r��scss|]}|tk	r|VqdS)N)r)r�r�r9r9r:r��sT)rEcss*|]"}|tkrdn|tkrdn|VqdS).r9N)�_TypingEllipsis�_TypingEmpty)r�r�r9r9r:r��sr�r7r�r6) r~�allr�rrFrar�r�r�r�rGrdr�r�rcr�rJrKr�r�r��__next_in_mro__�__orig_bases__r�r�r7r��
_abc_registryr6rvr�r�)rLrMrNrOrXrRr��extra�
orig_basesZgvars�baseZtvarsetZ
initial_basesrQ)rP)r�r:rKwsf




$



 zGenericMeta.__new__cCs|jr|jrt|j|�dS)N)r�r�rY)rQrXr9r9r:rY�szGenericMeta._get_type_varsc
s�|jr|j����nd}|jr8t��fdd�|jD��nd}||jkrT||jkrT|S|j|j|jt|j�|rtt	|�nd|||j
|jd�S)Nc3s|]}t|���VqdS)N)rW)r�r�)rUrVr9r:r��sz)GenericMeta._eval_type.<locals>.<genexpr>)rXrRr�r�r�)r�rWr�rcrPr7�	__bases__r��__dict__r�r�r�)rQrUrVr�r�r9)rUrVr:rW�s$zGenericMeta._eval_typecs"|jdkrt���S|�|���S)N)r�rJr\r�r�)rQ)rPr9r:r\�s

zGenericMeta.__repr__cstg}xV|dd�D]F}|dkr*|�d�qt|t�sD|�t|��q|�|d�|��qWt���dd�|�S)NrAr9z()rz[%s]z, )r�rarcrIr�rJr\rG)rQr�r�rp)rPr9r:r��s
zGenericMeta._tree_reprcCs,|jdkr|St|||�}t|�ft|�S)N)r�r�r�rc)rQrXrRr�r9r9r:r��s
zGenericMeta._subs_treecCs6t|t�stS|jdks"|jdkr*||kS|j|jkS)N)rar�rsr�r�)rQrtr9r9r:ru�s

zGenericMeta.__eq__cCs|jS)N)r�)rQr9r9r:rw�szGenericMeta.__hash__c
st|t�s|f}|s0t|�tk	r0tdt|���d�t�fdd�|D��}|tkr�tdd�|D��sltd��tt	|��t|�kr�td��|}|}nb|tt
fkr�t|�}|}nH|tkr�|}|}n6|j
ttfkr�tdt|���nt||�t|�}|}|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)rr)r�r�)r�r9r:r�sz*GenericMeta.__getitem__.<locals>.<genexpr>css|]}t|t�VqdS)N)rar)r�r�r9r9r:r�sz5Parameters to Generic[...] must all be type variablesz-Parameters to Generic[...] must all be uniquez'Cannot subscript already-subscripted %s)rXrRr�r�r�)rarcr�r	rFr;rr�r`r�rr�r�r�rr�rPr7r�r�r�r�r�)rQr�rXrRr9)r�r:r��sH

zGenericMeta.__getitem__cCst|j|�S)N)r�rP)rQr�r9r9r:ry(szGenericMeta.__instancecheck__c
Cs,|�|j|jt|j�|j|j|j|j|j	�S)N)
rPr7r�r�r�r�r�r�r�r�)rQr9r9r:�__copy__0szGenericMeta.__copy__)NNNNN)NN)r7rZr6r]rKrYrWr\r�r�rurwr�r�ryr�r_r9r9)rPr:r�tsP
,r�cOsZ|jdkr|�|�St|�}|�|�}y
||_Wntk
rDYnX|j||�|SdS)N)r�rKr�Z__orig_class__�AttributeErrorrT)Zbase_clsrLrRrSr�rxr9r9r:�_generic_new;s



r�c@seZdZdZdZdd�ZdS)raCAbstract base class for generic types.

    A generic type is typically declared by inheriting from
    this class parameterized with one or more type variables.
    For example, a generic mapping type might be defined as::

      class Mapping(Generic[KT, VT]):
          def __getitem__(self, key: KT) -> VT:
              ...
          # Etc.

    This class can then be used as follows::

      def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
          try:
              return mapping[key]
          except KeyError:
              return default
    r9cOs&t|t�rtd��t|j|f|�|�S)NzHType Generic cannot be instantiated; it can be used only as a base class)r�rrFr�r�)rLrRrSr9r9r:rKbs
zGeneric.__new__N)r7rZr6r]rfrKr9r9r9r:rKs)rgc@seZdZdZdS)r�z�Internal placeholder for () or []. Used by TupleMeta and CallableMeta
    to allow empty list/tuple in specific places, without allowing them
    to sneak in where prohibited.
    N)r7rZr6r]r9r9r9r:r�isr�c@seZdZdZdS)r�z(Internal placeholder for ... (ellipsis).N)r7rZr6r]r9r9r9r:r�psr�cs4eZdZdZe�fdd��Zdd�Zdd�Z�ZS)�	TupleMetazMetaclass for Tuple (internal).cs�|jdk	st|t�s t��|�S|dkr6t��tf�St|t�sF|f}t|�dkr�|ddkr�d�t	|d��}t��|t
f�Sd�t�fdd	�|D��}t��|�S)
Nr9r2rA.z Tuple[t, ...]: t must be a type.rz*Tuple[t0, t1, ...]: each t must be a type.c3s|]}t|��VqdS)N)rr)r�r�)r�r9r:r��sz(TupleMeta.__getitem__.<locals>.<genexpr>)r�r�r	rJr�r�rarcr`rrr�)rQr�r�)rP)r�r:r�ws
zTupleMeta.__getitem__cCs |jdkrt|t�Std��dS)Nz5Parameterized Tuple cannot be used with isinstance().)r�rarcrF)rQrxr9r9r:ry�s

zTupleMeta.__instancecheck__cCs |jdkrt|t�Std��dS)Nz5Parameterized Tuple cannot be used with issubclass().)r�r�rcrF)rQrLr9r9r:rz�s

zTupleMeta.__subclasscheck__)	r7rZr6r]r�r�ryrzr_r9r9)rPr:r�tsr�c@seZdZdZdZdd�ZdS)r	a@Tuple type; Tuple[X, Y] is the cross-product type of X and Y.

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

    To specify a variable-length tuple of homogeneous type, use Tuple[T, ...].
    r9cOs$t|t�rtd��tt|f|�|�S)Nz6Type Tuple cannot be instantiated; use tuple() instead)r�r	rFr�rc)rLrRrSr9r9r:rK�s
z
Tuple.__new__N)r7rZr6r]rfrKr9r9r9r:r	�s)r�rgcsHeZdZdZ�fdd�Z�fdd�Z�fdd�Ze�fdd	��Z�Z	S)
�CallableMetaz"Metaclass for Callable (internal).cs"|jdkrt���S|�|���S)N)r�rJr\r�r�)rQ)rPr9r:r\�s

zCallableMeta.__repr__cs�t|�tk	rt��|�Sg}xB|dd�D]2}t|t�sH|�t|��q*|�|d�|��q*W|ddkr�t|d�d|dSt|d�dd�	|dd��|dfS)NrArz...z	[..., %s]z
[[%s], %s]z, r�)
r�rrJr�rarcr�rIrrG)rQr�r�rp)rPr9r:r��s

zCallableMeta._tree_reprcs�|jdk	st|t�s t��|�St|t�r6t|�dkr>td��|\}}|t	krXt	|f}n$t|t
�sptd|f��t|�|f}|�|�S)zxA thin wrapper around __getitem_inner__ to provide the latter
        with hashable arguments to improve speed.
        Nr2z6Callable must be used as Callable[[arg, ...], result].z8Callable[args, result]: args must be a list. Got %.100r.)r�r�rrJr�rarcr`rF�Ellipsis�list�__getitem_inner__)rQr�rR�result)rPr9r:r��s


zCallableMeta.__getitem__cs^|\}}d�t|��}|tkr.t��t|f�Sd�t�fdd�|D��}||f}t��|�S)Nz.Callable[args, result]: result must be a type.z6Callable[[arg, ...], result]: each arg must be a type.c3s|]}t|��VqdS)N)rr)r�rp)r�r9r:r��sz1CallableMeta.__getitem_inner__.<locals>.<genexpr>)rrr�rJr�r�rc)rQr�rRr�)rP)r�r:r��s

zCallableMeta.__getitem_inner__)
r7rZr6r]r\r�r�r�r�r_r9r9)rPr:r��s
r�c@seZdZdZdZdd�ZdS)ra�Callable type; Callable[[int], str] is a function of (int) -> str.

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

    There is no syntax to indicate optional or keyword arguments,
    such function types are rarely used as callback types.
    r9cOs&t|t�rtd��t|j|f|�|�S)NzIType Callable cannot be instantiated; use a non-abstract subclass instead)r�rrFr�r�)rLrRrSr9r9r:rK�s
zCallable.__new__N)r7rZr6r]rfrKr9r9r9r:r�s	csNeZdZdZdZddd�Zdd�Zdd	�Z�fd
d�Zdd
�Z	dd�Z
�ZS)r�a3Special 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)r�)rQ�tprSr9r9r:rT	sz_ClassVar.__init__cCsPt|�}|jdkr4|t|d�|jdd���dd�Std�|jdd����dS)Nz{} accepts only single type.rAT)rEz {} cannot be further subscripted)rdr�rr�formatr7rF)rQ�itemrLr9r9r:r�s
z_ClassVar.__getitem__cCs,t|j||�}||jkr|St|�|dd�S)NT)rE)rWr�rd)rQrUrVZnew_tpr9r9r:rWs
z_ClassVar._eval_typecs,t���}|jdk	r(|d�t|j��7}|S)Nz[{}])rJr\r�r�rI)rQ�r)rPr9r:r\s

z_ClassVar.__repr__cCstt|�j|jf�S)N)rvrdr7r�)rQr9r9r:rw!sz_ClassVar.__hash__cCs,t|t�stS|jdk	r$|j|jkS||kS)N)rar�rsr�)rQrtr9r9r:ru$s


z_ClassVar.__eq__)N)r7rZr6r]rfrTr�rWr\rwrur_r9r9)rPr:r��s
	r�cCs|S)z�Cast a value to a type.

    This returns the value unchanged.  To the type checker this
    signals that the return value has the designated type, but at
    runtime we intentionally don't check anything (we want this
    to be as fast as possible).
    r9)�typ�valr9r9r:r*/sc
Cs�y
|j}Wntk
riSX|j}|j}|d|�}|jp@d}|j}|rTt|�ni}|t|�}x2t||d�|�D]\}}	||ks�t	�|	||<qxW|S)z:Internal helper to extract the default arguments, by name.Nr9)
�__code__r��co_argcount�co_varnames�__defaults__�__kwdefaults__r�r`�zipr~)
r�rqZ	pos_countZ	arg_names�defaultsZ
kwdefaultsr�Z
pos_offsetrM�valuer9r9r:�
_get_defaults:s

r
c	Cs�t|dd�riS|dkr2t|di�}|dkr>|}n|dkr>|}t|t�r�i}xlt|j�D]^}|j�di�}xJ|��D]>\}}|dkr�td�}t|t�r�t	|�}t
|||�}|||<qtWqXW|St|dd�}|dk�rt|tj��st|tj
��st|tj��st|tj��riStd�|���t|�}t|�}xp|��D]d\}}|dk�rRtd�}t|t��rft	|�}t
|||�}||k�r�||dk�r�t|}|||<�q8W|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, and if necessary
    adds Optional[t] if a default value equal to None is set.

    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, and these are also used as the locals.  If the
      object does not appear to have globals, an exception is raised.

    - 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.
    �__no_type_check__N�__globals__�__annotations__z1{!r} is not a module, class, method, or function.)r�rard�reversedr�r��get�itemsrbr>rWr�r��BuiltinFunctionType�
MethodType�
ModuleTyperFr�r
r�r)	rxrUrVZhintsr��annrMr	rr9r9r:r+NsR



cCs�t|t�rv|j��}x*|j��D]\}}||jkr |�|�q Wx4|��D](}t|tj	�r`d|_
t|t�rJt|�qJWy
d|_
Wntk
r�YnX|S)aIDecorator to indicate that annotations are not type hints.

    The argument must be a class or function; if it is a class, it
    applies recursively to all methods and classes defined in that class
    (but not to methods defined in its superclasses or subclasses).

    This mutates the function(s) or class(es) in place.
    T)
rardr��copyrr�r��valuesr�r�rr-rF)rpZ	arg_attrs�attrrrxr9r9r:r-�s	




cst����fdd��}|S)z�Decorator to give another decorator the @no_type_check effect.

    This wraps the decorator with something that wraps the decorated
    function in @no_type_check.
    cs�||�}t|�}|S)N)r-)rRrSr�)�	decoratorr9r:�wrapped_decorator�s
z2no_type_check_decorator.<locals>.wrapped_decorator)r�r�)rrr9)rr:r.�scOs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)rRrSr9r9r:�_overload_dummy�srcCstS)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)r�r9r9r:r/�scs0eZdZdZ�fdd�Zdd�Zdd�Z�ZS)�
_ProtocolMetaz~Internal metaclass for _Protocol.

    This exists so _Protocol classes can be generic without deriving
    from Generic.
    cs"t|jkrt��|�Std��dS)Nz+Protocols cannot be used with isinstance().)r�r�rJryrF)rQrx)rPr9r:ry�s
z_ProtocolMeta.__instancecheck__csL|js
tS|tkrdS|��}x(|D] �t�fdd�|jD��s$dSq$WdS)NTc3s|]}�|jkVqdS)N)r�)r��d)rr9r:r�sz2_ProtocolMeta.__subclasscheck__.<locals>.<genexpr>F)r^rsr��_get_protocol_attrsr�r�)rQrL�attrsr9)rr:rz�s
z_ProtocolMeta.__subclasscheck__cCsg}x.|jD]$}t|dd�r|jdkr|�|�qWt�}x�|D]�}x�|j��D]�}x�|jD]$}||k	r\||jkr\t|dd�s\Pq\W|�d�sP|dkrP|dkrP|dkrP|dkrP|dkrP|d	krP|d
krP|dkrP|dkrP|d
krP|dkrP|dkrP|dkrP|dkrP|dkrP|�|�qPWq@W|S)Nr^Fr�Z_abc_�__abstractmethods__r
�__weakref__r�r�rfrr�r�r�r�r�r�rZ)	r�r�r7r�r�r��keysrB�add)rQZprotocol_basesr�rr�rr9r9r:rs:

z!_ProtocolMeta._get_protocol_attrs)r7rZr6r]ryrzrr_r9r9)rPr:r�src@seZdZdZdZdZdS)r�z�Internal base class for protocol classes.

    This implements a simple-minded structural issubclass check
    (similar but more general than the one-offs in collections.abc
    such as Hashable).
    r9TN)r7rZr6r]rfr^r9r9r9r:r�-sr��	Awaitablec@seZdZdZdS)r$r9N)r7rZr6rfr9r9r9r:r$As)r��	Coroutinec@seZdZdZdS)r%r9N)r7rZr6rfr9r9r9r:r%Hs�
AsyncIterablec@seZdZdZdS)r&r9N)r7rZr6rfr9r9r9r:r&Qsc@seZdZdZdS)�
AsyncIteratorr9N)r7rZr6rfr9r9r9r:r'Tsr'c@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r\sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r`sc@s"eZdZdZeed�dd��ZdS)r r9)�returncCsdS)Nr9)rQr9r9r:�__int__gszSupportsInt.__int__N)r7rZr6rfr�intr)r9r9r9r:r dsc@s"eZdZdZeed�dd��ZdS)rr9)r(cCsdS)Nr9)rQr9r9r:�	__float__oszSupportsFloat.__float__N)r7rZr6rfr�floatr+r9r9r9r:rlsc@s"eZdZdZeed�dd��ZdS)�SupportsComplexr9)r(cCsdS)Nr9)rQr9r9r:�__complex__wszSupportsComplex.__complex__N)r7rZr6rfr�complexr.r9r9r9r:r-tsr-c@s"eZdZdZeed�dd��ZdS)�
SupportsBytesr9)r(cCsdS)Nr9)rQr9r9r:�	__bytes__szSupportsBytes.__bytes__N)r7rZr6rfr�bytesr1r9r9r9r:r0|sr0c@s"eZdZdZeed�dd��ZdS)rr9)r(cCsdS)Nr9)rQr9r9r:�__abs__�szSupportsAbs.__abs__N)r7rZr6rfrr�r3r9r9r9r:r�sc@s&eZdZdZedeed�dd��ZdS)r!r9r)�ndigitsr(cCsdS)Nr9)rQr4r9r9r:�	__round__�szSupportsRound.__round__N)r)r7rZr6rfrr*r�r5r9r9r9r:r!�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r�sc@s"eZdZdZedd�dd��ZdS)rr9zIterator[T_co])r(cCsdS)Nr9)rQr9r9r:�__reversed__�szReversible.__reversed__N)r7rZr6rfrr6r9r9r9r:r�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r�s�
Collectionc@seZdZdZdS)r7r9N)r7rZr6rfr9r9r9r:r7�sc@seZdZdZdS)r
r9N)r7rZr6rfr9r9r9r:r
�sc@seZdZdZdS)r
r9N)r7rZr6rfr9r9r9r:r
�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r�sc@seZdZdZdd�ZdS)r$r9cOs$t|t�rtd��tt|f|�|�S)Nz4Type List cannot be instantiated; use list() instead)r�r$rFr�r�)rLrRrSr9r9r:rK�s
zList.__new__N)r7rZr6rfrKr9r9r9r:r$�sc@seZdZdZdd�ZdS)r%r9cOs$t|t�rtd��tt|f|�|�S)Nz2Type Set cannot be instantiated; use set() instead)r�r%rFr�r�)rLrRrSr9r9r:rK�s
zSet.__new__N)r7rZr6rfrKr9r9r9r:r%�sc@seZdZdZdd�ZdS)r&r9cOs$t|t�rtd��tt|f|�|�S)Nz>Type FrozenSet cannot be instantiated; use frozenset() instead)r�r&rFr�r�)rLrRrSr9r9r:rK�s
zFrozenSet.__new__N)r7rZr6rfrKr9r9r9r:r&�sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:rsc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:rsc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:r
sc@seZdZdZdS)rr9N)r7rZr6rfr9r9r9r:rs�AbstractContextManagerc@seZdZdZdS)�ContextManagerr9N)r7rZr6rfr9r9r9r:r9sr9c@seZdZdZdd�ZdS)r"r9cOs$t|t�rtd��tt|f|�|�S)Nz4Type Dict cannot be instantiated; use dict() instead)r�r"rFr�r�)rLrRrSr9r9r:rK"s
zDict.__new__N)r7rZr6rfrKr9r9r9r:r"sc@seZdZdZdd�ZdS)r#r9cOs&t|t�rtd��ttj|f|�|�S)NzNType DefaultDict cannot be instantiated; use collections.defaultdict() instead)r�r#rFr��collections�defaultdict)rLrRrSr9r9r:rK-s
zDefaultDict.__new__N)r7rZr6rfrKr9r9r9r:r#(sc@seZdZdZdd�ZdS)r(r9cOs$t|t�rtd��tt|f|�|�S)Nz@Type Generator cannot be instantiated; create a subclass instead)r�r(rFr��_G_base)rLrRrSr9r9r:rK@s
zGenerator.__new__N)r7rZr6rfrKr9r9r9r:r(<s�CT_co)r�r�c@seZdZdZdZdS)r
a�A special construct usable to annotate class objects.

    For example, suppose we have the following classes::

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

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

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

      joe = new_user(BasicUser)

    At this point the type checker knows that joe has type BasicUser.
    r9N)r7rZr6r]rfr9r9r9r:r
Lsc	snd��fdd�|D�}t�|dd�|D��}t|�|_yt�d�j�dd�|_Wnt	t
fk
rhYnX|S)NzDNamedTuple('Name', [(f0, t0), (f1, t1), ...]); each t must be a typecsg|]\}}|t|��f�qSr9)rr)r��nr�)r�r9r:�
<listcomp>isz!_make_nmtuple.<locals>.<listcomp>cSsg|]\}}|�qSr9r9)r�r>r�r9r9r:r?jsr2r7�__main__)r:�
namedtupler�Z_field_typesr4r�r�rrZr�r�)rMr�Znm_tplr9)r�r:�
_make_nmtuplegs
rBr2)r3�cseZdZ�fdd�Z�ZS)�NamedTupleMetacsD|�dd�rt��||||�Sts*td��|�di�}t||���S)NrEFz<Class syntax for NamedTuple is only supported in Python 3.6+r
)rrJrK�_PY36rFrBr)rL�typenamerN�nsr�)rPr9r:rKxszNamedTupleMeta.__new__)r7rZr6rKr_r9r9)rPr:rDvsrDc@seZdZdZdZddd�ZdS)r'a�Typed version of namedtuple.

    Usage in Python versions >= 3.6::

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

    This is equivalent to::

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

    The resulting class has one extra attribute: _field_types,
    giving a dict mapping field names to types.  (The field names
    are in the _fields attribute, which is part of the namedtuple
    API.) Alternative equivalent keyword syntax is also accepted::

        Employee = NamedTuple('Employee', name=str, id=int)

    In Python versions <= 3.5 use::

        Employee = NamedTuple('Employee', [('name', str), ('id', int)])
    TNcKs8|rtstd��|dkr"|��}n|r.td��t||�S)Nz>Keyword syntax for NamedTuple is only supported in Python 3.6+zIEither list of fields or keywords can be provided to NamedTuple, not both)rErFrrB)rQrFZfields�kwargsr9r9r:rK�s
zNamedTuple.__new__)N)r7rZr6r]rErKr9r9r9r:r'�scCsdd�}||_||_|S)a%NewType creates simple unique types with almost zero
    runtime overhead. NewType(name, tp) is considered a subtype of tp
    by static type checkers. At runtime, NewType(name, tp) returns
    a dummy function that simply returns its argument. Usage::

        UserId = NewType('UserId', int)

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

        UserId('user')          # Fails type check

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

        num = UserId(5) + 1     # type: int
    cSs|S)Nr9)r8r9r9r:�new_type�szNewType.<locals>.new_type)r7Z
__supertype__)rMr�rIr9r9r:r,�sFc@s�eZdZdZdZeed�dd��Zeed�dd��Ze	dd�d	d
��Z
e	ed�dd��Ze	e
d�d
d��Ze	dd�dd��Ze	ed�dd��Ze	d7e
ed�dd��Ze	ed�dd��Ze	d8e
ed�dd��Ze	d9e
eed�dd��Ze	d:e
e
e
d �d!d"��Ze	ed�d#d$��Ze	e
d�d%d&��Ze	d;e
e
d'�d(d)��Ze	ed�d*d+��Ze	ee
d,�d-d.��Ze	eedd/�d0d1��Ze	d2d�d3d4��Ze	dd�d5d6��ZdS)<�IOa�Generic base class for TextIO and BinaryIO.

    This is an abstract, generic version of the return of open().

    NOTE: This does not distinguish between the different possible
    classes (text vs. binary, read vs. write vs. read/write,
    append-only, unbuffered).  The TextIO and BinaryIO subclasses
    below capture the distinctions between text vs. binary, which is
    pervasive in the interface; however we currently do not offer a
    way to track the other distinctions in the type system.
    r9)r(cCsdS)Nr9)rQr9r9r:�mode�szIO.modecCsdS)Nr9)rQr9r9r:rM�szIO.nameNcCsdS)Nr9)rQr9r9r:�close�szIO.closecCsdS)Nr9)rQr9r9r:�closed�sz	IO.closedcCsdS)Nr9)rQr9r9r:�fileno�sz	IO.filenocCsdS)Nr9)rQr9r9r:�flush�szIO.flushcCsdS)Nr9)rQr9r9r:�isatty�sz	IO.isattyr�)r>r(cCsdS)Nr9)rQr>r9r9r:�read�szIO.readcCsdS)Nr9)rQr9r9r:�readable�szIO.readable)�limitr(cCsdS)Nr9)rQrSr9r9r:�readline�szIO.readline)�hintr(cCsdS)Nr9)rQrUr9r9r:�	readlinesszIO.readlinesr)�offset�whencer(cCsdS)Nr9)rQrWrXr9r9r:�seekszIO.seekcCsdS)Nr9)rQr9r9r:�seekable	szIO.seekablecCsdS)Nr9)rQr9r9r:�tell
szIO.tell)�sizer(cCsdS)Nr9)rQr\r9r9r:�truncateszIO.truncatecCsdS)Nr9)rQr9r9r:�writableszIO.writable)�sr(cCsdS)Nr9)rQr_r9r9r:�writeszIO.write)�linesr(cCsdS)Nr9)rQrar9r9r:�
writelinessz
IO.writelinesz
IO[AnyStr]cCsdS)Nr9)rQr9r9r:�	__enter__!szIO.__enter__cCsdS)Nr9)rQrdr	�	tracebackr9r9r:�__exit__%szIO.__exit__)r�)r�)r�)r)N) r7rZr6r]rfrrbrKrMrrLr�rMr*rNrOrPr)rQrRrTr$rVrYrZr[r]r^r`rbrcrer9r9r9r:rJ�sTrJc@sBeZdZdZdZeeeefe	d�dd��Z
edd�dd��Zd	S)
�BinaryIOz5Typed version of the return of open() in binary mode.r9)r_r(cCsdS)Nr9)rQr_r9r9r:r`/szBinaryIO.write)r(cCsdS)Nr9)rQr9r9r:rc3szBinaryIO.__enter__N)r7rZr6r]rfrrr2�	bytearrayr*r`rcr9r9r9r:rf*srfc@s�eZdZdZdZeed�dd��Zeed�dd��Z	ee
ed�dd	��Zeed�d
d��Z
eed�dd
��Zedd�dd��ZdS)�TextIOz3Typed version of the return of open() in text mode.r9)r(cCsdS)Nr9)rQr9r9r:�buffer=sz
TextIO.buffercCsdS)Nr9)rQr9r9r:�encodingAszTextIO.encodingcCsdS)Nr9)rQr9r9r:�errorsEsz
TextIO.errorscCsdS)Nr9)rQr9r9r:�line_bufferingIszTextIO.line_bufferingcCsdS)Nr9)rQr9r9r:�newlinesMszTextIO.newlinescCsdS)Nr9)rQr9r9r:rcQszTextIO.__enter__N)r7rZr6r]rfrrfrirbrjrrkr�rlrrmrrcr9r9r9r:rh8srhc@s&eZdZdZdddgZeZeZeZdS)�ioz)Wrapper namespace for IO generic classes.rJrhrfN)r7rZr6r]�__all__rJrhrfr9r9r9r:rnVs

rnz.io�Pattern�cCs|jS)N)�pattern)r�r9r9r:�<lambda>c�rs�MatchcCs|jjS)N)�rerr)�mr9r9r:rsertc@s eZdZdZddgZeZeZdS)rvz&Wrapper namespace for re type aliases.rpruN)r7rZr6r]rorprur9r9r9r:rvhsrvz.re)NN)NN)�r�rrr:�
contextlibr�rvZ	stdlib_rer4r�Zcollections.abcZcollections_abc�ImportErrorror;rCrdrDr?r@r>r=rYr�rWrrrIr�rrr�r�r�r�r�r�r�r2rbr)r�r�r�r�r�r�r�rr�rr�r�r�r�r�r�r�r�rr�r�r�r�rcr	r�rr�rr*r
r+r-r.rr/rr�rr�r$r�r%r&r'rrr rr-r0rr!rrrr7r%r
rrrrrr*rr�r$r�r�r&rrrrr8r9r�r"r;r#r(r<�
GeneratorTyper=r
rBr5rErDr'r,r0r1rJrfrhrnr7�modulesrnrp�matchrur9r9r9r:�<module>s�*%5C
W
!)

 E"96

L	C








"








&`