MINI MINI MANI MO

Path : /lib64/python3.6/__pycache__/
File Upload :
Current File : //lib64/python3.6/__pycache__/typing.cpython-36.pyc

3


 \9D@sddlZddlmZmZddlZddlZddlZddlZddlZddl	Z	yddl
jZWnek
rrddlZYnXej
dddkrddlZyddl	mZmZmZWn4ek
reejZeejZeejZYnXddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:g4Zd;d<Zd=d>ZGd?d@d@eZGdAdBdBedCdDZGdEdFdFedCdGZGdHdIdIedCdGZGdJdKdKedCdGZdLdMZ dNdOZ!dPdQZ"dRdSZ#dTdUZ$GdVdWdWedCdGZ%e%dCdGZ&GdXdYdYedCdGZ'e'dCdGZ(GdZddedCdGZ)e)d[Z*e)d\Z+e)d]Z,e)d^dCd_Z-e)d`dCd_Z.e)dadCd_Z/e)dbdCdcZ0e)d2e1eZ2dddeZ3ddfdgZ4dhdiZ5djdkZ6gZ7dldmZ8GdndodoedCdGZ9e9dCdGZ:GdpdqdqedCdGZ;e;dCdGZ<drdsZ=dtduZ>dvdwZ?Gdxddeej@ZAdZBdydzZCGd{d
d
eAd|ZBGd}d~d~ZDGdddZEGdddeAZFGdddeGeGeFdZHGdddeAZIGdddejJeIdZJGdddedCdGZKeKdCdGZLdd3ZMddZNe	jOe	jPe	jQe	jReeefZSddd4ZTdd6ZUdd7ZVddZWdd8ZXGdddeAZYGdddeYd|ZZej[Z[e\edrjGdddeBe-ej]dZ]ej^de\edrGddde]e.eBe-e0e.fej_dZ_ej^de\edrGdddeBe-ej`dZ`Gddde`e-ejadZaej^dej^dGdddeBe-ejbdZbGdddebe-ejcdZcGdd'd'eZZdGdd&d&eZZeGdd%d%eZZfGdd$d$eZZgGdd#d#eZe-ZhGdd(d(eZe-Zie\ed"rGdd"d"ebe-ejjdZjnGdd"d"eZe-ZjejkZkGdddeBe-ejldZle\edr*Gdddekebe-ele-ejmdZmej^de\edrRGdddeme-ejndZon"Gdddekebe-ele-ejndZoGdddeoe*ejpdZpe\edrGdddeme+eBe+e/fejqdZqn,Gdddekebe+ele+eBe+e/fejqdZqGdddeqe+e,fejrdZre\ed"rhe\edrDGdddeje-eme-ejsdZsn"Gdddekeje-ele-ejsdZsn"Gdddekebe-ele-ejsdZsGdddese*ejtdZtGdddeseuejvdZvGdd-d-ewete*ewdZxGdd*d*ejyete*ejydZzGdd.d.e{epe*e{dZnGdd/d/e|eoe-e|dZ}Gdddekebe-ej~dZ~Gddde~e+eoe+ejdZGddde~eHe+e/feoeHe+e/feBe+e/fejdZGdd!d!e~e/ejdZe\edrGdddeBe-ejdZnGdddeBe-Ze\edÃ	r(GddńdeBe-ejdZej^dŃnej
dddk	rDedǃGdd+d+eere+e,fedZGdd,d,ejere+e,fejdZGdd)d)ejee*eufejdZe\ed˃	rej^d˃Gdd˄dejere+e,fejdZe\ed1	rejZne	jZGdd1d1ece-eBe-e0e.fedZe\ed΃
rVGdd΄deae-eBe-e0fejdZej^d΃e)ddCedэZGdd
d
eBeedZddԄZej
dddkZdZdZGdddeZGdd0d0ed|Zdd5ZeZdZGdddeBe2ZGdddee1ZGdddeeZGdddZede_eejej<ede2eejdddZede2eejddddZGdddZede_eejej<dS(N)abstractmethodabstractproperty)WrapperDescriptorTypeMethodWrapperTypeMethodDescriptorTypeAnyCallableClassVarGenericOptionalTupleTypeTypeVarUnionAbstractSetGenericMeta
ByteString	ContainerContextManagerHashable	ItemsViewIterableIteratorKeysViewMappingMappingViewMutableMappingMutableSequence
MutableSetSequenceSized
ValuesView
ReversibleSupportsAbs
SupportsBytesSupportsComplex
SupportsFloatSupportsInt
SupportsRoundCounterDequeDictDefaultDictListSet	FrozenSet
NamedTuple	GeneratorAnyStrcastget_type_hintsNewType
no_type_checkno_type_check_decoratoroverloadText
TYPE_CHECKINGcCs"tjdddkr|jS|jSdS)Nrr)rr)sysversion_info__qualname____name__)xrC/usr/lib64/python3.6/typing.py	_qualnamegsrEcCs&d}|jdr"||kr"|dd}|S)N
_TypeAlias_ForwardRef_TypingBase_FinalTypingBase_)rFrGrHrI)
startswith)ZnmZ	whitelistrCrCrD
_trim_nameosrMcsJeZdZdZdZddfdd
ZddZdd	Zd
dZdd
Z	Z
S)
TypingMetaaMetaclass 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 tddjtt|pdtj||||S)NzCannot subclass %sz, z())	TypeErrorjoinmap
_type_reprsuper__new__)clsnamebases	namespacerO)	__class__rCrDrUszTypingMeta.__new__cOsdS)NrC)selfargskwdsrCrCrD__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).
        rC)r[globalnslocalnsrCrCrD
_eval_typeszTypingMeta._eval_typecCsdS)NrC)r[tvarsrCrCrD_get_type_varsszTypingMeta._get_type_varscCstt|}d|j|fS)Nz%s.%s)rMrE
__module__)r[qnamerCrCrD__repr__szTypingMeta.__repr__)rArdr@__doc___is_protocolrUr^rarcrf
__classcell__rCrC)rZrDrNvs
rNcsLeZdZdZdZddZfddZddZd	d
ZddZ	d
dZ
ZS)rHz0Internal indicator of special typing constructs.__weakref__cOsdS)NrC)r[r\r]rCrCrDr^sz_TypingBase.__init__cs@t|dkr4t|dtr4t|dtr4td|tj|S)zConstructor.

        This only exists to give a better error message in case
        someone tries to subclass a special typing object (not a good idea).
        rrrKzCannot subclass %r)len
isinstancestrtuplerPrTrU)rVr\r])rZrCrDrUs
z_TypingBase.__new__cCs|S)NrC)r[r_r`rCrCrDrasz_TypingBase._eval_typecCsdS)NrC)r[rbrCrCrDrcsz_TypingBase._get_type_varscCs"t|}tt|}d|j|fS)Nz%s.%s)typerMrErd)r[rVrerCrCrDrfsz_TypingBase.__repr__cOstdt|dS)NzCannot instantiate %r)rPro)r[r\r]rCrCrD__call__sz_TypingBase.__call__)rj)rArdr@rg	__slots__r^rUrarcrfrprirCrC)rZrDrHsrHT)	metaclassrOcs2eZdZdZfZddfdd
ZddZZS)rIzInternal 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.
    F)rOcs0tj|f||}|dkr |Std|dS)NTzCannot instantiate %r)rTrUrP)rVrOr\r]r[)rZrCrDrUsz_FinalTypingBase.__new__cCstt|jS)N)rMrorA)r[rCrCrD
__reduce__sz_FinalTypingBase.__reduce__)rArdr@rgrqrUrsrirCrC)rZrDrIsrI)rOcsTeZdZdZdZfddZdd	Zd
dZdd
ZddZ	ddZ
ddZZS)rGz-Internal wrapper to hold a forward reference.__forward_arg____forward_code____forward_evaluated____forward_value__csttj|t|ts$td|fyt|dd}Wn"tk
rVtd|fYnX||_||_d|_	d|_
dS)Nz,Forward reference must be a string -- got %rz<string>evalz1Forward reference must be an expression -- got %rF)rTr^rlrmrPcompileSyntaxErrorrtrurvrw)r[argcode)rZrCrDr^s
z_ForwardRef.__init__cCsf|js||k	r`|dkr*|dkr*i}}n|dkr8|}n|dkrD|}tt|j||d|_d|_|jS)Nz*Forward references must evaluate to types.T)rv_type_checkrxrurw)r[r_r`rCrCrDras
z_ForwardRef._eval_typecCs&t|tstS|j|jko$|j|jkS)N)rlrGNotImplementedrtrw)r[otherrCrCrD__eq__s
z_ForwardRef.__eq__cCst|j|jfS)N)hashrtrw)r[rCrCrD__hash__sz_ForwardRef.__hash__cCstddS)Nz4Forward references cannot be used with isinstance().)rP)r[objrCrCrD__instancecheck__sz_ForwardRef.__instancecheck__cCstddS)Nz4Forward references cannot be used with issubclass().)rP)r[rVrCrCrD__subclasscheck__sz_ForwardRef.__subclasscheck__cCsd|jfS)Nz_ForwardRef(%r))rt)r[rCrCrDrf	sz_ForwardRef.__repr__)rtrurvrw)
rArdr@rgrqr^rarrrrrfrirCrC)rZrDrGsrGc@sLeZdZdZdZddZdd	Zd
dZdd
ZddZ	ddZ
ddZdS)rFa: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``.
    rWtype_var	impl_typetype_checkercCszt|tstt|t|ts,tt|t|tsDtt|t|ttfs^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)rlrmAssertionErrorreprrorNrHrWrrr)r[rWrrrrCrCrDr^sz_TypeAlias.__init__cCsd|jt|jfS)Nz%s[%s])rWrSr)r[rCrCrDrf,sz_TypeAlias.__repr__cCst|jtstd||jjrJt|trJt||jjsJtd||jft|trj||jk	rjtd||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.)rlrrrP__constraints__ro
