HEX
Server: Apache/2.4.65 (Debian)
System: Linux kubikelcreative 5.10.0-35-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64
User: www-data (33)
PHP: 8.4.13
Disabled: NONE
Upload Files
File: //usr/lib/python3.5/__pycache__/typing.cpython-35.pyc


��j`�6@s�
ddlZddlmZmZddlZddlZddlZddlZddlZddl	Z	yddl
jZWnek
r�ddlZYnXddddddd	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�d8d9ed:d;�ZGd<d=�d=ed:d;�ZGd>d?�d?ed:d;�ZGd@dA�dAed:d;�ZdBdC�ZdDdE�ZdFdG�ZdHdI�ZdJdK�ZGdLdM�dMed:d;�Zed:d;�ZGdNd
�d
ed:d;�ZedO�ZedP�ZedQ�Z edRdSd;�Z!edTdSd;�Z"edUdSd;�Z#edVdWd;�Z$ed(e%e&�Z'dXdY�Z(dddZd[�Z)d\d]�Z*d^d_�Z+gZ,d`da�Z-Gdbdc�dced:d;�Z.e.d:d;�Z/Gddde�deed:d;�Z0e0d:d;�Z1dfdg�Z2dhdi�Z3djdk�Z4dldm�Z5dndo�Z6dpdq�Z7Gdrds�dseej8�Z9dZ:dtdu�Z;Gdvd�dd9e9�Z:Gdwdx�dx�Z<Gdydz�dz�Z=Gd{d|�d|e9�Z>Gd}d�de?d~e?d9e>�Z@Gdd��d�e9�ZAGd�d�dd~ejBd9eA�ZBGd�d��d�ed:d;�ZCeCd:d;�ZDd�d)�ZEd�d��ZFddd�d*�ZGd�d,�ZHd�d-�ZId�d��ZJd�d.�ZKGd�d��d�e9�ZLGd�d��d�d9eL�ZMejNZNeOed��r�Gd�d��d�e:e!d~ejP�ZPe
jQd��eOed��r�Gd�d��d�ePe"e:e!e$e"fd~ejR�ZRe
jQd��eOed��rMGd�d��d�e:e!d~ejS�ZSGd�d��d�eSe!d~ejT�ZTe
jQd��e
jQd��Gd�d�de:e!d~ejU�ZUGd�d�deUe!d~ejV�ZVGd�d�deM�ZWGd�d�deM�ZXGd�d��d�eM�ZYGd�d��d�eM�ZZGd�d�deMe!�Z[Gd�d �d eMe!�Z\eOed�rTGd�d�deUe!d~ej]�Z]nGd�d�deMe!�Z]ej^Z^Gd�d�de:e!d~ej_�Z_eOed��r�Gd�d��d�e^eUe!e_e!d~ej`�Z`e
jQd��eOed��rGd�d�de`e!d~eja�Zbn-Gd�d�de^eUe!e_e!d~eja�ZbGd�d�debed~ejc�ZceOed��r�Gd�d�de`ee:ee#fd~ejd�Zdn:Gd�d�de^eUee_ee:ee#fd~ejd�ZdGd�d�dedee fd~eje�ZeeOed�r�	eOed��rX	Gd�d�de]e!e`e!d~ejf�Zfq�	Gd�d�de^e]e!e_e!d~ejf�Zfn-Gd�d�de^eUe!e_e!d~ejf�ZfGd�d�defed~ejg�ZgGd�d
�d
efehd~eji�ZiGd�d#�d#ejeged~ej�ZkGd�d$�d$eleced~el�ZaGd�d%�d%emebe!d~em�ZnGd�d�de^eUe!d~ejo�ZoGd�d�deoeebed~ejp�ZpGd�d�deoe@ee#febe@ee#fe:ee#fd~ejq�ZqGd�d�deoe#d~ejr�ZreOed��raGd�d��d�e:e!d~ejs�Zte
jQd��Gd�d!�d!eueeee fd~eu�ZvGd�d"�d"ejweeee fd~ejw�ZxeOed'�r�ejyZzn	e	j{ZzGd�d'�d'eVe!e:e!e$e"fd~ez�Zyed�dSd;d�e�Z|Gd�d	�d	e:e|d~e�Z}d�d��Z~ejdd��d�kZ�Gd�d��d�e�Z�Gd�d&�d&d9e��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'eej�d���d�d���Z�ed�e'eej�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��)r3r3)�sys�version_info�__qualname__�__name__)�x�r9�/usr/lib/python3.5/typing.py�	_qualnameWsr;cCs/|jd�r+|dkr+|dd�}|S)N�_�
_TypeAlias�_ForwardRef�_TypingBase�_FinalTypingBase�)r=r>r?r@)�
startswith)Znmr9r9r:�
_trim_name_s	rCcsdeZdZdZdZdd�fdd�Zdd�Zdd	�Zd
d�Zdd
�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�_rootcsG|s.tddjtt|��p'd��t�j||||�S)NzCannot subclass %sz, z())�	TypeError�join�map�
_type_repr�super�__new__)�cls�name�bases�	namespacerE)�	__class__r9r:rKus"zTypingMeta.__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_varscCs#tt|��}d|j|fS)Nz%s.%s)rCr;�
__module__)rQ�qnamer9r9r:�__repr__�szTypingMeta.__repr__)
r7rZr6�__doc__�_is_protocolrKrTrWrYr\r9r9)rPr:rDfs
rDcsjeZdZdZfZdd�Z�fdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
�S)r?z0Internal indicator of special typing constructs.cOsdS)Nr9)rQrRrSr9r9r:rT�sz_TypingBase.__init__csXt|�dkrHt|dt�rHt|dt�rHtd|��t�j|�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)rFrc)rQrRrSr9r9r:�__call__�sz_TypingBase.__call__)r7rZr6r]�	__slots__rTrKrWrYr\rdr9r9)rPr:r?�sr?�	metaclassrETcs@eZdZdZfZdd�fdd�Zdd�Z�S)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.
    rEFcs<t�j|||�}|dkr(|Std|��dS)NTzCannot instantiate %r)rJrKrF)rLrErRrSrQ)rPr9r:rK�sz_FinalTypingBase.__new__cCstt|�j�S)N)rCrcr7)rQr9r9r:�
