HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority
Upload Files
File: //usr/lib/python3.7/__pycache__/typing.cpython-37.pyc
B

{aJ;@sdZddlZddlmZmZddlZddlZddlZddlZddlZddl	Z
ddlZddlZddlm
Z
mZmZddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?g;ZddAdBZdCdDZdEdFZdGdHZdIdJZdKdLZgZdMdNZdOdPZGdQdRdRZGdSdTdTZGdUdVdVeed@dWZeddXdYZed<dZdYZedd[dYZed
d\dYZ ed	d]dYZ!Gd^d_d_ed@dWZ"Gd`ddeed@dWZ#d1d
d/d2d3d.d0ddda	Z$dbdcZ%Gdddedeed@dWZ&Gdfdgdge&d@dWZ'GdhddZ(GdidjdjZ)GdkdldlZ*dmd7Z+dndoZ,ej-ej.ej/ej0e
eefZ1ddpd8Z2dqd:Z3drd;Z4dsdtZ5dud=Z6Gdvdwdwe7Z8Gdxdydye(e8dzZ9e#d{Z:e#d|Z;e#d}Z<e#d~d@dZ=e#dd@dZ>e#dd@dZ?e#dd@dZ@e#dd@e7dZAe#d6eBeCZDdddZEeEejjFdZFeEejjGe=ZGeEejjHe=e@e>fZHeEejjIe=ZIeEejjJe=ZJeEejjKe=ZKeEejjLe=ZLeEejjMe=ZMeEejjNdZNeEejjOe=ZOeEejjPe=ZPe'ejjQdd@dZQdeQ_eEejjRe=ZSeEejjTe:ZTeEejjUe;e?fZUeEejjVe;e<fZVeEejjWe=ZWeEejjXe:ZXeEejjYdZYe'eZddd@dZ[de[_eEe\e:ddZ]eEej^e:Z_eEe`e:ddZReEeae=ddZbeEejjce=ZceEejjde;ZdeEejjee;e?fZeeEejjfe?ZfeEejge=ZheEejie=ZjeEeke;e<fddZleEejme;e<fZneEejoe;e<fZoeEejpe:ZpeEejqe;e<fZqeEejjre=e@e>fZreEejjse=e@fZseEe7eAddZtdet_Gdd+d+e9ZuGdd*d*e9ZvGdd)d)e9ZwGdd(d(e9ZxGdd'd'e9e=ZyGdd,d,e9e=ZzddZ{dZ|dZ}Gddde7Z~Gdd4d4e~dzZdd9ZeCZdZGddde(eDZGdddeeBZGdddeeCZGdddZede_eejej<eEe
jeDZeEe
jeDZGdddZ	ede	_e	eje	j<dS)a
The typing module: Support for gradual typing as defined by PEP 484.

At large scale, the structure of the module is following:
* Imports and exports, all public names should be explicitly added to __all__.
* Internal helper functions: these should never be used in code outside this module.
* _SpecialForm and its instances (special forms): Any, NoReturn, ClassVar, Union, Optional
* Two classes whose instances can be type arguments in addition to types: ForwardRef and TypeVar
* The core of internal generics API: _GenericAlias and _VariadicGenericAlias, the latter is
  currently only used by Tuple and Callable. All subscripted types like X[int], Union[int, str],
  etc., are instances of either of these classes.
* The public counterpart of the generics API consists of two classes: Generic and Protocol
  (the latter is currently private, but will be made public after PEP 544 acceptance).
* Public helper functions: get_type_hints, overload, cast, no_type_check,
  no_type_check_decorator.
* Generic aliases for collections.abc ABCs and few additional protocols.
* Special types: NewType, NamedTuple, TypedDict (may be added soon).
* Wrapper submodules for re and io related types.
N)abstractmethodabstractproperty)WrapperDescriptorTypeMethodWrapperTypeMethodDescriptorTypeAnyCallableClassVarGenericOptionalTupleTypeTypeVarUnionAbstractSet
ByteString	ContainerContextManagerHashable	ItemsViewIterableIteratorKeysViewMappingMappingViewMutableMappingMutableSequence
MutableSetSequenceSized
ValuesView	Awaitable
AsyncIterator
AsyncIterable	Coroutine
CollectionAsyncGeneratorAsyncContextManager
ReversibleSupportsAbs
SupportsBytesSupportsComplex
SupportsFloatSupportsInt
SupportsRoundCounterDequeDictDefaultDictListSet	FrozenSet
NamedTuple	GeneratorAnyStrcastget_type_hintsNewType
no_type_checkno_type_check_decoratorNoReturnoverloadText
TYPE_CHECKINGTcCsttf}|r|tf}|dkr&tdSt|tr8t|St|trZ|j|krZt	|dt|t
rp|ttfks||ttfkrt	d|dt|tt
tfr|St|st	|d|dd|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 wrap strings
    into ForwardRef instances. Consider several corner cases, for example plain
    special forms like Union are not valid, while Union[int, str] is OK, etc.
    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).
    Nz is not valid as type argumentzPlain z Got z.100.)r
	_Protocolr	type