issubclassrZrWrr)r[Z	parameterrCrCrD__getitem__/s
z_TypeAlias.__getitem__cCs&t|tstS|j|jko$|j|jkS)N)rlrFr~rWr)r[rrCrCrDr;s
z_TypeAlias.__eq__cCst|j|jfS)N)rrWr)r[rCrCrDr@sz_TypeAlias.__hash__cCs t|jtstdt||jS)Nz<Parameterized type aliases cannot be used with isinstance().)rlrrrPr)r[rrCrCrDrCsz_TypeAlias.__instancecheck__cCs t|jtstdt||jS)Nz<Parameterized type aliases cannot be used with issubclass().)rlrrrPrr)r[rVrCrCrDrIsz_TypeAlias.__subclasscheck__N)rWrrr)rArdr@rgrqr^rfrrrrrrCrCrCrDrF
srFcCs0x*|D]"}t|tst|tr|j|qWdS)N)rlrNrHrc)typesrbtrCrCrDrcPs
rccCsg}t||t|S)N)rcrn)rrbrCrCrD
_type_varsVs
rcCs$t|tst|tr |j||S|S)N)rlrNrHra)rr_r`rCrCrDra\sracCs|dkrtdSt|tr"t|}t|tr:t|jdksTt|ttfrft|rft|d|ft|jdkrt|ddst|t	r|j
ttfkrtd||S)	aCheck 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)rr)
rorlrmrGrHrAcallablerPgetattrrN_gorgr
	_Protocol)r{msgrCrCrDr}bs
r}cCs`t|tr:t|tr:|jdkr(t|Sd|jt|fS|dkrFdSt|tjrX|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...)	rlrorNrdrErFunctionTyperAr)rrCrCrDrSs
rSc@s$eZdZdZfZddZddZdS)_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.
    cCstddS)Nz%Any cannot be used with isinstance().)rP)r[rrCrCrDrsz_Any.__instancecheck__cCstddS)Nz%Any cannot be used with issubclass().)rP)r[rVrCrCrDrsz_Any.__subclasscheck__N)rArdr@rgrqrrrCrCrCrDrs
rc@s$eZdZdZfZddZddZdS)	_NoReturnaSpecial 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.
    cCstddS)Nz*NoReturn cannot be used with isinstance().)rP)r[rrCrCrDrsz_NoReturn.__instancecheck__cCstddS)Nz*NoReturn cannot be used with issubclass().)rP)r[rVrCrCrDrsz_NoReturn.__subclasscheck__N)rArdr@rgrqrrrCrCrCrDrsrcsNeZdZdZdZdddd	fd
d
Zdd
ZddZddZddZ	Z
S)raType 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)
    rA	__bound__r