__reduce__�sz_FinalTypingBase.__reduce__)r7rZr6r]rerKrgr9r9)rPr:r@�sr@csveZdZdZdZ�fdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Z�S)r>z-Internal wrapper to hold a forward reference.�__forward_arg__�__forward_code__�__forward_evaluated__�__forward_value__cs�t�j|�t|t�s2td|f��yt|dd�}Wn%tk
rotd|f��YnX||_||_d|_	d|_
dS)Nz,Forward reference must be a string -- got %rz<string>�evalz1Forward reference must be an expression -- got %rF)rJrTr`rarF�compile�SyntaxErrorrhrirjrk)rQ�arg�code)rPr9r:rT�s
			z_ForwardRef.__init__cCs�|js||k	r�|dkr;|dkr;i}}n'|dkrP|}n|dkrb|}tt|j||�d�|_d|_|jS)Nz*Forward references must evaluate to types.T)rj�_type_checkrlrirk)rQrUrVr9r9r:rW�s
		z_ForwardRef._eval_typecCs5t|t�stS|j|jko4|j|jkS)N)r`r>�NotImplementedrhrk)rQ�otherr9r9r:�__eq__�sz_ForwardRef.__eq__cCst|j|jf�S)N)�hashrhrk)rQr9r9r:�__hash__�sz_ForwardRef.__hash__cCstd��dS)Nz4Forward references cannot be used with isinstance().)rF)rQ�objr9r9r:�__instancecheck__�sz_ForwardRef.__instancecheck__cCstd��dS)Nz4Forward references cannot be used with issubclass().)rF)rQrLr9r9r:�__subclasscheck__�sz_ForwardRef.__subclasscheck__cCsd|jfS)Nz_ForwardRef(%r))rh)rQr9r9r:r\�sz_ForwardRef.__repr__)rhrirjrk)r7rZr6r]rerTrWrtrvrxryr\r9r9)rPr:r>�sr>c@speZdZdZdZdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�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_checkercCs�t|t�s!tt|���t|t�sBtt|���t|t�sdtt|���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)r`ra�AssertionError�reprrcrDr?rMrzr{r|)rQrMrzr{r|r9r9r:rTs!!"'			z_TypeAlias.__init__cCsd|jt|j�fS)Nz%s[%s])rMrIrz)rQr9r9r:r\sz_TypeAlias.__repr__cCs�t|jt�s"td|��|jjrkt|t�rkt||jj�sktd||jf��t|t�r�||jk	r�td|��|j|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.)r`rzrrF�__constraints__rc�
issubclassrPrMr{r|)rQZ	parameterr9r9r:�__getitem__sz_TypeAlias.__getitem__cCs5t|t�stS|j|jko4|j|jkS)N)r`r=rrrMrz)rQrsr9r9r:rt+sz_TypeAlias.__eq__cCst|j|jf�S)N)rurMrz)rQr9r9r:rv0sz_TypeAlias.__hash__cCs.t|jt�std��t||j�S)Nz<Parameterized type aliases cannot be used with isinstance().)r`rzrrFr{)rQrwr9r9r:rx3sz_TypeAlias.__instancecheck__cCs.t|jt�std��t||j�S)Nz<Parameterized type aliases cannot be used with issubclass().)r`rzrrFr�r{)rQrLr9r9r:ry9sz_TypeAlias.__subclasscheck__N)rMrzr{r|)r7rZr6r]rerTr\r�rtrvrxryr9r9r9r:r=�sr=cCs@x9|D]1}t|t�s+t|t�r|j|�qWdS)N)r`rDr?rY)�typesrX�tr9r9r:rY@s
rYcCsg}t||�t|�S)N)rYrb)r�rXr9r9r:�
_type_varsFs
r�cCs2t|t�st|t�r.|j||�S|S)N)r`rDr?rW)r�rUrVr9r9r:rWLsrWcCs�|dkrtd�St|t�r1t|�}t|t�rUt|�jdksxt|ttf�r�t|�r�t|d|f��t|�jdkr�t|dd�s�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)r�r�)
rcr`rar>r?r7�callablerF�getattrrD�_gorgr�	_Protocol)ro�msgr9r9r:rqRs
$#'rqcCs�t|t�rOt|t�rO|jdkr8t|�Sd|jt|�fS|dkr_dSt|tj�rx|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...)	r`rcrDrZr;r��FunctionTyper7r~)rwr9r9r:rIms
rIc@s4eZdZdZfZdd�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.
    cCstd��dS)Nz%Any cannot be used with isinstance().)rF)rQrwr9r9r:rx�sz_Any.__instancecheck__cCstd��dS)Nz%Any cannot be used with issubclass().)rF)rQrLr9r9r:ry�sz_Any.__subclasscheck__N)r7rZr6r]rerxryr9r9r9r:r��s