isinstancestr
ForwardRef
_GenericAlias
__origin__	TypeError_SpecialFormrr>rcallable)argmsgis_argumentZinvalid_generic_formsrP/usr/lib/python3.7/typing.py_type_checkns$



rRcCsRt|tr,|jdkr|jS|jd|jS|dkr8dSt|tjrJ|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).
    builtinsrB.z...)rErD
__module____qualname__typesFunctionType__name__repr)objrPrPrQ
_type_reprs

r[cs`gxR|D]J}t|tr*|kr*|t|tr
|js
fdd|jDq
WtS)zCollect all type variable contained in types in order of
    first appearance (lexicographic order). For example::

        _collect_type_vars((T, List[S, T])) == (T, S)
    csg|]}|kr|qSrPrP).0t)tvarsrPrQ
<listcomp>sz&_collect_type_vars.<locals>.<listcomp>)rErappendrH_specialextend__parameters__tuple)rVr]rP)r^rQ_collect_type_varss

recCst|ts|St|j}x\t|jD]N\}}t|trbx:t|D]\}}||kr@||||<q@Wq$t|||||<q$W|jtkrtt	|S|
t	|S)zjSubstitute type variables 'tvars' with substitutions 'subs'.
    These two must have the same length.
    )rErHlist__args__	enumerater_subs_tvarsrIrrd	copy_with)tpr^ZsubsZnew_argsarMiZtvarrPrPrQris



ric	Cs^|jst|dt|}t|j}||krZtd||kr>dndd|d|d|dS)	zCheck correct count for parameters of a generic cls (internal helper).
    This gives a nice error message in case of count mismatch.
    z is not a generic classzToo ZmanyZfewz parameters for z	; actual z, expected N)rcrJlen)cls
parametersZalenZelenrPrPrQ_check_generics
rqcCsg}xn|D]f}t|tr0|jtkr0||jq
t|trft|dkrf|dtkrf||ddq
||q
Wt	|}t|t|krg}x(|D] }||kr|||
|qW|}|rt|t|S)zyAn internal helper for Union creation and substitution: flatten Unions
    among parameters, then remove duplicates.
    rN)rErHrIrrbrgrdrnr`setremoveAssertionError)rpparamspZ
all_paramsZ
new_paramsr]rPrPrQ_remove_dups_flattens"
"

rxcs4ttjtfdd}|S)zInternal wrapper caching __getitem__ of generic types with a fallback to
    original function for non-hashable arguments.
    cs*y
||Stk
rYnX||S)N)rJ)argskwds)cachedfuncrPrQinners