__covariant____contravariant__NF)bound	covariant
contravariantcstj|f||||d||_|r2|r2tdt||_t||_|rZ|dk	rZtd|rrt|dkrrtddt	fdd|D|_
|rt|d	|_nd|_dS)
N)rrrz"Bivariant types are not supported.z-Constraints cannot be combined with bound=...rKz"A single constraint is not allowedz:TypeVar(name, constraint, ...): constraints must be types.c3s|]}t|VqdS)N)r}).0r)rrCrD	<genexpr>sz#TypeVar.__init__.<locals>.<genexpr>zBound must be a type.)
rTr^rA
ValueErrorboolrrrPrkrnrr}r)r[rWrrrZconstraints)rZ)rrDr^s 

zTypeVar.__init__cCs||kr|j|dS)N)append)r[rbrCrCrDrcszTypeVar._get_type_varscCs&|jrd}n|jrd}nd}||jS)N+-~)rrrA)r[prefixrCrCrDrf
szTypeVar.__repr__cCstddS)Nz0Type variables cannot be used with isinstance().)rP)r[instancerCrCrDrszTypeVar.__instancecheck__cCstddS)Nz0Type variables cannot be used with issubclass().)rP)r[rVrCrCrDrszTypeVar.__subclasscheck__)rArrrr)rArdr@rgrqr^rcrfrrrirCrC)rZrDrs(	TKTVTT_co)rV_coVT_coT_contra)rcCsd|dkrg}t|dr0t|ttfr0|j||St|tr`x$t|D]\}}||krD||SqDW|S)zAn 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)hasattrrlrrHrr	enumerate)r{rbr\iZtvarrCrCrD_replace_arg)s
rc	Cs|jdkr|S|j}g}x|jdk	r6|j||j}qWg}x |jD]}|jt|||qDWx8|D]0}g}x"|jD]}|jt||j|qtW|}qdW|S)aAn 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)rr__args__r__parameters__)	rVrbr\ZcurrentZ
orig_chain	tree_argsr{ZoclsZ
new_tree_argsrCrCrDrDs 



rcs*g}xn|D]f}t|tr0|jtkr0|j|jq
t|trft|dkrf|dtkrf|j|ddq
|j|q
Wt	|tt|krg}x(|D] }|kr|j|j
|qW|}stt	|x>|D]6ttsqt
fddhDrڈj
qWtfdd|DS)zAn internal helper for Union creation and substitution: flatten Union's
    among parameters, then remove duplicates and strict subclasses.
    rrKNc3s6|].}t|to|jdk	st|to,t|VqdS)N)rlrrror)rZt2)t1rCrDrs
z'_remove_dups_flatten.<locals>.<genexpr>c3s|]}|kr|VqdS)NrC)rr)
all_paramsrCrDrs)rlrrrextendrrnrkrsetremoverroany)
parametersparamspZ
new_paramsrrC)rrrD_remove_dups_flattenes0
"



rcCsX|jstdt|t|}t|j}||krTtd||kr@dndt|||fdS)Nz%s is not a generic classz0Too %s parameters for %s; actual %s, expected %sZmanyZfew)rrPrrk)rVrZalenZelenrCrCrD_check_generics
rcs4tjtjjtjfdd}|S)zInternal wrapper caching __getitem__ of generic types with a fallback to
    original function for non-hashable arguments.
    cs*y
||Stk
rYnX||S)N)rP)r\r])cachedfuncrCrDinners

z_tp_cache.<locals>.inner)	functools	lru_cache	_cleanupsrcache_clearwraps)rrrC)rrrD	_tp_cachesrcseZdZdZdZd ddfd	d
ZddZd
dZfddZfddZ	e
ddZd!ddZddZ
ddZddZddZZS)"raUnion 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].
    rrr
__tree_hash__NF)rOcstj|||f|d|i}|dkrHd|_d|_d|_ttd|_|St|t	sZt
d|tkr~t|}t
|dkr~|dSt||_||_||_|j}t|t	rtt||_n
t||_|S)NrOrzExpected parameters=<tuple>rKr)r)rTrUrrrr	frozensetrrlrnrPrrrkrr)rVroriginrOr\r[Z	subs_tree)rZrCrDrUs*



z_Union.__new__cs^|jdkr|Stfdd|jD}t|j}||jkrN||jkrN|S|j||ddS)Nc3s|]}t|VqdS)N)ra)rr)r_r`rCrDrsz$_Union._eval_type.<locals>.<genexpr>T)rO)rrnrarrZ)r[r_r`ev_args	ev_originrC)r_r`rDras
z_Union._eval_typecCs|jr|jrt|j|dS)N)rrrc)r[rbrCrCrDrcsz_Union._get_type_varscs<|jdkrtjS|j}t|ts.t|S|dj|S)Nr)rrTrfrrlrnr
_tree_repr)r[tree)rZrCrDrfs