r�c	speZdZdZdZddd	d
dd
�fdd
�Zdd�Zdd�Zdd�Zdd�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__�boundN�	covariantF�
contravariantc	s�t�j||d|d|d|�||_|rF|rFtd��t|�|_t|�|_|r�|dk	r�td��|r�t|�dkr�td��d�t	�fd	d
�|D��|_
|r�t|d�|_n	d|_dS)Nr�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)rq)�.0r�)r�r9r:�	<genexpr>�sz#TypeVar.__init__.<locals>.<genexpr>zBound must be a type.)
rJrTr7�
ValueError�boolr�r�rFr_rbrrqr�)rQrMr�r�r�Zconstraints)rP)r�r:rT�s 
	"zTypeVar.__init__cCs||kr|j|�dS)N)�append)rQrXr9r9r:rY�szTypeVar._get_type_varscCs5|jrd}n|jr$d}nd}||jS)N�+�-�~)r�r�r7)rQ�prefixr9r9r:r\�s				zTypeVar.__repr__cCstd��dS)Nz0Type variables cannot be used with isinstance().)rF)rQ�instancer9r9r:rx�szTypeVar.__instancecheck__cCstd��dS)Nz0Type variables cannot be used with issubclass().)rF)rQrLr9r9r:ry�szTypeVar.__subclasscheck__)r7r�rr�r�)
r7rZr6r]rerTrYr\rxryr9r9)rPr:r�s(		�T�KT�VT�T_cor��V_co�VT_co�T_contrar�cCsu|dkrg}t|d�r1|j||�St|t�rqx.t|�D] \}}||krM||SqMW|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�r`r�	enumerate)rorXrR�iZtvarr9r9r:�_replace_arg�sr�c
Cs�|jdkr|S|j}g}x)|jdk	rM|j|�|j}q%Wg}x*|jD]}|jt|||��q^WxV|D]N}g}x9t|j�D](\}	}|jt||j|��q�W|}q�W|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_argsroZoclsZ
new_tree_argsr�r9r9r:r�
s 	


 
r�cs�g}x�|D]�}t|t�rD|jtkrD|j|j�q
t|t�r�t|�dkr�|dtkr�|j|dd��q
|j|�q
Wt	|��t��t|�krg}x4|D],}|�kr�|j|��j
|�q�W|}�st���t	|��xS|D]K�t�t�sEq-t
�fdd���hD��r-�j
��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.
    rrANc3sK|]A}t|t�o$|jdk	st|t�oBt�|�VqdS)N)r`�GenericMetar�rcr�)r�Zt2)�t1r9r:r�Osz'_remove_dups_flatten.<locals>.<genexpr>c3s!|]}|�kr|VqdS)Nr9)r�r�)�
all_paramsr9r:r�Ts)r`r�r�r�extendr�rbr_r��set�remover}rc�any)�
parameters�params�pZ
new_paramsr�r9)r�r�r:�_remove_dups_flatten.s0
1


r�cCs~|jstdt|���t|�}t|j�}||krztd||kr^dndt|�||f��dS)Nz%s is not a generic classz0Too %s parameters for %s; actual %s, expected %sZmanyZfew)r�rFr~r_)rLr�ZalenZelenr9r9r:�_check_genericWs	r�csJtj����tj�j�tj����fdd��}|S)zInternal wrapper caching __getitem__ of generic types with a fallback to
    original function for non-hashable arguments.
    cs3y�||�SWntk
r%YnX�||�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�eZdZdZdZdddd�fd	d
�Zdd�Zd
d�Z�fdd�Z�fdd�Z	e
dd��Zdddd�Zdd�Z
dd�Zdd�Zdd�Z�S) 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__NrEFcst�j||||d|�}|dkrad|_d|_d|_ttd��|_|St|t	�s|t
d��|tkr�t|�}t
|�dkr�|dSt|�|_||_||_|j�}t|t	�rtt|��|_nt|�|_|S)NrErzExpected parameters=<tuple>rAr)r)rJrKr�r�r�ru�	frozensetr�r`rbrFrr�r_r�r�)rLr��originrErRrQZ	subs_tree)rPr9r:rK�s*!					z_Union.__new__cs�|jdkr|St��fdd�|jD��}t|j���}||jkro||jkro|S|j||dd�S)Nc3s!|]}t|���VqdS)N)rW)r�r�)rUrVr9r:r��sz$_Union._eval_type.<locals>.<genexpr>rET)r�rbrWr�rP)rQrUrV�ev_args�	ev_originr9)rUrVr:rW�s%z_Union._eval_typecCs&|jr"|jr"t|j|�dS)N)r�r�rY)rQrXr9r9r:rY�sz_Union._get_type_varscsR|jdkrt�j�S|j�}t|t�sAt|�S|dj|�S)Nr)r�rJr\r�r`rbr~�
_tree_repr)rQ�tree)rPr9r:r\�s

z_Union.__repr__cs~g}xW|dd�D]E}t|t�sB|jt|��q|j|dj|��qWt�j�ddj|�S)NrArz[%s]z, )r`rbr�rIr�rJr\rG)rQr��arg_listro)rPr9r:r��sz_Union._tree_reprcs�|fkrtd��t|t�s0|f}|jdkrHd�nd�t�fdd�|D��}|tk	r�t||�|j|d|dd�S)	Nz 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)rq)r�r�)r�r9r:r��sz%_Union.__getitem__.<locals>.<genexpr>r�rET)rFr`rbr�rr�rP)rQr�r9)r�r:r��s		
z_Union.__getitem__cCsS|tkrtSt|||�}t|�}t|�dkrH|dStf|S)NrAr)rr�r�r_)rQrXrRr�r9r9r:r��sz_Union._subs_treecCs/t|t�s|j�|kS|j|jkS)N)r`r�r�r�)rQrsr9r9r:rt�sz
_Union.__eq__cCs|jS)N)r�)rQr9r9r:rv�sz_Union.__hash__cCstd��dS)Nz(Unions cannot be used with isinstance().)rF)rQrwr9r9r:rx�sz_Union.__instancecheck__cCstd��dS)Nz(Unions cannot be used with issubclass().)rF)rQrLr9r9r:rysz_Union.__subclasscheck__)r�r�r�r�)r7rZr6r]rerKrWrYr\r�r�r�r�rtrvrxryr9r9)rPr:r�vs*
		r�c@s.eZdZdZfZedd��ZdS)r�zEOptional type.

    Optional[X] is equivalent to Union[X, None].
    cCs#t|d�}t|td�fS)Nz#Optional[t] requires a single type.)rqrrc)rQror9r9r:r�sz_Optional.__getitem__N)r7rZr6r]rer�r�r9r9r9r:r�sr�cCs8t|t�st�x|jdk	r3|j}qW|S)z@Return the farthest origin of a generic class (internal helper).N)r`r�r}r�)�ar9r9r:r�s