z_tp_cache.<locals>.inner)	functools	lru_cache	_cleanupsr`cache_clearwraps)r|r}rP)r{r|rQ	_tp_cachesrcsbt|tr|St|tr^tfdd|jD}||jkrH|S||}|j|_|S|S)zEvaluate all forward reverences in the given type t.
    For use of globalns and localns see the docstring for get_type_hints().
    c3s|]}t|VqdS)N)
_eval_type)r\rl)globalnslocalnsrPrQ	<genexpr>sz_eval_type.<locals>.<genexpr>)rErG	_evaluaterHrdrgrjra)r]rrZev_argsresrP)rrrQrs



rc@seZdZdZdZddZdS)_FinalzMixin to prohibit subclassing)__weakref__cOsd|krtddS)N_rootz&Cannot subclass special typing classes)rJ)selfryrzrPrPrQ__init_subclass__sz_Final.__init_subclass__N)rXrTrU__doc__	__slots__rrPrPrPrQrsrc@s eZdZdZddZddZdS)
_Immutablez3Mixin to indicate that object should not be copied.cCs|S)NrP)rrPrPrQ__copy__sz_Immutable.__copy__cCs|S)NrP)rZmemorPrPrQ__deepcopy__sz_Immutable.__deepcopy__N)rXrTrUrrrrPrPrPrQrsrcspeZdZdZdZfddZddZddZd	d
ZddZ	d
dZ
ddZddZddZ
eddZZS)rKzhInternal indicator of special typing constructs.
    See _doc instance attribute for specific docs.
    )_name_doccsBt|dkr6t|dtr6t|dtr6td|t|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).
        rrrzCannot subclass )rnrErFrdrJsuper__new__)roryrz)	__class__rPrQr)s
z_SpecialForm.__new__cCs||_||_dS)N)rr)rnamedocrPrPrQ__init__6sz_SpecialForm.__init__cCst|tstS|j|jkS)N)rErKNotImplementedr)rotherrPrPrQ__eq__:s
z_SpecialForm.__eq__cCst|jfS)N)hashr)rrPrPrQ__hash__?sz_SpecialForm.__hash__cCs
d|jS)Nztyping.)r)rrPrPrQ__repr__Bsz_SpecialForm.__repr__cCs|jS)N)r)rrPrPrQ
__reduce__Esz_SpecialForm.__reduce__cOstd|dS)NzCannot instantiate )rJ)rryrzrPrPrQ__call__Hsz_SpecialForm.__call__cCst|ddS)Nz! cannot be used with isinstance())rJ)rrZrPrPrQ__instancecheck__Ksz_SpecialForm.__instancecheck__cCst|ddS)Nz! cannot be used with issubclass())rJ)rrorPrPrQ__subclasscheck__Nsz_SpecialForm.__subclasscheck__cs|jdkr t|d}t||fS|jdkr|dkr:tdt|tsJ|f}dtfdd|D}t|}t|d	kr|d
St||S|jdkrt|d}t|t	dfSt|d
dS)Nr	z"ClassVar accepts only single type.rrPz Cannot take a Union of no types.z)Union[arg, ...]: each arg must be a type.c3s|]}t|VqdS)N)rR)r\rw)rNrPrQr\sz+_SpecialForm.__getitem__.<locals>.<genexpr>rrrrz#Optional[t] requires a single type.z is not subscriptable)
rrRrHrJrErdrxrnrrD)rrpitemrMrP)rNrQ__getitem__Qs$






z_SpecialForm.__getitem__)rXrTrUrrrrrrrrrrrrr
__classcell__rPrP)rrQrK"s
rK)ra`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.
    )raSpecial 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.
    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().
    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]

    - You cannot subclass or instantiate a union.
    - You can use Optional[X] as a shorthand for Union[X, None].
    zEOptional type.

    Optional[X] is equivalent to Union[X, None].
    c@s>eZdZdZdZdddZddZdd	Zd
dZdd
Z	dS)rGz-Internal wrapper to hold a forward reference.)__forward_arg____forward_code____forward_evaluated____forward_value____forward_is_argument__TcCsnt|tstd|yt|dd}Wn"tk
rJtd|YnX||_||_d|_d|_||_	dS)Nz*Forward reference must be a string -- got z<string>evalz/Forward reference must be an expression -- got F)
rErFrJcompileSyntaxErrorrrrrr)rrMrOcoderPrPrQrs
zForwardRef.__init__cCsj|jr||k	rd|dkr(|dkr(i}}n|dkr6|}n|dkrB|}tt|j||d|jd|_d|_|jS)Nz*Forward references must evaluate to types.)rOT)rrRrrrr)rrrrPrPrQrs
zForwardRef._evaluatecCs&t|tstS|j|jko$|j|jkS)N)rErGrrr)rrrPrPrQrs
zForwardRef.__eq__cCst|j|jfS)N)rrr)rrPrPrQrszForwardRef.__hash__cCsd|jdS)NzForwardRef())r)rrPrPrQrszForwardRef.__repr__N)T)
rXrTrUrrrrrrrrPrPrPrQrGs