z_Union.__repr__cs`g}xB|ddD]2}t|ts0|jt|q|j|dj|qWtjddj|S)NrKrz[%s]z, )rlrnrrSrrTrfrQ)r[rarg_listr{)rZrCrDr
s
z_Union._tree_reprcsl|fkrtdt|ts |f}|jdkr0dndtfdd|D}|tk	r\t|||j||ddS)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)r})rr)rrCrDr sz%_Union.__getitem__.<locals>.<genexpr>T)rrO)rPrlrnrrrrZ)r[rrC)rrDrs


z_Union.__getitem__cCs>|tkrtSt|||}t|}t|dkr4|dStf|S)NrKr)rrrrk)r[rbr\rrCrCrDr%sz_Union._subs_treecCs6t|tr|j|jkS|tk	r*|j|kS||kSdS)N)rlrrrr)r[rrCrCrDr.s

z
_Union.__eq__cCs|jS)N)r)r[rCrCrDr6sz_Union.__hash__cCstddS)Nz(Unions cannot be used with isinstance().)rP)r[rrCrCrDr9sz_Union.__instancecheck__cCstddS)Nz(Unions cannot be used with issubclass().)rP)r[rVrCrCrDr<sz_Union.__subclasscheck__)rrrr)NN)NN)rArdr@rgrqrUrarcrfrrrrrrrrrirCrC)rZrDrs*
	
	rc@s eZdZdZfZeddZdS)rzEOptional type.

    Optional[X] is equivalent to Union[X, None].
    cCst|d}t|tdfS)Nz#Optional[t] requires a single type.)r}rro)r[r{rCrCrDrKs
z_Optional.__getitem__N)rArdr@rgrqrrrCrCrCrDrCsrcCsJt}x@t|jddD]*\}}t|tr|jtkr|j|d}qW|S)zHelper for Generic.__new__.

    Returns the class after the last occurrence of Generic or
    Generic[...] in cls.__mro__.
    NrK)objectr__mro__rlrrr
)rVZnext_in_mrorcrCrCrD_next_in_mroTs
rcs,tjtjrfdd}nfdd}|S)zConstruct a __subclasshook__ callable that incorporates
    the associated __extra__ class in subclass checks performed
    against cls.
    csZjj|}|tk	r|Sj|jkr(dSx,jjD]}t|trDq4t||r4dSq4WtS)NT)	__extra____subclasshook__r~r__subclasses__rlrr)subclassresscls)rVrCrD
__extrahook__ks

z)_make_subclasshook.<locals>.__extrahook__csjrt|jrdStS)NT)rrr~)r)rVrCrDrys)rlrabcABCMeta)rVrrC)rVrD_make_subclasshookbsrcCs2t|}d|kr.x|dD]}|j|dqW|S)zInternal helper: copy class __dict__ and clean slots class variables.
    (They will be re-created if necessary by normal class machinery.)
    rqN)dictpop)ZdctZ	dict_copyZslotrCrCrD_no_slots_copys
rcseZdZdZd!fdd	ZeddZejddZedd	Zejd
d	ZddZ	d
dZ
fddZfddZd"ddZ
ddZddZeddZfddZddZfdd ZZS)#racMetaclass for generic types.

    This is a metaclass for typing.Generic and generic ABCs defined in
    typing module. User defined subclasses of GenericMeta can override
    __new__ and invoke super().__new__. Note that GenericMeta.__new__
    has strict rules on what is allowed in its bases argument:
    * plain Generic is disallowed in bases;
    * Generic[...] should appear in bases at most once;
    * if Generic[...] is present, then it should list all type variables
      that appear in other bases.
    In addition, type of all generic bases is erased, e.g., C[int] is
    stripped to plain C.
    Nc	s|dk	r0|dk	sttdd|Ds.t|n|dks@t||dksPt||dks`t|t|}d}	xF|D]>}
|
tkrtdt|
trr|
jtkrr|	dk	rtd|
j}	qrW|	dkr|}	nRt	|}t	|	|kstddj
fdd|Ddj
d	d|	Df|	}|}|dk	rFt|tj
krF||krF|f|}td
d|D}tdd|Dr~tdd|D}|j|||sdn|jd
tj||||dd}
tt|
jd|s|
n|j||
_|rtdd|Dnd|
_t|
|
_|dkr||
_d|kr|s2t|
jdddkr<t|
|
_t|tj
r\|j|
_|j|
_n|dk	rv|j|
_|j|
_|rt|dr|j|
_|rt |
j!ntt|
j"|
_#|
S)zCreate a new generic class. GenericMeta.__new__ accepts
        keyword arguments that are used for internal bookkeeping, therefore
        an override should pass unused keyword arguments to super().
        Ncss|]}t|tVqdS)N)rlr)rrrCrCrDrsz&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)rm)rr)gvarsetrCrDrscss|]}t|VqdS)N)rm)rgrCrCrDrscss"|]}t|tr|jn|VqdS)N)rlrr)rbrCrCrDrscss |]}t|to|tk	VqdS)N)rlrr
)rrrCrCrDrscss|]}|tk	r|VqdS)N)r
)rrrCrCrDrs)rrrT)rOrcss*|]"}|tkrdn|tkrfn|VqdS).N)_TypingEllipsis_TypingEmpty)rarCrCrDrsrrArr@)$rallrr
rPrlrrrrrQrorrrnrupdaterrTrU__setattr__rr__next_in_mro____orig_bases__rrr
_abc_registry
_abc_cacherr@rrrr)rVrWrXrYrbr\rextra
orig_basesZgvarsbaseZtvarsetZ
initial_basesr[)rZ)rrDrUsr




$





zGenericMeta.__new__cCst|jtjr|jjS|jjS)N)rlrrr_abc_negative_cacher_abc_generic_negative_cache)r[rCrCrDrszGenericMeta._abc_negative_cachecCs,|jdkr(t|jtjr"||j_n||_dS)N)rrlrrrrr)r[valuerCrCrDrs

cCst|jtjr|jjS|jjS)N)rlrrr_abc_negative_cache_versionr#_abc_generic_negative_cache_version)r[rCrCrDr	sz'GenericMeta._abc_negative_cache_versioncCs,|jdkr(t|jtjr"||j_n||_dS)N)rrlrrrrr)r[rrCrCrDrs