r�cCs:t|t�rt|t�s$t�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.
    )r`r�r}r�)r��br9r9r:�_geqv!s
$r�cCsft}xYt|jdd��D]>\}}t|t�r t|�tkr |j|d}q W|S)z�Helper for Generic.__new__.

    Returns the class after the last occurrence of Generic or
    Generic[...] in cls.__mro__.
    NrA���)�objectr��__mro__r`r�r�r)rLZnext_in_mror��cr9r9r:�_next_in_mro0s
&!r�cCsW|tkrtd|��|jdk	rStjd�jddkrStd��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)r�r�)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.
    cs�t���jj|�}|tk	r,|S�j|jkrBdSx<�jj�D]+}t|t�rjqRt||�rRdSqRWtS)NT)	r��	__extra__�__subclasshook__rrr��__subclasses__r`r�r�)�subclass�res�scls)rLr9r:�
__extrahook__Rs
z)_make_subclasshook.<locals>.__extrahook__cs-t���jr)t|�j�r)dStS)NT)r�r�r�rr)r�)rLr9r:r�as
)r`r�r��ABCMeta)rLr�r9)rLr:�_make_subclasshookIsr�cCsAt|�}d|kr=x"|dD]}|j|d�q#W|S)z�Internal helper: copy class __dict__ and clean slots class variables.
    (They will be re-created if necessary by normal class machinery.)
    reN)�dict�pop)ZdctZ	dict_copyZslotr9r9r:�_no_slots_copyis
r�cs�eZdZdZddddd�fdd�Zdd�Zdd�Z�fd	d
�Z�fdd�Zddd
d�Z	dd�Z
dd�Zedd��Z
dd�Zdd�Z�S)r�zMetaclass for generic types.Nc	sW|dk	rF|dk	st�tdd�|D��s�t|��nI|dks^t|��|dksvt|��|dks�t|��t|�}d}	xe|D]]}
|
tkr�td��t|
t�r�|
jtkr�|	dk	r�td��|
j}	q�W|	dkr|}	nrt	|�}t	|	��|�ks�tddj
�fdd�|D��dj
dd�|	D��f��|	}|}|dk	r�t|�tj
kr�||kr�|f|}td	d�|D��}td
d�|D��rtdd�|D��}t�j||||dd
�}
||
_|rctdd�|D��nd|
_||
_||
_t|
�|
_|dkr�||
_d|kr�|s�t|
jd�r�|
jjdkr�t|
�|
_t|tj
�r|j|
_|r&t|d�r&|j|
_|r>t|
j��nt|
jf�|
_|
S)Ncss|]}t|t�VqdS)N)r`r)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)ra)r�r�)�gvarsetr9r:r��scss|]}t|�VqdS)N)ra)r��gr9r9r:r��scss0|]&}t|t�r$t|�n|VqdS)N)r`r�r�)r�r�r9r9r:r��scss*|] }t|t�o!|tk	VqdS)N)r`r�r)r�r�r9r9r:r��scss!|]}|tk	r|VqdS)N)r)r�r�r9r9r:r��srETcss9|]/}|tkrdn|tkr-fn|VqdS).N)�_TypingEllipsis�_TypingEmpty)r�r�r9r9r:r��sr�r7r�r6) r}�allr�rrFr`r�r�r�r�rGrcr�r�rbr�rJrKr�r�r��__next_in_mro__�__orig_bases__r�r�r7r��
_abc_registryr6rur�r�)rLrMrNrOrXrRr��extra�
orig_basesZgvars�baseZtvarsetZ
initial_basesrQ)rP)r�r:rKwsf(
	
	#-
!	(			-zGenericMeta.__new__cCs&|jr"|jr"t|j|�dS)N)r�r�rY)rQrXr9r9r:rY�szGenericMeta._get_type_varscs�|jr|jj���nd}|jrRt��fdd�|jD��nd}||jkrz||jkrz|S|j|j|jt|j�d|r�t	|�ndd|d|d|j
d|j�S)Nc3s!|]}t|���VqdS)N)rW)r�r�)rUrVr9r:r��sz)GenericMeta._eval_type.<locals>.<genexpr>rXrRr�r�r�)r�rWr�rbrPr7�	__bases__r��__dict__r�r�r�)rQrUrVr�r�r9)rUrVr:rW�s$4	zGenericMeta._eval_typecs/|jdkrt�j�S|j|j��S)N)r�rJr\r�r�)rQ)rPr9r:r\�s
zGenericMeta.__repr__cs�g}xs|dd�D]a}|fkr9|jd�qt|t�s^|jt|��q|j|dj|��qWt�j�ddj|�S)NrAz()rz[%s]z, )r�r`rbrIr�rJr\rG)rQr�r�ro)rPr9r:r��szGenericMeta._tree_reprcCs<|jdkr|St|||�}t|�ft|�S)N)r�r�r�rb)rQrXrRr�r9r9r:r��szGenericMeta._subs_treecCsKt|t�stS|jdks1|jdkr;||kS|j|jkS)N)r`r�rrr�r�)rQrsr9r9r:rt�s