rGc@s6eZdZdZdZddddddZdd	Zd
dZdS)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 to 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)

    Note that only type variables defined in global scope can be pickled.
    )rX	__bound____constraints__
__covariant____contravariant__NF)bound	covariant
contravariantcs||_|r|rtdt||_t||_|r>|dk	r>td|rVt|dkrVtddtfdd|D|_|rt	|d|_
nd|_
tdj
d	}|d
kr||_dS)Nz"Bivariant types are not supported.z-Constraints cannot be combined with bound=...rrz"A single constraint is not allowedz:TypeVar(name, constraint, ...): constraints must be types.c3s|]}t|VqdS)N)rR)r\r])rNrPrQrsz#TypeVar.__init__.<locals>.<genexpr>zBound must be a type.rXtyping)rX
ValueErrorboolrrrJrnrdrrRrsys	_getframe	f_globalsrT)rrrrrZconstraintsZdef_modrP)rNrQrs"

zTypeVar.__init__cCs&|jrd}n|jrd}nd}||jS)N+-~)rrrX)rprefixrPrPrQr'szTypeVar.__repr__cCs|jS)N)rX)rrPrPrQr0szTypeVar.__reduce__)rXrTrUrrrrrrPrPrPrQrs*	)	rfrddictrs	frozensetdequedefaultdictrDr4cCs|do|dS)N__)
startswithendswith)attrrPrPrQ
_is_dunderKsrcseZdZdZddddddZedd	Zd
dZdd
ZddZ	ddZ
ddZddZddZ
fddZddZddZddZZS) rHaThe central part of internal API.

    This represents a generic version of type 'origin' with type arguments 'params'.
    There are two kind of these aliases: user defined and special. The special ones
    are wrappers around builtin collections and ABCs in collections.abc. These must
    have 'name' always set. If 'inst' is False, then the alias can't be instantiated,
    this is used by e.g. typing.List and typing.Dict.
    TFN)instspecialrcCsz||_||_|r*|dkr*|j}t||}||_t|ts@|f}||_tdd|D|_	t
||_d|_|sv|j
|_
dS)Ncss*|]"}|tkrdn|tkrdn|VqdS).rPN)_TypingEllipsis_TypingEmpty)r\rlrPrPrQrbsz)_GenericAlias.__init__.<locals>.<genexpr>)_instrarX_normalize_aliasgetrrErdrIrgrercrrT)roriginrvrrrZ	orig_namerPrPrQrXs

z_GenericAlias.__init__cs^|jttfkrtd|t|ts,|f}dtfdd|D}t||t||j|S)Nz%Cannot subscript already-subscripted z*Parameters to generic types must be types.c3s|]}t|VqdS)N)rR)r\rw)rNrPrQrrsz,_GenericAlias.__getitem__.<locals>.<genexpr>)	rIr
rCrJrErdrqrirc)rrvrP)rNrQrjs

z_GenericAlias.__getitem__cCst|j||j|jdS)N)rr)rHrIrr)rrvrPrPrQrjvsz_GenericAlias.copy_withcCs|jdks&t|jdkrx|jdtkrx|jr8d|j}n
t|j}|jshdddd|jDd	}nd
}||S|jrdSddd
d|jddDdt|jdd	S)Nrrztyping.[z, cSsg|]}t|qSrP)r[)r\rlrPrPrQr_sz*_GenericAlias.__repr__.<locals>.<listcomp>]ztyping.Callableztyping.Callable[[cSsg|]}t|qSrP)r[)r\rlrPrPrQr_sz], )rrnrgEllipsisr[rIrajoin)rrryrPrPrQrzs

 z_GenericAlias.__repr__cCsRt|tstS|j|jkrdS|jtkrF|jtkrFt|jt|jkS|j|jkS)NF)rErHrrIrrrg)rrrPrPrQrs