cCs|jr|jrt|j|dS)N)rrrc)r[rbrCrCrDrcszGenericMeta._get_type_varsc
s|jr|jjnd}|jr8tfdd|jDnd}||jkrT||jkrT|S|j|j|jt|j|rtt	|nd|||j
|jdS)Nc3s|]}t|VqdS)N)ra)rr)r_r`rCrDrsz)GenericMeta._eval_type.<locals>.<genexpr>)rbr\rrr)rrarrnrZrA	__bases__r__dict__rrr)r[r_r`rrrC)r_r`rDras$zGenericMeta._eval_typecs"|jdkrtjS|j|jS)N)rrTrfrr)r[)rZrCrDrf+s

zGenericMeta.__repr__cstg}xV|ddD]F}|fkr*|jdqt|tsD|jt|q|j|dj|qWtjddj|S)NrKz()rz[%s]z, )rrlrnrSrrTrfrQ)r[rrr{)rZrCrDr0s
zGenericMeta._tree_reprcCs*|jdkr|St|||}|jft|S)N)rrrrn)r[rbr\rrCrCrDr;s
zGenericMeta._subs_treecCs6t|tstS|jdks"|jdkr*||kS|j|jkS)N)rlrr~rr)r[rrCrCrDrAs

zGenericMeta.__eq__cCs|jS)N)r)r[rCrCrDrHszGenericMeta.__hash__c
s6t|ts|f}|r0|jtk	r0tdt|dtfdd|D}|tkrtdd|Dsltdtt	|t|krtd|}|}nb|tt
fkrt|}|}nH|tkr|}|}n6|j
ttfkrtdt|nt||t|}|}|j
dkr|fnf}|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})rr)rrCrDrSsz*GenericMeta.__getitem__.<locals>.<genexpr>css|]}t|tVqdS)N)rlr)rrrCrCrDrVsz5Parameters to Generic[...] must all be type variablesz-Parameters to Generic[...] must all be uniquez'Cannot subscript already-subscripted %s)rbr\rrr)rlrnrrrPrEr
rrkrrrrrrrrZrArrrrr)r[rrbr\ZprependrC)rrDrKsJ

zGenericMeta.__getitem__csJ|jdk	r*tjdjddkr&tddS|tkr>td|tj|S)	NrKrArrzCParameterized generics cannot be used with class or instance checksFz5Class %r cannot be used with class or instance checks)rr)rr>	_getframe	f_globalsrPr
rTr)r[rV)rZrCrDrys
zGenericMeta.__subclasscheck__cCst|j|S)N)rrZ)r[rrCrCrDrszGenericMeta.__instancecheck__csT|jdr|jds(|jds(|jdkr<tt|j||ntt|jj||dS)N___abc_)rLendswithrrTrr)r[attrr)rZrCrDrs


zGenericMeta.__setattr__)NNNNN)NN)rArdr@rgrUpropertyrsetterrrcrarfrrrrrrrrrrirCrC)rZrDrs"
`
.cOs|jdkr@|jtjkr,|jtjk	r,|j|S|j|f||Snl|j}|jtjkrj|jtjk	rj|j|}n|j|f||}y
||_Wntk
rYnX|j|||SdS)N)rrUrr^rZ__orig_class__AttributeError)Zbase_clsrVr\r]rrrCrCrD_generic_news 


rc@seZdZdZfZddZdS)r
aCAbstract 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
    cOs&|jtkrtdt|j|f||S)NzHType Generic cannot be instantiated; it can be used only as a base class)rr
rPrr)rVr\r]rCrCrDrUs
zGeneric.__new__N)rArdr@rgrqrUrCrCrCrDr
s)rrc@seZdZdZdS)rzInternal 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)rArdr@rgrCrCrCrDrsrc@seZdZdZdS)rz(Internal placeholder for ... (ellipsis).N)rArdr@rgrCrCrCrDrsrcs4eZdZdZefddZddZddZZS)	TupleMetazMetaclass for Tuple (internal).cs|jdk	s|jtk	r tj|S|fkr6tjtfSt|tsF|f}t|dkr|ddkrdt	|d}tj|t
fSdtfdd|D}tj|S)	NrrK.z Tuple[t, ...]: t must be a type.rz*Tuple[t0, t1, ...]: each t must be a type.c3s|]}t|VqdS)N)r})rr)rrCrDrsz(TupleMeta.__getitem__.<locals>.<genexpr>)rrrrTrrrlrnrkr}r)r[rr)rZ)rrDrs
zTupleMeta.__getitem__cCs |jdkrt|tStddS)Nz5Parameterized Tuple cannot be used with isinstance().)rrlrnrP)r[rrCrCrDrs

zTupleMeta.__instancecheck__cCs |jdkrt|tStddS)Nz5Parameterized Tuple cannot be used with issubclass().)rrrnrP)r[rVrCrCrDrs

zTupleMeta.__subclasscheck__)	rArdr@rgrrrrrirCrC)rZrDr
sr
c@seZdZdZfZddZdS)ra@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$|jtkrtdtt|f||S)Nz6Type Tuple cannot be instantiated; use tuple() instead)rrrPrrn)rVr\r]rCrCrDrUs
z
Tuple.__new__N)rArdr@rgrqrUrCrCrCrDrs)rrrcsHeZdZdZfddZfddZfddZefdd	ZZ	S)
CallableMetaz"Metaclass for Callable (internal).cs"|jdkrtjS|j|jS)N)rrTrfrr)r[)rZrCrDrfs

zCallableMeta.__repr__cs|jtk	rtj|Sg}xB|ddD]2}t|tsF|jt|q(|j|dj|q(W|ddkrt|dd|dSt|dddj	|dd|dfS)	NrKrz...z	[..., %s]z
[[%s], %s]z, rr)
rrrTrrlrnrrSrrQ)r[rrr{)rZrCrDrs


zCallableMeta._tree_reprcs|jdk	s|jtk	r tj|St|ts8t|dkr@td|\}}|t	krZt	|f}n$t|t
srtd|ft||f}|j|S)zxA thin wrapper around __getitem_inner__ to provide the latter
        with hashable arguments to improve speed.
        Nrz6Callable must be used as Callable[[arg, ...], result].z8Callable[args, result]: args must be a list. Got %.100r.)rrrrTrrlrnrkrPEllipsislist__getitem_inner__)r[rr\result)rZrCrDr*s


zCallableMeta.__getitem__cs^|\}}dt|}|tkr.tjt|fSdtfdd|D}||f}tj|S)Nz.Callable[args, result]: result must be a type.z6Callable[[arg, ...], result]: each arg must be a type.c3s|]}t|VqdS)N)r})rr{)rrCrDrFsz1CallableMeta.__getitem_inner__.<locals>.<genexpr>)r}rrTrrrn)r[rr\r)rZ)rrDr>s

zCallableMeta.__getitem_inner__)
rArdr@rgrfrrrrrirCrC)rZrDrs
rc@seZdZdZfZddZdS)raCallable 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.
    cOs&|jtkrtdt|j|f||S)NzIType Callable cannot be instantiated; use a non-abstract subclass instead)rrrPrr)rVr\r]rCrCrDrUXs