zGenericMeta.__eq__cCs|jS)N)r�)rQr9r9r:rv�szGenericMeta.__hash__cs�t|t�s|f}|rGt|�tk	rGtdt|���d�t�fdd�|D��}|tkr�tdd�|D��s�td��tt	|��t|�kr�td��|}|}n�|tt
fkr�t|�}|}nh|tkr|}|}nM|j
ttfkrFtdt|���nt||�t|�}|}|j|j|jt|j�d	|d
|d|d|jd
|j�S)Nz)Parameter list to %s[...] cannot be emptyz*Parameters to generic types must be types.c3s|]}t|��VqdS)N)rq)r�r�)r�r9r:r�sz*GenericMeta.__getitem__.<locals>.<genexpr>css|]}t|t�VqdS)N)r`r)r�r�r9r9r:r�sz5Parameters to Generic[...] must all be type variablesz-Parameters to Generic[...] must all be uniquez'Cannot subscript already-subscripted %srXrRr�r�r�)r`rbr�r	rFr;rr�r_r�rr�r�r�r~r�rPr7r�r�r�r�r�)rQr�rXrRr9)r�r:r��sH						
	zGenericMeta.__getitem__cCst|j|�S)N)r�rP)rQr�r9r9r:rx(szGenericMeta.__instancecheck__c	Cs@|j|j|jt|j�|j|j|j|j|j	�S)N)
rPr7r�r�r�r�r�r�r�r�)rQr9r9r:�__copy__0szGenericMeta.__copy__)r7rZr6r]rKrYrWr\r�r�rtrvr�r�rxr�r9r9)rPr:r�ts!P,r�cOsq|jdkr|j|�St|�}|j|�}y
||_Wntk
rXYnX|j||�|SdS)N)r�rKr�Z__orig_class__�AttributeErrorrT)Zbase_clsrLrRrSr�rwr9r9r:�_generic_new;s


r�c@s(eZdZdZfZdd�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
    cOs1t|t�rtd��t|j|||�S)NzHType Generic cannot be instantiated; it can be used only as a base class)r�rrFr�r�)rLrRrSr9r9r:rKbszGeneric.__new__N)r7rZr6r]rerKr9r9r9r:rKsc@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�isr�c@seZdZdZdS)r�z(Internal placeholder for ... (ellipsis).N)r7rZr6r]r9r9r9r:r�psr�csFeZdZdZe�fdd��Zdd�Zdd�Z�S)�	TupleMetazMetaclass for Tuple (internal).cs�|jdk	st|t�r/t�j|�S|fkrNt�jtf�St|t�sf|f}t|�dkr�|ddkr�d�t	|d��}t�j|t
f�Sd�t�fdd�|D��}t�j|�S)	Nr2rA.z Tuple[t, ...]: t must be a type.rz*Tuple[t0, t1, ...]: each t must be a type.c3s|]}t|��VqdS)N)rq)r�r�)r�r9r:r��sz(TupleMeta.__getitem__.<locals>.<genexpr>)r�r�r	rJr�r�r`rbr_rqr�)rQr�r�)rP)r�r:r�ws	"zTupleMeta.__getitem__cCs,|jdkrt|t�Std��dS)Nz5Parameterized Tuple cannot be used with isinstance().)r�r`rbrF)rQrwr9r9r:rx�s
zTupleMeta.__instancecheck__cCs,|jdkrt|t�Std��dS)Nz5Parameterized Tuple cannot be used with issubclass().)r�r�rbrF)rQrLr9r9r:ry�s
zTupleMeta.__subclasscheck__)r7rZr6r]r�r�rxryr9r9)rPr:r�tsr�c@s(eZdZdZfZdd�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, ...].
    cOs.t|t�rtd��tt|||�S)Nz6Type Tuple cannot be instantiated; use tuple() instead)r�r	rFr�rb)rLrRrSr9r9r:rK�sz