z_GenericAlias.__eq__cCs,|jtkrttt|jfSt|j|jfS)N)rIrrrrg)rrPrPrQrs
z_GenericAlias.__hash__cOsT|js$td|jd|jd|j||}y
||_Wntk
rNYnX|S)NzType z cannot be instantiated; use z
() instead)rrJrlowerrIZ__orig_class__AttributeError)rrykwargsresultrPrPrQrs
z_GenericAlias.__call__cCs|jrZg}|j|kr ||j||}tdd||ddDsR|tt|S|jtkr||}x.||ddD]}t|tr||k	rdSqW|jfS)Ncss"|]}t|tpt|tVqdS)N)rErH
issubclassr
)r\brPrPrQrsz0_GenericAlias.__mro_entries__.<locals>.<genexpr>rrrP)	rrIr`indexanyr
rdrErH)rbasesrrmrrPrPrQ__mro_entries__s




z_GenericAlias.__mro_entries__cCs*d|jkrt|st|j|St|dS)NrI)__dict__rgetattrrIr)rrrPrPrQ__getattr__sz_GenericAlias.__getattr__cs2t|s|dkr t||nt|j||dS)N)rrra)rr__setattr__setattrrI)rrval)rrPrQrsz_GenericAlias.__setattr__cCs|t|S)N)rrD)rrZrPrPrQrsz_GenericAlias.__instancecheck__cCs<|jr0t|tst||jS|jr0t|j|jStddS)NzBSubscripted generics cannot be used with class and instance checks)rarErHrrIrJ)rrorPrPrQrs
z_GenericAlias.__subclasscheck__cCs|jr|jS|jr t|j}n|j}|tkrht|jdkrJ|jdtksht|jdd|jdf}n*t	|j}t|dkrt
|dt	s|\}tj||ffS)Nrrrrr)
rarglobalsrIrrnrgrrfrdrEoperatorgetitem)rrryrPrPrQrs
z_GenericAlias.__reduce__)rXrTrUrrrrrjrrrrrrrrrrrrPrP)rrQrHOs		rHcs,eZdZdZddZefddZZS)_VariadicGenericAliaszSame as _GenericAlias above but for variadic aliases. Currently,
    this is used only by special internal aliases: Tuple and Callable.
    cCs|jdks|js||St|tr0t|dkr8td|\}}|tkrRt|f}n$t|tsjtd|t||f}||S)Nrrz6Callable must be used as Callable[[arg, ...], result].z1Callable[args, result]: args must be a list. Got )	rra__getitem_inner__rErdrnrJrrf)rrvryrrPrPrQrs


z!_VariadicGenericAlias.__getitem__cs
|jtkr|jr|dkr$|tfSt|ts4|f}t|dkrl|ddkrldt|d}||tfSdtfdd	|D}||S|jt	j
jkr|jr|\}}d
t|}|tkr|t|fSdtfdd	|D}||f}||St
|S)
NrPrrr.z Tuple[t, ...]: t must be a type.rz*Tuple[t0, t1, ...]: each t must be a type.c3s|]}t|VqdS)N)rR)r\rw)rNrPrQrsz:_VariadicGenericAlias.__getitem_inner__.<locals>.<genexpr>z.Callable[args, result]: result must be a type.z6Callable[[arg, ...], result]: each arg must be a type.c3s|]}t|VqdS)N)rR)r\rM)rNrPrQr
s)rIrdrarjrrErnrRrcollectionsabcrrrr)rrvrwryr)r)rNrQrs.




z'_VariadicGenericAlias.__getitem_inner__)rXrTrUrrrrrrPrP)rrQrsrcs<eZdZdZdZfddZeddZfddZZ	S)	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
    rPcsP|tkrtdtjtjkr8|jtjk	r8t|}ntj|f||}|S)NzHType Generic cannot be instantiated; it can be used only as a base class)r
rJrrobjectr)roryrzrZ)rrPrQr&szGeneric.__new__cst|ts|f}|s.|tk	r.td|jddtfdd|D}|tkrtdd|Dsjtdtt|t|krtdn|t	krn
t
||t||S)	NzParameter list to z[...] cannot be emptyz*Parameters to generic types must be types.c3s|]}t|VqdS)N)rR)r\rw)rNrPrQr8sz,Generic.__class_getitem__.<locals>.<genexpr>css|]}t|tVqdS)N)rEr)r\rwrPrPrQr;sz5Parameters to Generic[...] must all be type variablesz-Parameters to Generic[...] must all be unique)rErdrrJrUr
allrnrsrCrqrH)rorvrP)rNrQ__class_getitem__0s$

zGeneric.__class_getitem__c
stj||g}d|jkr(t|jk}nt|jko:|jdk}|rHtdd|jkr
t|j}d}x8|jD].}t	|t
rj|jtkrj|dk	rtd|j}qjW|dkr|}n`t
|}t
||ksdfdd|D}ddd|D}	td	|d
|	d|}t||_dS)N__orig_bases__rCz!Cannot inherit from plain Genericz0Cannot inherit from Generic[...] multiple types.z, c3s|]}|krt|VqdS)N)rF)r\r])gvarsetrPrQrgsz,Generic.__init_subclass__.<locals>.<genexpr>css|]}t|VqdS)N)rF)r\grPrPrQrhszSome type variables (z) are not listed in Generic[r)rrrr
r	__bases__rXrJrerErHrIrcrsrrd)
roryrr^errorZgvarsbaseZtvarsetZs_varsZs_args)r)rrQrIs6