zCallable.__new__N)rArdr@rgrqrUrCrCrCrDrKs	csNeZdZdZdZdddZddZdd	Zfd
dZdd
Z	ddZ
ZS)ra3Special 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)r[tpr]rCrCrDr^rsz_ClassVar.__init__cCsPt|}|jdkr4|t|dj|jddddStdj|jdddS)Nz{} accepts only single type.rKT)rOz {} cannot be further subscripted)rorr}formatrArP)r[itemrVrCrCrDrus
z_ClassVar.__getitem__cCs,t|j||}||jkr|St||ddS)NT)rO)rarro)r[r_r`Znew_tprCrCrDra~s
z_ClassVar._eval_typecs,tj}|jdk	r(|djt|j7}|S)Nz[{}])rTrfrrrS)r[r)rZrCrDrfs

z_ClassVar.__repr__cCstt|j|jfS)N)rrorAr)r[rCrCrDrsz_ClassVar.__hash__cCs,t|tstS|jdk	r$|j|jkS||kS)N)rlrr~r)r[rrCrCrDrs


z_ClassVar.__eq__)r)N)rArdr@rgrqr^rrarfrrrirCrC)rZrDr_s
	rcCs|S)zCast 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).
    rC)typvalrCrCrDr6sc
Csy
|j}Wntk
riSX|j}|j}|d|}|jp@f}|j}|rTt|ni}|t|}x2t||d|D]\}}	||kst	|	||<qxW|S)z:Internal helper to extract the default arguments, by name.N)
__code__rco_argcountco_varnames__defaults____kwdefaults__rrkzipr)
rr|Z	pos_countZ	arg_namesdefaultsZ
kwdefaultsrZ
pos_offsetrWrrCrCrD
_get_defaultss

r!c
Cst|ddriSt|tri}xt|jD]z}|dkrFtj|jj}n|}|jj	di}xJ|j
D]>\}}|dkrztd}t|trt|}t
|||}|||<qbWq*W|S|dkrt|tjr|j}nt|di}|dkr|}n|dkr|}t|dd}|dkr"t|triStdj|t|}	t|}xp|j
D]d\}}|dkrVtd}t|trjt|}t
|||}||	kr|	|dkrt|}|||<q<W|S)aReturn 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 (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.
    __no_type_check__N__annotations____globals__z1{!r} is not a module, class, method, or function.)rrlroreversedrr>modulesrdrgetitemsrmrGrar
ModuleType_allowed_typesrPrr!rr)
rr_r`ZhintsrZbase_globalsZannrWrr rCrCrDr7sV



cCst|tr||jj}x0|jjD]"\}}||j|fkr |j|q Wx4|jD](}t|tj	rfd|_
t|trPt|qPWy
d|_
Wntk
rYnX|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)
rlrorcopyr(rrvaluesrrr"r9rP)r{Z	arg_attrsrrrrCrCrDr9s	



cstjfdd}|S)zDecorator 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)r9)r\r]r)	decoratorrCrDwrapped_decorator/s
z2no_type_check_decorator.<locals>.wrapped_decorator)rr)r-r.rC)r-rDr:(scOstddS)z*Helper for @overload to raise when called.zYou 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\r]rCrCrD_overload_dummy8sr0cCstS)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
    )r0)rrCrCrDr;Ascs0eZdZdZfddZddZddZZS)
_ProtocolMetaz~Internal metaclass for _Protocol.

    This exists so _Protocol classes can be generic without deriving
    from Generic.
    cs"t|jkrtj|StddS)Nz+Protocols cannot be used with isinstance().)rrrTrrP)r[r)rZrCrDres