Tuple.__new__N)r7rZr6r]rerKr9r9r9r:r	�sr�csdeZdZdZ�fdd�Z�fdd�Z�fdd�Ze�fdd	��Z�S)
�CallableMetaz"Metaclass for Callable (internal).cs/|jdkrt�j�S|j|j��S)N)r�rJr\r�r�)rQ)rPr9r:r\�s
zCallableMeta.__repr__cs�t|�tk	r"t�j|�Sg}xW|dd�D]E}t|t�sd|jt|��q9|j|dj|��q9W|ddkr�t|d�d|dSt|d�ddj	|dd��|dfS)	NrArz...z	[..., %s]z
[[%s], %s]z, r�r�)
r�rrJr�r`rbr�rIr~rG)rQr�r�ro)rPr9r:r��s
zCallableMeta._tree_reprcs�|jdk	st|t�r/t�j|�St|t�sQt|�dkr]td��|\}}|t	kr�t	|f}n4t|t
�s�td|f��t|�|f}|j|�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�r`rbr_rF�Ellipsis�list�__getitem_inner__)rQr�rR�result)rPr9r:r��s"
zCallableMeta.__getitem__cs�|\}}d�t|��}|tkrCt�jt|f�Sd�t�fdd�|D��}||f}t�j|�S)Nz.Callable[args, result]: result must be a type.z6Callable[[arg, ...], result]: each arg must be a type.c3s|]}t|��VqdS)N)rq)r�ro)r�r9r:r��sz1CallableMeta.__getitem_inner__.<locals>.<genexpr>)rqr�rJr�r�rb)rQr�rRr�)rP)r�r:r��s
zCallableMeta.__getitem_inner__)	r7rZr6r]r\r�r�r�r�r9r9)rPr:r��s
r�c@s(eZdZdZfZdd�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.
    cOs1t|t�rtd��t|j|||�S)NzIType Callable cannot be instantiated; use a non-abstract subclass instead)r�rrFr�r�)rLrRrSr9r9r:rK�szCallable.__new__N)r7rZr6r]rerKr9r9r9r:r�s	csmeZdZdZdZddd�Zdd�Zdd	�Z�fd