zGeneric.__init_subclass__)
rXrTrUrrrrrrrrPrP)rrQr
s

c@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)rXrTrUrrPrPrPrQrosrc@seZdZdZdS)rz(Internal placeholder for ... (ellipsis).N)rXrTrUrrPrPrPrQrvsrcCs|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).
    rP)typrrPrPrQr9zsc
Csy
|j}Wntk
riSX|j}|j}|d|}|jp@d}|j}|rTt|ni}|t|}x2t||d|D]\}}	||kst	|	||<qxW|S)z:Internal helper to extract the default arguments, by name.NrP)
__code__rco_argcountco_varnames__defaults____kwdefaults__rrnzipru)
r|rZ	pos_countZ	arg_namesdefaultsZ
kwdefaultsrZ
pos_offsetrvaluerPrPrQ
_get_defaultss

rc
Cst|ddriSt|tri}xt|jD]~}|dkrFtj|jj}n|}|j	di}xN|
D]B\}}|dkrztd}t|trt|dd}t
|||}|||<qbWq*W|S|dkrt|tjr|j}nt|di}|dkr|}n|dkr|}t|dd}|dkr&t|triStd|t|}	t|}xp|
D]d\}}|dkrZtd}t|trnt|}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__F)rO__globals__z1{!r} is not a module, class, method, or function.)rrErDreversed__mro__rmodulesrTrritemsrFrGrrV
ModuleType_allowed_typesrJformatrrr)
rZrrZhintsrZbase_globalsannrrrrPrPrQr:sV



cCst|tr||j}x0|jD]"\}}||j|fkr ||q Wx4|D](}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)
rErDrcopyr
rpopvaluesrVrWrr<rJ)rMZ	arg_attrsrrrZrPrPrQr<s	



cstfdd}|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)r<)ryrzr|)	decoratorrPrQwrapped_decorators
z2no_type_check_decorator.<locals>.wrapped_decorator)r~r)rrrP)rrQr=
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)ryrzrPrPrQ_overload_dummysrcCstS)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|rPrPrQr?#scs0eZdZdZfddZddZddZZS)
_ProtocolMetaz~Internal metaclass for _Protocol.

    This exists so _Protocol classes can be generic without deriving
    from Generic.
    cs"t|jkrt|StddS)Nz+Protocols cannot be used with isinstance().)rCrrrrJ)rrZ)rrPrQrGs