z_ProtocolMeta.__instancecheck__csL|js
tS|tkrdS|j}x(|D] tfdd|jDs$dSq$WdS)NTc3s|]}|jkVqdS)N)r)rd)rrCrDrwsz2_ProtocolMeta.__subclasscheck__.<locals>.<genexpr>F)rhr~r_get_protocol_attrsrr)r[rVattrsrC)rrDrjs
z_ProtocolMeta.__subclasscheck__cCs,g}x.|jD]$}t|ddr|jdkr|j|qWt}x|D]}x|jjD]}x|jD]&}||k	r`||jkr`t|ddr`Pq`W|jdrT|dkrT|dkrT|dkrT|dkrT|dkrT|d	krT|d
krT|dkrT|dkrT|d
krT|dkrT|dkrT|dkrT|dkrT|dkrT|dkrT|j|qTWqBW|S)NrhFrr__abstractmethods__r#rjrrrrqr3rrrrrrrd)	rrrArrrkeysrLadd)r[Zprotocol_basesrr4rrrCrCrDr3{s<z!_ProtocolMeta._get_protocol_attrs)rArdr@rgrrr3rirCrC)rZrDr1^sr1c@seZdZdZfZdZdS)rzInternal 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)rArdr@rgrqrhrCrCrCrDrsr	Awaitablec@seZdZfZdS)r8N)rArdr@rqrCrCrCrDr8s)r	Coroutinec@seZdZfZdS)r9N)rArdr@rqrCrCrCrDr9s
AsyncIterablec@seZdZfZdS)r:N)rArdr@rqrCrCrCrDr:sc@seZdZfZdS)
AsyncIteratorN)rArdr@rqrCrCrCrDr;sr;c@seZdZfZdS)rN)rArdr@rqrCrCrCrDrsc@seZdZfZdS)rN)rArdr@rqrCrCrCrDrsc@s"eZdZfZeedddZdS)r*)returncCsdS)NrC)r[rCrCrD__int__szSupportsInt.__int__N)rArdr@rqrintr=rCrCrCrDr*sc@s"eZdZfZeedddZdS)r))r<cCsdS)NrC)r[rCrCrD	__float__szSupportsFloat.__float__N)rArdr@rqrfloatr?rCrCrCrDr)sc@s"eZdZfZeedddZdS)r()r<cCsdS)NrC)r[rCrCrD__complex__szSupportsComplex.__complex__N)rArdr@rqrcomplexrArCrCrCrDr(sc@s"eZdZfZeedddZdS)r')r<cCsdS)NrC)r[rCrCrD	__bytes__szSupportsBytes.__bytes__N)rArdr@rqrbytesrCrCrCrCrDr'sc@s"eZdZfZeedddZdS)r&)r<cCsdS)NrC)r[rCrCrD__abs__szSupportsAbs.__abs__N)rArdr@rqrrrErCrCrCrDr&sc@s&eZdZfZedeedddZdS)r+r)ndigitsr<cCsdS)NrC)r[rFrCrCrD	__round__szSupportsRound.__round__N)r)rArdr@rqrr>rrGrCrCrCrDr+sc@seZdZfZdS)r%N)rArdr@rqrCrCrCrDr%
sc@s"eZdZfZeddddZdS)r%zIterator[T_co])r<cCsdS)NrC)r[rCrCrD__reversed__szReversible.__reversed__N)rArdr@rqrrHrCrCrCrDr%
sc@seZdZfZdS)rN)rArdr@rqrCrCrCrDrs
Collectionc@seZdZfZdS)rIN)rArdr@rqrCrCrCrDrIsc@seZdZfZdS)rN)rArdr@rqrCrCrCrDr'sc@seZdZfZdS)rN)rArdr@rqrCrCrCrDr+sc@seZdZfZdS)r!N)rArdr@rqrCrCrCrDr!0sc@seZdZfZdS)rN)rArdr@rqrCrCrCrDr6sc@seZdZfZdS)rN)rArdr@rqrCrCrCrDr:sc@seZdZfZdS)rN)rArdr@rqrCrCrCrDr?sc@seZdZfZdS)r"N)rArdr@rqrCrCrCrDr"Esc@seZdZfZdS)r"N)rArdr@rqrCrCrCrDr"Isc@seZdZfZdS)r"N)rArdr@rqrCrCrCrDr"Msc@seZdZfZdS)r N)rArdr@rqrCrCrCrDr Rsc@seZdZfZdS)rN)rArdr@rqrCrCrCrDrVsc@seZdZfZddZdS)r0cOs$|jtkrtdtt|f||S)Nz4Type List cannot be instantiated; use list() instead)rr0rPrr)rVr\r]rCrCrDrU^s
zList.__new__N)rArdr@rqrUrCrCrCrDr0Zsc@seZdZfZddZdS)r-cOs*|jtkrtj||Sttj|f||S)N)rr-collectionsdequer)rVr\r]rCrCrDrUis
z
Deque.__new__N)rArdr@rqrUrCrCrCrDr-esc@seZdZfZddZdS)r1cOs$|jtkrtdtt|f||S)Nz2Type Set cannot be instantiated; use set() instead)rr1rPrr)rVr\r]rCrCrDrUss
zSet.__new__N)rArdr@rqrUrCrCrCrDr1osc@seZdZfZddZdS)r2cOs$|jtkrtdtt|f||S)Nz>Type FrozenSet cannot be instantiated; use frozenset() instead)rr2rPrr)rVr\r]rCrCrDrU}s
zFrozenSet.__new__N)rArdr@rqrUrCrCrCrDr2zsc@seZdZfZdS)rN)rArdr@rqrCrCrCrDrsc@seZdZfZdS)rN)rArdr@rqrCrCrCrDrsc@seZdZfZdS)rN)rArdr@rqrCrCrCrDrsc@seZdZfZdS)r$N)rArdr@rqrCrCrCrDr$sAbstractContextManagerc@seZdZfZdS)rN)rArdr@rqrCrCrCrDrsc@s2eZdZfZddZejddZeddZ	dS)rcCs|S)NrC)r[rCrCrD	__enter__szContextManager.__enter__cCsdS)NrC)r[exc_type	exc_value	tracebackrCrCrD__exit__szContextManager.__exit__cCs8|tkr4tdd|jDr4tdd|jDr4dStS)Ncss|]}d|jkVqdS)rMN)r)rBrCrCrDrsz2ContextManager.__subclasshook__.<locals>.<genexpr>css|]}d|jkVqdS)rQN)r)rrRrCrCrDrsT)rrrr~)rVCrCrCrDrs
zContextManager.__subclasshook__N)
rArdr@rqrMrrrQclassmethodrrCrCrCrDrsAbstractAsyncContextManagerc@seZdZfZdS)AsyncContextManagerN)rArdr@rqrCrCrCrDrVsrVa
class AsyncContextManager(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:
            if sys.version_info[:2] >= (3, 6):
                return _collections_abc._check_methods(C, "__aenter__", "__aexit__")
            if (any("__aenter__" in B.__dict__ for B in C.__mro__) and
                    any("__aexit__" in B.__dict__ for B in C.__mro__)):
                return True
        return NotImplemented

__all__.append('AsyncContextManager')
c@seZdZfZddZdS)r.cOs$|jtkrtdtt|f||S)Nz4Type Dict cannot be instantiated; use dict() instead)rr.rPrr)rVr\r]rCrCrDrUs
zDict.__new__N)rArdr@rqrUrCrCrCrDr.sc@seZdZfZddZdS)r/cOs*|jtkrtj||Sttj|f||S)N)rr/rJdefaultdictr)rVr\r]rCrCrDrUs
zDefaultDict.__new__N)rArdr@rqrUrCrCrCrDr/sc@seZdZfZddZdS)r,cOs*|jtkrtj||Sttj|f||S)N)rr,rJr)rVr\r]rCrCrDrUs
zCounter.__new__N)rArdr@rqrUrCrCrCrDr,sChainMapc@seZdZfZddZdS)rYcOs*|jtkrtj||Sttj|f||S)N)rrYrJr)rVr\r]rCrCrDrUs
zChainMap.__new__N)rArdr@rqrUrCrCrCrDrYsc@seZdZfZddZdS)r4cOs$|jtkrtdtt|f||S)Nz@Type Generator cannot be instantiated; create a subclass instead)rr4rPr_G_base)rVr\r]rCrCrDrUs
zGenerator.__new__N)rArdr@rqrUrCrCrCrDr4sAsyncGeneratorc@seZdZfZdS)r[N)rArdr@rqrCrCrCrDr[sCT_co)rrc@seZdZdZfZdS)raA 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)rArdr@rgrqrCrCrCrDr$scsvdfdd|D}tj|dd|D}tj||_|_ytjdjjdd|_	Wnt
tfk
rpYnX|S)NzDNamedTuple('Name', [(f0, t0), (f1, t1), ...]); each t must be a typecsg|]\}}|t|fqSrC)r})rnr)rrCrD
<listcomp>Asz!_make_nmtuple.<locals>.<listcomp>cSsg|]\}}|qSrCrC)rr]rrCrCrDr^BsrrA__main__)rJ
namedtupleOrderedDictr#_field_typesr>rrr'rdrr)rWrnm_tplrC)rrD
_make_nmtuple?srdrUr^rq__getnewargs___fields_field_defaultsrb_make_replace_asdict_sourcerdrAr@r#cseZdZfddZZS)NamedTupleMetacs|jddrtj||||Sts*td|jdi}t||j}g}i}xP|D]H}||krz||}	|j|	|	||<qR|rRtdj|dj	|j
dqRWtj||j_
t||j_||_xD|D]<}
|
tkrtd|
q|
tko|
|jkrt||
||
qW|S)	NrOFz<Class syntax for NamedTuple is only supported in Python 3.6+r#zXNon-default namedtuple field {field_name} cannot follow default field(s) {default_names}z, )
field_nameZ
default_namesz&Cannot overwrite NamedTuple attribute )r'rTrU_PY36rPrdr(rrrQr6rJrar#rnrrg_prohibitedr_specialrfsetattr)rVtypenamerXnsrrcr Z
defaults_dictrmZ
default_valuekey)rZrCrDrUYs4