d�Zdd
�Z	dd�Z
�S)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|�}|jdkrJ|t|dj|jdd���dd�Stdj|jdd����dS)Nz{} accepts only single type.rArETz {} cannot be further subscripted)rcr�rq�formatr7rF)rQ�itemrLr9r9r:r�s		z_ClassVar.__getitem__cCs>t|j||�}||jkr(|St|�|dd�S)NrET)rWr�rc)rQrUrVZnew_tpr9r9r:rWsz_ClassVar._eval_typecs>t�j�}|jdk	r:|djt|j��7}|S)Nz[{}])rJr\r�r�rI)rQ�r)rPr9r:r\sz_ClassVar.__repr__cCstt|�j|jf�S)N)rurcr7r�)rQr9r9r:rv!sz_ClassVar.__hash__cCs<t|t�stS|jdk	r2|j|jkS||kS)N)r`r�rrr�)rQrsr9r9r:rt$s
z_ClassVar.__eq__)r�)r7rZr6r]rerTr�rWr\rvrtr9r9)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
r%iSYnX|j}|j}|d|�}|jpTf}|j}|rrt|�ni}|t|�}xCt||d�|�D](\}}	||ks�t	�|	||<q�W|S)z:Internal helper to extract the default arguments, by name.N)
�__code__r��co_argcount�co_varnames�__defaults__�__kwdefaults__r�r_�zipr})
r�rpZ	pos_countZ	arg_names�defaultsZ
kwdefaultsr�Z
pos_offsetrM�valuer9r9r:�
_get_defaults:s

				&r
c	Cs<t|dd�riS|dkrIt|di�}|dkr[|}n|dkr[|}t|t�ri}x�t|j�D]�}|jjdi�}xi|j�D][\}}|dkr�td�}t|t�r�t	|�}t
|||�}|||<q�Wq�W|St|dd�}|dkr�t|tj�sut|tj
�sut|tj�sut|tj�ryiStdj|���t|�}t|�}x�|j�D]�\}}|dkr�td�}t|t�r�t	|�}t
|||�}||kr*||dkr*t|}|||<q�W|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�r`rc�reversedr�r��get�itemsrar>rWr�r��BuiltinFunctionType�
MethodType�
ModuleTyperFr�r
r�r)	rwrUrVZhintsr�ZannrMr	rr9r9r:r+NsR		
cCs�t|t�r�|jj�}x9|jj�D](\}}||jkr.|j|�q.WxH|j�D]:}t|tj	�r�d|_
t|t�rgt|�qgWy
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)
r`rcr��copyrr�r��valuesr�r�rr-rF)roZ	arg_attrs�attrrrwr9r9r:r-�s		

cs%tj���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.�s!cOstd��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/�scs@eZdZdZ�fdd�Zdd�Zdd�Z�S)�
_ProtocolMetaz~Internal metaclass for _Protocol.

    This exists so _Protocol classes can be generic without deriving
    from Generic.
    cs/t|jkrt�j|�Std��dS)Nz+Protocols cannot be used with isinstance().)r�r�rJrxrF)rQrw)rPr9r:rx�sz_ProtocolMeta.__instancecheck__csd|js
tS|tkrdS|j�}x4|D],�t�fdd�|jD��s0dSq0WdS)NTc3s|]}�|jkVqdS)N)r�)r��d)rr9r:r�sz2_ProtocolMeta.__subclasscheck__.<locals>.<genexpr>F)r^rrr��_get_protocol_attrsr�r�)rQrL�attrsr9)rr:ry�s	
"z_ProtocolMeta.__subclasscheck__cCs�g}x?|jD]4}t|dd�r|jdkr|j|�qWt�}x<|D]4}x+|jj�D]}x|jD]5}||k	r~||jkr~t|dd�r~Pq~W|jd�rn|dkrn|dkrn|dkrn|dkrn|dkrn|d	krn|d
krn|dkrn|dkrn|d
krn|dkrn|dkrn|dkrn|dkrn|dkrn|j|�qnWqXW|S)Nr^Fr��_abc_�__abstractmethods__r
�__weakref__r�r�rerr�r�r�r�r�r�rZ)	r�r�r7r�r�r��keysrB�add)rQZprotocol_basesr�rr�rr9r9r:rs:!	
z!_ProtocolMeta._get_protocol_attrs)r7rZr6r]rxryrr9r9)rPr:r�src@s"eZdZdZfZdZdS)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).
    TN)r7rZr6r]rer^r9r9r9r:r�-sr��	Awaitablec@seZdZfZdS)r$N)r7rZr6rer9r9r9r:r$As�	Coroutinec@seZdZfZdS)r%N)r7rZr6rer9r9r9r:r%Hs�
AsyncIterablec@seZdZfZdS)r&N)r7rZr6rer9r9r9r:r&Qsc@seZdZfZdS)�
AsyncIteratorN)r7rZr6rer9r9r9r:r'Tsr'c@seZdZfZdS)rN)r7rZr6rer9r9r9r:r\sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r`sc@s1eZdZfZeeddd���ZdS)r )�returncCsdS)Nr9)rQr9r9r:�__int__gszSupportsInt.__int__N)r7rZr6rer�intr)r9r9r9r:r dsc@s1eZdZfZeeddd���ZdS)r)r(cCsdS)Nr9)rQr9r9r:�	__float__oszSupportsFloat.__float__N)r7rZr6rer�floatr+r9r9r9r:rlsc@s1eZdZfZeeddd���ZdS)�SupportsComplex)r(cCsdS)Nr9)rQr9r9r:�__complex__wszSupportsComplex.__complex__N)r7rZr6rer�complexr.r9r9r9r:r-tsr-c@s1eZdZfZeeddd���ZdS)�
SupportsBytes)r(cCsdS)Nr9)rQr9r9r:�	__bytes__szSupportsBytes.__bytes__N)r7rZr6rer�bytesr1r9r9r9r:r0|sr0c@s1eZdZfZeeddd���ZdS)r)r(cCsdS)Nr9)rQr9r9r:�__abs__�szSupportsAbs.__abs__N)r7rZr6rerr�r3r9r9r9r:r�sc@s7eZdZfZedeeddd���ZdS)r!r)�ndigitsr(cCsdS)Nr9)rQr4r9r9r:�	__round__�szSupportsRound.__round__N)r7rZr6rerr*r�r5r9r9r9r:r!�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r�sc@s1eZdZfZedddd���ZdS)rzIterator[T_co])r(cCsdS)Nr9)rQr9r9r:�__reversed__�szReversible.__reversed__N)r7rZr6rerr6r9r9r9r:r�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r�s�
Collectionc@seZdZfZdS)r7N)r7rZr6rer9r9r9r:r7�sc@seZdZfZdS)r
N)r7rZr6rer9r9r9r:r
�sc@seZdZfZdS)r
N)r7rZr6rer9r9r9r:r
�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r�sc@s"eZdZfZdd�ZdS)r$cOs.t|t�rtd��tt|||�S)Nz4Type List cannot be instantiated; use list() instead)r�r$rFr�r�)rLrRrSr9r9r:rK�szList.__new__N)r7rZr6rerKr9r9r9r:r$�sc@s"eZdZfZdd�ZdS)r%cOs.t|t�rtd��tt|||�S)Nz2Type Set cannot be instantiated; use set() instead)r�r%rFr�r�)rLrRrSr9r9r:rK�szSet.__new__N)r7rZr6rerKr9r9r9r:r%�sc@s"eZdZfZdd�ZdS)r&cOs.t|t�rtd��tt|||�S)Nz>Type FrozenSet cannot be instantiated; use frozenset() instead)r�r&rFr�r�)rLrRrSr9r9r:rK�szFrozenSet.__new__N)r7rZr6rerKr9r9r9r:r&�sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:rsc@seZdZfZdS)rN)r7rZr6rer9r9r9r:rsc@seZdZfZdS)rN)r7rZr6rer9r9r9r:r
sc@seZdZfZdS)rN)r7rZr6rer9r9r9r:rs�AbstractContextManagerc@seZdZfZdS)�ContextManagerN)r7rZr6rer9r9r9r:r9sr9c@s"eZdZfZdd�ZdS)r"cOs.t|t�rtd��tt|||�S)Nz4Type Dict cannot be instantiated; use dict() instead)r�r"rFr�r�)rLrRrSr9r9r:rK"szDict.__new__N)r7rZr6rerKr9r9r9r:r"sc@s"eZdZfZdd�ZdS)r#cOs1t|t�rtd��ttj|||�S)NzNType DefaultDict cannot be instantiated; use collections.defaultdict() instead)r�r#rFr��collections�defaultdict)rLrRrSr9r9r:rK-szDefaultDict.__new__N)r7rZr6rerKr9r9r9r:r#(sc@s"eZdZfZdd�ZdS)r(cOs.t|t�rtd��tt|||�S)Nz@Type Generator cannot be instantiated; create a subclass instead)r�r(rFr��_G_base)rLrRrSr9r9r:rK@szGenerator.__new__N)r7rZr6rerKr9r9r9r:r(<s�CT_cor�c@seZdZdZfZdS)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.
    N)r7rZr6r]rer9r9r9r:r