z_ProtocolMeta.__instancecheck__csL|js
tS|tkrdS|}x(|D] tfdd|jDs$dSq$WdS)NTc3s|]}|jkVqdS)N)r)r\d)rrPrQrYsz2_ProtocolMeta.__subclasscheck__.<locals>.<genexpr>F)_is_protocolrrC_get_protocol_attrsrr)rroattrsrP)rrQrLs
z_ProtocolMeta.__subclasscheck__cCs&g}x.|jD]$}t|ddr|jdkr||qWt}x|D]}x|jD]}x|jD]$}||k	r^||jkr^t|dds^Pq^W|dsR|dkrR|dkrR|dkrR|dkrR|dkrR|d	krR|d
krR|dkrR|dkrR|d
krR|dkrR|dkrR|dkrR|dkrR|dkrR|dkrR||qRWqBW|S)NrFrCZ_abc___abstractmethods__rrZ_gorgrrgrrZ__next_in_mro__rcrIrZ	__extra__Z
__tree_hash__rT)	rrrXr`rsrkeysradd)rZprotocol_basescrrrrPrPrQr]s<
z!_ProtocolMeta._get_protocol_attrs)rXrTrUrrrrrrPrP)rrQr@srcs(eZdZdZdZdZfddZZS)rCzInternal 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).
    rPTcst|S)N)rr)rorv)rrPrQrsz_Protocol.__class_getitem__)rXrTrUrrrrrrPrP)rrQrCsrC)	metaclassTKTVTT_co)rV_coVT_coT_contra)rCT_co)rrcCst||d|dS)NT)rr)rH)rrvrrPrPrQ_aliassr+rP)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.
    F)rra@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, ...].
    )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.
    c@s"eZdZdZeedddZdS)r-rP)returncCsdS)NrP)rrPrPrQ__int__szSupportsInt.__int__N)rXrTrUrrintr-rPrPrPrQr-sc@s"eZdZdZeedddZdS)r,rP)r,cCsdS)NrP)rrPrPrQ	__float__szSupportsFloat.__float__N)rXrTrUrrfloatr/rPrPrPrQr,sc@s"eZdZdZeedddZdS)r+rP)r,cCsdS)NrP)rrPrPrQ__complex__szSupportsComplex.__complex__N)rXrTrUrrcomplexr1rPrPrPrQr+sc@s"eZdZdZeedddZdS)r*rP)r,cCsdS)NrP)rrPrPrQ	__bytes__szSupportsBytes.__bytes__N)rXrTrUrrbytesr3rPrPrPrQr*sc@s"eZdZdZeedddZdS)r)rP)r,cCsdS)NrP)rrPrPrQ__abs__szSupportsAbs.__abs__N)rXrTrUrrr&r5rPrPrPrQr)sc@s&eZdZdZedeedddZdS)r.rPr)ndigitsr,cCsdS)NrP)rr6rPrPrQ	__round__'szSupportsRound.__round__N)r)rXrTrUrrr.r&r7rPrPrPrQr.$sc	svdfdd|D}t|dd|D}t||_|_ytdjdd|_	Wnt
tfk
rpYnX|S)NzDNamedTuple('Name', [(f0, t0), (f1, t1), ...]); each t must be a typecsg|]\}}|t|fqSrP)rR)r\nr])rNrPrQr_.sz!_make_nmtuple.<locals>.<listcomp>cSsg|]\}}|qSrPrP)r\r8r]rPrPrQr_/srrX__main__)r
namedtupleOrderedDictr_field_typesrrrrrTrr)rrVnm_tplrP)rNrQ
_make_nmtuple,sr>)rrr__getnewargs___fields_field_defaultsr<_make_replace_asdictZ_source)rTrXrUrcseZdZfddZZS)NamedTupleMetacs|ddrt||||S|di}t||}g}i}xP|D]H}||krn||}	||	|	||<qF|rFtdj|d|	dqFWt
||j_t
||j_||_xD|D]<}
|
tkrtd|
q|
tkr|
|jkrt||
||
qW|S)NrFrzXNon-default namedtuple field {field_name} cannot follow default field(s) {default_names}z, )
field_nameZ
default_namesz&Cannot overwrite NamedTuple attribute )rrrr>r
r`rJrrrrr;rrdrrA_prohibitedrrar@r)rotypenamernsrVr=rZ
defaults_dictrFZ
default_valuekey)rrPrQrDs0



zNamedTupleMeta.__new__)rXrTrUrrrPrP)rrQrEBsrEc@seZdZdZdZdddZdS)r6a4Typed 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(|dkr|}n|rtdt||S)NzIEither list of fields or keywords can be provided to NamedTuple, not both)r
rJr>)rrHZfieldsrrPrPrQr}s