zNamedTupleMeta.__new__)rArdr@rUrirCrC)rZrDrlWsrlc@seZdZdZdZdddZdS)r3a4Typed 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 extra __annotations__ and _field_types
    attributes, giving an ordered dict mapping field names to types.
    __annotations__ should be preferred, while _field_types
    is kept to maintain pre PEP 526 compatibility. (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)])
    TNcKs:|rtrtd|dkr$|j}n|r0tdt||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)rnrPr(rd)r[rrZfieldskwargsrCrCrDrUs

zNamedTuple.__new__)N)rArdr@rgrOrUrCrCrCrDr3yscCsdd}||_||_|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)NrC)rBrCrCrDnew_typeszNewType.<locals>.new_type)rAZ
__supertype__)rWrrvrCrCrDr8sFc@seZdZdZfZeedddZeedddZe	dddd	Z
e	edd
dZe	e
ddd
Ze	ddddZe	edddZe	d7e
edddZe	edddZe	d9e
edddZe	d;e
eedddZe	d<e
e
e
dd d!Ze	edd"d#Ze	e
dd$d%Ze	d=e
e
d&d'd(Ze	edd)d*Ze	ee
d+d,d-Ze	eedd.d/d0Ze	d1dd2d3Ze	ddd4d5ZdS)>IOaGeneric 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)NrC)r[rCrCrDmodeszIO.modecCsdS)NrC)r[rCrCrDrWszIO.nameNcCsdS)NrC)r[rCrCrDcloseszIO.closecCsdS)NrC)r[rCrCrDclosedsz	IO.closedcCsdS)NrC)r[rCrCrDfilenosz	IO.filenocCsdS)NrC)r[rCrCrDflushszIO.flushcCsdS)NrC)r[rCrCrDisattysz	IO.isattyrK)r]r<cCsdS)NrC)r[r]rCrCrDreadszIO.readcCsdS)NrC)r[rCrCrDreadableszIO.readable)limitr<cCsdS)NrC)r[rrCrCrDreadlineszIO.readline)hintr<cCsdS)NrC)r[rrCrCrD	readlinesszIO.readlinesr)offsetwhencer<cCsdS)NrC)r[rrrCrCrDseekszIO.seekcCsdS)NrC)r[rCrCrDseekable	szIO.seekablecCsdS)NrC)r[rCrCrDtell	szIO.tell)sizer<cCsdS)NrC)r[rrCrCrDtruncate	szIO.truncatecCsdS)NrC)r[rCrCrDwritable	szIO.writable)sr<cCsdS)NrC)r[rrCrCrDwrite	szIO.write)linesr<cCsdS)NrC)r[rrCrCrD
writelines	sz
IO.writelinesz
IO[AnyStr]cCsdS)NrC)r[rCrCrDrM	szIO.__enter__cCsdS)NrC)r[rorrPrCrCrDrQ	szIO.__exit__r)rr)rr)r)r)N) rArdr@rgrqrrmrxrWrryrrzr>r{r|r}r5r~rrr0rrrrrrrrrMrQrCrCrCrDrwsTrwc@sBeZdZdZfZeeeefe	dddZ
eddddZdS)	BinaryIOz5Typed version of the return of open() in binary mode.)rr<cCsdS)NrC)r[rrCrCrDr)	szBinaryIO.write)r<cCsdS)NrC)r[rCrCrDrM-	szBinaryIO.__enter__N)rArdr@rgrqrrrD	bytearrayr>rrMrCrCrCrDr$	src@seZdZdZfZeedddZeedddZ	ee
edddZeedd	d
Z
eedddZeddd
dZdS)TextIOz3Typed version of the return of open() in text mode.)r<cCsdS)NrC)r[rCrCrDbuffer7	sz
TextIO.buffercCsdS)NrC)r[rCrCrDencoding;	szTextIO.encodingcCsdS)NrC)r[rCrCrDerrors?	sz
TextIO.errorscCsdS)NrC)r[rCrCrDline_bufferingC	szTextIO.line_bufferingcCsdS)NrC)r[rCrCrDnewlinesG	szTextIO.newlinescCsdS)NrC)r[rCrCrDrMK	szTextIO.__enter__N)rArdr@rgrqrrrrmrrrrrr
rrrMrCrCrCrDr2	src@s&eZdZdZdddgZeZeZeZdS)ioz)Wrapper namespace for IO generic classes.rwrrN)rArdr@rg__all__rwrrrCrCrCrDrP	s

rz.ioPatternrcCs|jS)N)pattern)rrCrCrD<lambda>^	srMatchcCs|jjS)N)rer)mrCrCrDr`	sc@s eZdZdZddgZeZeZdS)rz&Wrapper namespace for re type aliases.rrN)rArdr@rgrrrrCrCrCrDrc	srz.re)rr)NN)NN)rrW)rr)rUr^rqrerfrgrbrhrirjrk)rdrAr@r#)rrrrJ
contextlibrrZ	stdlib_rer>rcollections.abcZcollections_abcImportErrorr?_collections_abcrrr	rorr^__str__rmrQrrErMrNrHrIrGrFrcrrar}rSrr
rZNoReturnrrrrrrrrrDr5rrrrrrrrrrrrrrrr
rrrr
rnrrrrrr6r!rBuiltinFunctionType
MethodTyper)r*r7r9r:r0r;r1rrrr8rr9r:r;rrr*r)r(r'r&r+r%r#rrIr1rr!rrr"r r>rrr0rKr-rrr2rrrr$rLrrUrVexecrr.rXr/r,rYr4rZ
GeneratorTyper[r\rrdrnrorprlr3r8r<r=rwrrrrAr&ryrmatchrrCrCrCrD<module>s
*%5C

W
!)

"96


R	D








"









"





"(`	





OHA YOOOO