Lscs�d��fdd�|D�}tj|dd�|D��}t|�|_y%tjd�jjdd�|_Wnt	t
fk
r�YnX|S)NzDNamedTuple('Name', [(f0, t0), (f1, t1), ...]); each t must be a typecs+g|]!\}}|t|��f�qSr9)rq)r��nr�)r�r9r:�
<listcomp>is	z!_make_nmtuple.<locals>.<listcomp>cSsg|]\}}|�qSr9r9)r�r>r�r9r9r:r?js	r2r7�__main__)r:�
namedtupler�Z_field_typesr4r�r�rrZr�r�)rMr�Znm_tplr9)r�r:�
_make_nmtuplegs%rBr2r3�cs"eZdZ�fdd�Z�S)�NamedTupleMetacsb|jdd�r+t�j||||�Sts=td��|jdi�}t||j��S)NrEFz<Class syntax for NamedTuple is only supported in Python 3.6+r
)rrJrK�_PY36rFrBr)rL�typenamerN�nsr�)rPr9r:rKxszNamedTupleMeta.__new__)r7rZr6rKr9r9)rPr:rDvsrDc@s+eZdZdZdZddd�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)])
    TNcKsS|rtrtd��|dkr4|j�}n|rFtd��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__)r7rZr6r]rErKr9r9r9r:r'�scCs"dd�}||_||_|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,�s		Fc@sgeZdZdZfZeeddd���Zeeddd���Ze	dddd	���Z
e	edd
d���Ze	e
ddd
���Ze	dddd���Ze	eddd���Ze	d6e
eddd���Ze	eddd���Ze	d7e
eddd���Ze	d8e
eeddd���Ze	de
e
e
dd d!���Ze	edd"d#���Ze	e
dd$d%���Ze	de
e
d&d'd(���Ze	edd)d*���Ze	ee
d+d,d-���Ze	eedd.d/d0���Ze	d1dd2d3���Ze	ddd4d5���ZdS)9�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.
    )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.isattyrA)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)rQrcr	�	tracebackr9r9r:�__exit__%szIO.__exit__r�r�r�) r7rZr6r]rerrarKrMrrLr�rMr*rNrOrPr)rQrRrTr$rVrYrZr[r]r^r`rbrcrer9r9r9r:rJ�sT"!rJc@s_eZdZdZfZeeeefe	ddd���Z
edddd���ZdS)	�BinaryIOz5Typed version of the return of open() in binary mode.)r_r(cCsdS)Nr9)rQr_r9r9r:r`/szBinaryIO.write)r(cCsdS)Nr9)rQr9r9r:rc3szBinaryIO.__enter__N)r7rZr6r]rerrr2�	bytearrayr*r`rcr9r9r9r:rf*s%rfc@s�eZdZdZfZeeddd���Zeeddd���Z	ee
eddd���Zeedd	d
���Z
eeddd���Zeddd
d���ZdS)�TextIOz3Typed version of the return of open() in text mode.)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]rerrfrirarjrrkr�rlrrmrrcr9r9r9r:rh8srhc@s7eZdZdZdddgZeZeZeZdS)�ioz)Wrapper namespace for IO generic classes.rJrhrfN)r7rZr6r]�__all__rJrhrfr9r9r9r:rnVs
rnz.io�Pattern�cCs|jS)N)�pattern)r�r9r9r:�<lambda>csrs�MatchcCs
|jjS)N)�rerr)�mr9r9r:rsesc@s.eZdZdZddgZeZeZdS)ruz&Wrapper namespace for re type aliases.rprtN)r7rZr6r]rorprtr9r9r9r:ruhsruz.re)r3rC)�r�rrr:�
contextlibr�ruZ	stdlib_rer4r��collections.abcZcollections_abc�ImportErrorror;rCrcrDr?r@r>r=rYr�rWrqrIr�rrr�r�r�r�r�r�r�r2rar)r�r�r�r�r�r�r�rr�rr�r�r�r�r�r�r�r�rr�r�r�r�rbr	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�modulesrmrp�matchrtr9r9r9r:�<module>s�
	*%5CW!)� �""9"6L	C	#
'
#

##&	#!
!#$.)!!#####
&##
)
#	'	 &`