zNamedTuple.__new__)N)rXrTrUrrrrPrPrPrQr6ascCsdd}||_||_|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)NrP)xrPrPrQnew_typeszNewType.<locals>.new_type)rXZ
__supertype__)rrkrLrPrPrQr;sc@seZdZdZdZeedddZeedddZe	ddd	d
Z
e	edddZe	e
dd
dZe	ddddZe	edddZe	d7e
edddZe	edddZe	d8e
edddZe	d9e
eedddZe	d:e
e
e
d d!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/d0d1Ze	d2dd3d4Ze	ddd5d6ZdS)<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.
    rP)r,cCsdS)NrP)rrPrPrQmodeszIO.modecCsdS)NrP)rrPrPrQrszIO.nameNcCsdS)NrP)rrPrPrQcloseszIO.closecCsdS)NrP)rrPrPrQclosedsz	IO.closedcCsdS)NrP)rrPrPrQfilenosz	IO.filenocCsdS)NrP)rrPrPrQflushszIO.flushcCsdS)NrP)rrPrPrQisattysz	IO.isattyr)r8r,cCsdS)NrP)rr8rPrPrQreadszIO.readcCsdS)NrP)rrPrPrQreadableszIO.readable)limitr,cCsdS)NrP)rrVrPrPrQreadlineszIO.readline)hintr,cCsdS)NrP)rrXrPrPrQ	readlinesszIO.readlinesr)offsetwhencer,cCsdS)NrP)rrZr[rPrPrQseekszIO.seekcCsdS)NrP)rrPrPrQseekableszIO.seekablecCsdS)NrP)rrPrPrQtellszIO.tell)sizer,cCsdS)NrP)rr_rPrPrQtruncateszIO.truncatecCsdS)NrP)rrPrPrQwritableszIO.writable)sr,cCsdS)NrP)rrbrPrPrQwriteszIO.write)linesr,cCsdS)NrP)rrdrPrPrQ
writelinessz
IO.writelinesz
IO[AnyStr]cCsdS)NrP)rrPrPrQ	__enter__szIO.__enter__cCsdS)NrP)rrDr	tracebackrPrPrQ__exit__szIO.__exit__)r)r)r)r)N) rXrTrUrrrrFrNrrrOrrPr.rQrRrSr8rTrUrWr3rYr\r]r^r`rarcrerfrhrPrPrPrQrMsTrMc@sBeZdZdZdZeeeefe	dddZ
eddddZd	S)
BinaryIOz5Typed version of the return of open() in binary mode.rP)rbr,cCsdS)NrP)rrbrPrPrQrcszBinaryIO.write)r,cCsdS)NrP)rrPrPrQrfszBinaryIO.__enter__N)rXrTrUrrrrr4	bytearrayr.rcrfrPrPrPrQri	sric@seZdZdZdZeedddZeedddZ	ee
eddd	Zeedd
dZ
eeddd
ZeddddZdS)TextIOz3Typed version of the return of open() in text mode.rP)r,cCsdS)NrP)rrPrPrQbuffersz
TextIO.buffercCsdS)NrP)rrPrPrQencoding szTextIO.encodingcCsdS)NrP)rrPrPrQerrors$sz
TextIO.errorscCsdS)NrP)rrPrPrQline_buffering(szTextIO.line_bufferingcCsdS)NrP)rrPrPrQnewlines,szTextIO.newlinescCsdS)NrP)rrPrPrQrf0szTextIO.__enter__N)rXrTrUrrrrirlrFrmrrnrrorrprrfrPrPrPrQrksrkc@s&eZdZdZdddgZeZeZeZdS)ioz)Wrapper namespace for IO generic classes.rMrkriN)rXrTrUr__all__rMrkrirPrPrPrQrq5s

rqz.ioc@s eZdZdZddgZeZeZdS)rez&Wrapper namespace for re type aliases.PatternMatchN)rXrTrUrrrrtrurPrPrPrQrsDsrsz.re)T)NN)T)rrrrrZcollections.abc
contextlibr~rrsZ	stdlib_rerrVrrrrrrRr[rerirqrxrrrrrrKrr>r	rrrGrrrrHrr
rrr9rrWBuiltinFunctionType
MethodTyperrr:r<r=rr?rDrrCr#r$r%r&r'r(r)r*r4rFr8r+rr!r$r#r"rrr(rrr%rr4rrrrrrrrdrrfr3rr0rsrr5rrrr AbstractContextManagerrAbstractAsyncContextManagerr'rr1rr2r;r/ChainMapr7r&r
r-r,r+r*r)r.r>rGrarEr6r;r@rArMrirkrqrXrrtrurPrPrPrQ<module>s
!
	
E
0^/_

R	D

	%`