U e5db �G@s�ddlmZmZddlZddlZddlZddlZddlZddlZ ddl Z ddl Z ddl m Z m Z mZdddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJgGZd�dLdM�ZdNdO�ZdPdQ�ZdRdS�ZdTdU�ZdVdW�ZgZdXdY�ZdZd[�ZGd\d]�d]�ZGd^d_�d_�ZGd`da�daeedKdb�Zeddcdd�ZedFdedd�Zeddfdd�Zeddgdd�Zeddhdd�Z ed didd�Z!ed djdd�Z"Gdkd�dedKdb�Z#Gdld�deedKdb�Z$d6d d4d8d9d3d5dddm� Z%dndo�Z&Gdpdq�dqedKdb�Z'Gdrds�dse'dKdb�Z(Gdtd �d �Z)Gdudv�dv�Z*Gdwdx�dx�Z+dydzd{d|d}gZ,d~dd�d�d�d�d�d�d�d�g Z-e,e-d�gZ.d�d��Z/d�d��Z0d�d��Z1d�d��Z2dd"ddd$dd dd&d)g d�d�gd��Z3Gd�d��d�e�Z4Gd�d �d e)e4d��Z5d�dH�Z6d�d>�Z7d�d��Z8e j9e j:e j;e jd�dA�Z?d�d@�Z@d�dD�ZAd�dE�ZBd�d��ZCd�dG�ZDd�d?�ZEe$d��ZFe$d��ZGe$d��ZHe$d�dKd��ZIe$d�dKd��ZJe$d�dKd��ZKe$d�dKd��ZLe$d�dKeMd��ZNe$d=eOeP�ZQd�d�d��ZReRejjSd��ZSeRejjTeI�ZTeRejjUeIeLeJf�ZUeRejjVeI�ZVeRejjWeI�ZWeRejjXeI�ZXeRejjYeI�ZYeRejjZeI�ZZeRejj[d��Z[eRejj\eI�Z\eRejj]eI�Z]e(ejj^d�dKd��Z^d�e^__eRejj`eI�ZaeRejjbeF�ZbeRejjceGeKf�ZceRejjdeGeHf�ZdeRejjeeI�ZeeRejjfeF�ZfeRejjgd��Zge(ehd�d�dKd��Zid�ei__eRejeFd�d��ZkeRejleF�ZmeReneFd�d��Z`eReoeId�d��ZpeRejjqeI�ZqeRejjreG�ZreRejjseGeKf�ZseRejjteK�ZteRejueI�ZveRejweI�ZxeReyeGeHfd�d��ZzeRej{eGeHf�Z|eRej}eGeHf�Z}eRej~eF�Z~eRejeGeHf�ZeRejj�eIeLeJf�Z�eRejj�eIeLf�Z�eReMeNd�d��Z�d�e�__e6Gd�d/�d/e5��Z�e6Gd�d-�d-e5��Z�e6Gd�d,�d,e5��Z�e6Gd�d+�d+e5��Z�e6Gd�d.�d.e5��Z�e6Gd�d*�d*e5eI��Z�e6Gd�d0�d0e5eI��Z�d�d„Z�d�Z�d�Z�Gd�dÆ„d�eM�Z�Gd�d:�d:e�d��Z�d�dÉ„Z�d�dKdÊœd�dÌ„Z�d�d΄Z�Gd�dЄd�eM�Z�Gd�d;�d;eye�d��Z�d�dC�Z�ePZ�d�Z�Gd�dÔ„d�e)eQ�Z�Gd�dÖ„d�e�eO�Z�Gd�dØ„d�e�eP�Z�Gd�dÚ„dÚƒZ�e�d�e�_�e�e j�e�j�<eRe j�eQ�Z�eRe j�eQ�Z�Gd�dÝ„d݃Ze�d�e_�ee j�ej�<dS)��)�abstractmethod�ABCMetaN)�WrapperDescriptorType�MethodWrapperType�MethodDescriptorType�Any�Callable�ClassVar�Final� ForwardRef�Generic�Literal�Optional�Protocol�Tuple�Type�TypeVar�Union� AbstractSet� ByteString� Container�ContextManager�Hashable� ItemsView�Iterable�Iterator�KeysView�Mapping� MappingView�MutableMapping�MutableSequence� MutableSet�Sequence�Sized� ValuesView� Awaitable� AsyncIterator� AsyncIterable� Coroutine� Collection�AsyncGenerator�AsyncContextManager� Reversible� SupportsAbs� SupportsBytes�SupportsComplex� SupportsFloat� SupportsIndex� SupportsInt� SupportsRound�ChainMap�Counter�Deque�Dict� DefaultDict�List� OrderedDict�Set� FrozenSet� NamedTuple� TypedDict� Generator�AnyStr�cast�final�get_args� get_origin�get_type_hints�NewType� no_type_check�no_type_check_decorator�NoReturn�overload�runtime_checkable�Text� TYPE_CHECKINGTcCs�ttf}|r|ttf}|dkr(td�St|t�r:t|�St|t�r\|j |kr\t |�d���t|t �rr|t t fks~|ttfkr�t d|�d���t|tttf�r�|St|�s�t |�d|d�d���|S)Nz is not valid as type argumentzPlain z Got z.100�.)r rr r �type� isinstance�strr � _GenericAlias� __origin__� TypeError� _SpecialFormrrIr�callable)�arg�msg� is_argumentZinvalid_generic_forms�rZ�/usr/lib64/python3.8/typing.py� _type_checkxs(    � �r\cCsRt|t�r,|jdkr|jS|j�d|j��S|dkr8dSt|tj�rJ|jSt|�S)N�builtinsrN.z...)rPrO� __module__� __qualname__�types� FunctionType�__name__�repr)�objrZrZr[� _type_repr�s   recs\g�|D]J}t|t�r(|�kr(��|�t|t�r|js���fdd�|jD��qt��S)Ncsg|]}|�kr|�qSrZrZ��.0�t��tvarsrZr[� �sz&_collect_type_vars..)rPr�appendrR�_special�extend�__parameters__�tuple)r`rhrZrir[�_collect_type_vars�s rqcCs�t|t�s|St|j�}t|j�D]J\}}t|t�r\t|�D]\}}||kr<||||<qdnd�d|�d|�d|����dS)Nz is not a generic classzToo ZmanyZfewz parameters for z ; actual z , expected )rorT�len)�cls� parametersZalenZelenrZrZr[�_check_generic�s  r~cCs�g}|D]f}t|t�r.|jtkr.|�|j�qt|t�rdt|�dkrd|dtkrd|�|dd��q|�|�qt |�}t|�t|�kr�g}|D] }||kr�|�|�|� |�q�|}t|�S)Nr�) rPrRrSrrnrtrpr{rl�set�remove)r}�params�pZ all_paramsZ new_paramsrhrZrZr[�_remove_dups_flatten�s "   r�cs4t�����t��j�t�����fdd��}|S)Ncs,z �||�WStk r YnX�||�Srr�rT��args�kwds��cached�funcrZr[�inner�s  z_tp_cache..inner)� functools� lru_cache� _cleanupsrl� cache_clear�wraps)r�r�rZr�r[� _tp_cache�s   r�csbt|t�r|����St|t�r^t��fdd�|jD��}||jkrH|S|�|�}|j|_|S|S)Nc3s|]}t|���VqdSrr)� _eval_type�rgry��globalns�localnsrZr[� sz_eval_type..)rPr � _evaluaterRrprtrwrm)rhr�r�Zev_args�resrZr�r[r� s     r�c@seZdZdZdd�ZdS)�_Final)� __weakref__cOsd|krtd��dS)N�_rootz&Cannot subclass special typing classesr���selfr�r�rZrZr[�__init_subclass__sz_Final.__init_subclass__N)rbr^r_� __slots__r�rZrZrZr[r�sr�c@seZdZdd�Zdd�ZdS)� _ImmutablecCs|SrrrZ�r�rZrZr[�__copy__%sz_Immutable.__copy__cCs|SrrrZ)r�ZmemorZrZr[� __deepcopy__(sz_Immutable.__deepcopy__N)rbr^r_r�r�rZrZrZr[r�"sr�csleZdZdZ�fdd�Zdd�Zdd�Zdd �Zd d �Zd d �Z dd�Z dd�Z dd�Z e dd��Z�ZS)rU��_nameZ_doccsBt|�dkr6t|dt�r6t|dt�r6td|����t��|�S)N�rrzCannot subclass )r{rPrQrprT�super�__new__)r|r�r��� __class__rZr[r�3s  � �z_SpecialForm.__new__cCs||_||_dSrrr�)r��name�docrZrZr[�__init__@sz_SpecialForm.__init__cCst|t�stS|j|jkSrr)rPrU�NotImplementedr��r��otherrZrZr[�__eq__Ds z_SpecialForm.__eq__cCs t|jf�Srr)�hashr�r�rZrZr[�__hash__Isz_SpecialForm.__hash__cCs d|jS)N�typing.�r�r�rZrZr[�__repr__Lsz_SpecialForm.__repr__cCs|jSrrr�r�rZrZr[� __reduce__Osz_SpecialForm.__reduce__cOstd|����dS)NzCannot instantiate r�r�rZrZr[�__call__Rsz_SpecialForm.__call__cCst|�d���dS)Nz! cannot be used with isinstance()r��r�rdrZrZr[�__instancecheck__Usz_SpecialForm.__instancecheck__cCst|�d���dS)Nz! cannot be used with issubclass()r��r�r|rZrZr[�__subclasscheck__Xsz_SpecialForm.__subclasscheck__cs�|jdkr(t||j�d��}t||f�S|jdkr�|dkrBtd��t|t�sR|f}d�t�fdd�|D��}t|�}t|�d kr�|d St||�S|jd kr�t|d �}t|t d�fS|jd kr�t||�St|�d���dS)N)r r z accepts only single type.rrZz Cannot take a Union of no types.z)Union[arg, ...]: each arg must be a type.c3s|]}t|��VqdSrr�r\�rgr��rXrZr[r�fsz+_SpecialForm.__getitem__..rrrz#Optional[t] requires a single type.r z is not subscriptable) r�r\rRrTrPrpr�r{rrO)r�r}�itemrWrZr�r[� __getitem__[s(          z_SpecialForm.__getitem__)rbr^r_r�r�r�r�r�r�r�r�r�r�r�r�� __classcell__rZrZr�r[rU,s rU)r�a`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. )r�aSpecial 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�Special typing construct to indicate final names to type checkers. A final name cannot be re-assigned or overridden in a subclass. For example: MAX_SIZE: Final = 9000 MAX_SIZE += 1 # Error reported by type checker class Connection: TIMEOUT: Final[int] = 10 class FastConnector(Connection): TIMEOUT = 1 # Error reported by type checker There is no runtime checking of these properties. 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]. a�Special typing form to define literal types (a.k.a. value types). This form can be used to indicate to type checkers that the corresponding variable or function parameter has a value equivalent to the provided literal (or one of several literals): def validate_simple(data: Any) -> Literal[True]: # always returns True ... MODE = Literal['r', 'rb', 'w', 'wb'] def open_helper(file: str, mode: MODE) -> str: ... open_helper('/some/path', 'r') # Passes type check open_helper('/other/path', 'typo') # Error in type checker Literal[...] cannot be subclassed. At runtime, an arbitrary value is allowed as type argument to Literal[...], but type checkers may impose restrictions. c@s:eZdZdZddd�Zdd�Zdd�Zd d �Zd d �Zd S)r )�__forward_arg__�__forward_code__�__forward_evaluated__�__forward_value__�__forward_is_argument__TcCsnt|t�std|����zt|dd�}Wn"tk rJtd|����YnX||_||_d|_d|_||_ dS)Nz*Forward reference must be a string -- got z�evalz/Forward reference must be an expression -- got F) rPrQrT�compile� SyntaxErrorr�r�r�r�r�)r�rWrY�coderZrZr[r��s 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.�rYT)r�r\r�r�r�r�)r�r�r�rZrZr[r��s  �zForwardRef._evaluatecCs>t|t�stS|jr2|jr2|j|jko0|j|jkS|j|jkSrr)rPr r�r�r�r�r�rZrZr[r� s    �zForwardRef.__eq__cCs t|j�Srr)r�r�r�rZrZr[r�szForwardRef.__hash__cCsd|j�d�S)Nz ForwardRef(�))r�r�rZrZr[r�szForwardRef.__repr__N)T) rbr^r_r�r�r�r�r�r�rZrZrZr[r �s  c@s2eZdZdZdddd�dd�Zdd�Zd d �ZdS) r)rb� __bound__�__constraints__� __covariant__�__contravariant__NF)�bound� covariant� contravariantc s�||_|r|rtd��t|�|_t|�|_|r>|dk r>td��|rVt|�dkrVtd��d�t�fdd�|D��|_|r�t |d�|_ nd|_ zt � d�j �d d �}Wnttfk r�d}YnX|d kr�||_dS) Nz"Bivariant types are not supported.z-Constraints cannot be combined with bound=...rz"A single constraint is not allowedz:TypeVar(name, constraint, ...): constraints must be types.c3s|]}t|��VqdSrrr�rfr�rZr[r�Vsz#TypeVar.__init__..zBound must be a type.rb�__main__�typing)rb� ValueError�boolr�r�rTr{rpr�r\r��sys� _getframe� f_globals�get�AttributeErrorr^)r�r�r�r�r�Z constraintsZdef_modrZr�r[r�Js(    zTypeVar.__init__cCs&|jr d}n|jrd}nd}||jS)N�+�-�~)r�r�rb)r��prefixrZrZr[r�bs zTypeVar.__repr__cCs|jSrr)rbr�rZrZr[r�kszTypeVar.__reduce__)rbr^r_r�r�r�r�rZrZrZr[rs,�  ) rsrp�dictr�� frozenset�deque� defaultdictrOr;cCs|�d�o|�d�S)N�__)� startswith�endswith)�attrrZrZr[� _is_dunder�sr�cs�eZdZdddd�dd�Zedd��Zd d �Zd d �Zd d�Zdd�Z dd�Z dd�Z dd�Z �fdd�Z dd�Zdd�Zdd�Z�ZS)rRTFN)�inst�specialr�cCsz||_||_|r*|dkr*|j}t�||�}||_t|t�s@|f}||_tdd�|D��|_ t |�|_ d|_ |sv|j |_ dS)Ncss*|]"}|tkrdn|tkrdn|VqdS).rZN)�_TypingEllipsis� _TypingEmptyr�rZrZr[r��s�  z)_GenericAlias.__init__..)�_instrmrb�_normalize_aliasr�r�rPrprSrtrqror�r^)r��originr�r�r�r�Z orig_namerZrZr[r��s    �  z_GenericAlias.__init__cs^|jttfkrtd|����t|t�s,|f}d�t�fdd�|D��}t||�t||j|�S)Nz%Cannot subscript already-subscripted �*Parameters to generic types must be types.c3s|]}t|��VqdSrrr�r�r�rZr[r��sz,_GenericAlias.__getitem__..) rSr rrTrPrpr~rvro�r�r�rZr�r[r��s  z_GenericAlias.__getitem__cCst|j||j|jd�S)N)r�r�)rRrSr�r�r�rZrZr[rw�sz_GenericAlias.copy_withcCs�|jdks&t|j�dkrx|jdtkrx|jr8d|j}n t|j�}|jshdd�dd�|jD���d �}nd }|�|��S|jr�d Sd d�d d�|jdd�D���dt|jd��d �S)Nr�rr��[�, cSsg|] }t|��qSrZ�rer�rZrZr[rk�sz*_GenericAlias.__repr__..�]�ztyping.Callableztyping.Callable[[cSsg|] }t|��qSrZr�r�rZrZr[rk�s�����z], )r�r{rt�EllipsisrerSrm�join)r�r�r�rZrZr[r��s  � �    z_GenericAlias.__repr__cCsRt|t�stS|j|jkrdS|jtkrF|jtkrFt|j�t|j�kS|j|jkS)NF)rPrRr�rSrr�rtr�rZrZr[r��s  z_GenericAlias.__eq__cCs,|jtkrttt|j�f�St|j|jf�Srr)rSrr�r�rtr�rZrZr[r��s z_GenericAlias.__hash__cOsT|js$td|j�d|j���d���|j||�}z ||_Wntk rNYnX|S)N�Type z cannot be instantiated; use z () instead)r�rTr��lowerrS�__orig_class__r�)r�r��kwargs�resultrZrZr[r��s  z_GenericAlias.__call__cCs�|jrZg}|j|kr |�|j�|�|�}tdd�||dd�D��sR|�t�t|�S|jtkr�t|krpdS|�|�}||dd�D]}t|t �r�||k r�dSq�|jfS)Ncss"|]}t|t�pt|t�VqdSrr)rPrR� issubclassr �rg�brZrZr[r��s�z0_GenericAlias.__mro_entries__..rrZ) r�rSrl�index�anyr rprrPrR)r��basesr�rzrrZrZr[�__mro_entries__�s$   �   z_GenericAlias.__mro_entries__cCs*d|jkrt|�st|j|�St|��dS)NrS)�__dict__r��getattrrSr�)r�r�rZrZr[� __getattr__�s z_GenericAlias.__getattr__cs2t|�s|dkr t��||�nt|j||�dS)N)r�r�rm)r�r�� __setattr__�setattrrS)r�r��valr�rZr[r�sz_GenericAlias.__setattr__cCs|�t|��Srr)r�rOr�rZrZr[r�sz_GenericAlias.__instancecheck__cCs<|jr0t|t�st||j�S|jr0t|j|j�Std��dS)NzBSubscripted generics cannot be used with class and instance checks)rmrPrRrrSrTr�rZrZr[r�s   z_GenericAlias.__subclasscheck__cCs�|jr |jS|jr t�|j}n|j}|tkrht|j�dkrJ|jdtksht|jdd��|jdf}n*t |j�}t|�dkr�t |dt �s�|\}t j ||ffS)Nr�rr�r) rmr��globalsrSrr{rtr�rsrprP�operator�getitem)r�r�r�rZrZr[r� s � � z_GenericAlias.__reduce__)rbr^r_r�r�r�rwr�r�r�r�r r rr�r�r�r�rZrZr�r[rR�s      rRcs(eZdZdd�Ze�fdd��Z�ZS)�_VariadicGenericAliascCs�|jdks|js|�|�St|t�r0t|�dkr8td��|\}}|tkrRt|f}n$t|t�sjtd|����t|�|f}|�|�S)Nrr�z6Callable must be used as Callable[[arg, ...], result].z1Callable[args, result]: args must be a list. Got ) r�rm�__getitem_inner__rPrpr{rTr�rs)r�r�r�rrZrZr[r�"s    z!_VariadicGenericAlias.__getitem__cs |jtkr�|jr�|dkr$|�tf�St|t�s4|f}t|�dkrl|ddkrld�t|d��}|�|tf�Sd�t�fdd �|D��}|�|�S|jt j j kr�|jr�|\}}d �t|��}|t kr�|�t|f�Sd �t�fd d �|D��}||f}|�|�St ��|�S) NrZr�r.z Tuple[t, ...]: t must be a type.rz*Tuple[t0, t1, ...]: each t must be a type.c3s|]}t|��VqdSrrr�r�r�rZr[r�>sz:_VariadicGenericAlias.__getitem_inner__..z.Callable[args, result]: result must be a type.z6Callable[[arg, ...], result]: each arg must be a type.c3s|]}t|��VqdSrrr�)rgrWr�rZr[r�Gs)rSrprmrwr�rPr{r\r�� collections�abcrr�r�r�)r�r�r�r�rr�r�r[r2s.      z'_VariadicGenericAlias.__getitem_inner__)rbr^r_r�r�rr�rZrZr�r[rsrcs<eZdZdZdZ�fdd�Zedd��Z�fdd�Z�Z S) r rZFcs^|ttfkrtd|j�d���t�jtjkrF|jtjk rFt��|�}nt�j|f|�|�}|S)Nr�z< cannot be instantiated; it can be used only as a base class)r rrTrbr�r��objectr�)r|r�r�rdr�rZr[r�ds  zGeneric.__new__cs�t|t�s|f}|s.|tk r.td|j�d���d�t�fdd�|D��}|ttfkr�tdd�|D��sxtd|j�d���t t |��t |�kr�td|j�d ���n t ||�t ||�S) NzParameter list to z[...] cannot be emptyr�c3s|]}t|��VqdSrrr�r�r�rZr[r�vsz,Generic.__class_getitem__..css|]}t|t�VqdSrr)rPrr�rZrZr[r�yszParameters to z [...] must all be type variablesz[...] must all be unique) rPrprrTr_r r�allrbr{r�r~rR)r|r�rZr�r[�__class_getitem__ns&   �  � � zGeneric.__class_getitem__c s t�j||�g}d|jkr(t|jk}nt|jko:|jdk}|rHtd��d|jkr�t|j�}d}|jD].}t |t �rf|j tkrf|dk r�td��|j }qf|dk r�t |�}t |��|�ks�d��fdd�|D��}d�dd�|D��} td |�d | �d ���|}t|�|_ dS) N�__orig_bases__rz!Cannot inherit from plain Genericz0Cannot inherit from Generic[...] multiple types.r�c3s|]}|�krt|�VqdSrr�rQrf�ZgvarsetrZr[r��sz,Generic.__init_subclass__..css|]}t|�VqdSrrr)rg�grZrZr[r��szSome type variables (z) are not listed in Generic[r�)r�r�r r r� __bases__rbrTrqrPrRrSror�r�rp) r|r�rrj�errorZgvars�baseZtvarsetZs_varsZs_argsr�rr[r��s8      ��zGeneric.__init_subclass__) rbr^r_r�� _is_protocolr�r�rr�r�rZrZr�r[r Ms   c@s eZdZdS)r�N�rbr^r_rZrZrZr[r��sr�c@s eZdZdS)r�Nr#rZrZrZr[r��sr�rorrr"�_is_runtime_protocol�__abstractmethods__�__annotations__r �__doc__r�r^r�r��__subclasshook__r��_MutableMapping__markercCsrt�}|jdd�D]X}|jdkr$qt|di�}t|j���t|���D] }|�d�sJ|tkrJ|� |�qJq|S)Nr�)rr r&Z_abc_) r��__mro__rbr rsr �keysr��EXCLUDED_ATTRIBUTES�add)r|�attrsr!� annotationsr�rZrZr[�_get_protocol_attrs�s  r0cst�fdd�t��D��S)Nc3s|]}tt�|d��VqdSrr)rVr �rgr��r|rZr[r��sz,_is_callable_members_only..)rr0r2rZr2r[�_is_callable_members_only�sr3cOst|�jrtd��dS)Nz Protocols cannot be instantiated)rOr"rT)r�r�rrZrZr[�_no_init�s r4c Cs6zt�d�jddkWSttfk r0YdSXdS)Nr�rb)rr�T)r�r�r�r�r�rZrZrZr[�_allow_reckless_class_cheks�sr5�AbstractContextManager�AbstractAsyncContextManager)zcollections.abc� contextlibcseZdZ�fdd�Z�ZS)� _ProtocolMetacsVt�dd�rt��r$t�j��r$dS�jrJt��fdd�t��D��rJdSt����S)Nr"FTc3s8|]0}t�|�o.tt�|d�� p.t�|�dk VqdSrr)�hasattrrVr r1�r|�instancerZr[r��s� z2_ProtocolMeta.__instancecheck__..) r r3rr�r"rr0r�r�r;r�r;r[r��s � ��z_ProtocolMeta.__instancecheck__)rbr^r_r�r�rZrZr�r[r9�sr9cs(eZdZdZdZdZ�fdd�Z�ZS)rrZTFcs�t�j||��j�dd�s2tdd��jD���_�fdd�}d�jkrN|�_�jsXdS�jD]F}|tt fks^|j t kr�|j t |j ks^t |t �r�|js^td|��q^t�_dS) Nr"Fcss|]}|tkVqdSrr)rrrZrZr[r�)sz-Protocol.__init_subclass__..cs��j�dd�stSt�dd�s0t�r(tStd��t��sJt�rBtStd��t|t�s\td��t ��D]v}|j D]b}||jkr�|j|dkr�tSqdt|di�}t|t j j �rn||krnt|t�rn|jrnqdqntSqddS) Nr"Fr$zLInstance and class checks can only be used with @runtime_checkable protocolsz._proto_hookr(z7Protocols can only inherit from other protocols, got %r)r�r�r r�rrr"r(rr r^�_PROTO_WHITELISTrbrrTr4r�)r|r�rr=r!r�r2r[r�$s, &   �����zProtocol.__init_subclass__)rbr^r_r�r"r$r�r�rZrZr�r[rs)� metaclasscCs&t|t�r|jstd|��d|_|S)NzB@runtime_checkable can be only applied to protocol classes, got %rT)rr r"rTr$r2rZrZr[rKds �cCs|SrrrZ)�typrrZrZr[rA}sc Cs�z |j}Wntk r"iYSX|j}|j}|d|�}|jpDd}|j}|rXt|�ni}|t|�}t||d�|�D]\}} | ||<qz|S)NrZ) �__code__r�� co_argcount� co_varnames� __defaults__�__kwdefaults__r�r{�zip) r�r�Z pos_countZ arg_names�defaultsZ kwdefaultsr�Z pos_offsetr��valuerZrZr[� _get_defaults�s      rIc Cs�t|dd�riSt|t�r�i}t|j�D]z}|dkrDtj|jj}n|}|j� di�}|� �D]B\}}|dkrvtd�}t|t �r�t |dd�}t |||�}|||<q^q(|S|dkr�t|tj�r�|j}n"|} t| d�r�| j} q�t| di�}|dkr�|}n|dk�r|}t|dd�}|dk�r6t|t��r(iStd�|���t|�} t|�}|� �D]d\}}|dk�rhtd�}t|t ��r|t |�}t |||�}|| k�r�| |dk�r�t|}|||<�qN|S)N�__no_type_check__r&Fr�� __wrapped__� __globals__z1{!r} is not a module, class, method, or function.)r rPrO�reversedr*r��modulesr^r r��itemsrQr r�r`� ModuleTyper:rK�_allowed_typesrT�formatrIr�r) rdr�r�Zhintsr!Z base_globals�annr�rHZnsobjrGrZrZr[rE�s^             �    cCs t|t�r|jS|tkrtSdSrr)rPrRrSr )rxrZrZr[rD�s  cCsRt|t�rN|jsN|j}t|�tjjkrJ|dtk rJt |dd��|df}|SdS)Nrr�rZ) rPrRrmrtrDrrrr�rs)rxr�rZrZr[rC s cCs�t|t�rt|j��}|j��D]"\}}||j|fkr|�|�q|��D](}t|tj �r`d|_ t|t�rJt |�qJz d|_ Wnt k r�YnX|S)NT) rPrOr �copyrOr�pop�valuesr`rarJrGrT)rWZ arg_attrsr�rrdrZrZr[rGs        cst����fdd��}|S)Ncs�||�}t|�}|Srr)rG)r�r�r��� decoratorrZr[�wrapped_decorator@s z2no_type_check_decorator..wrapped_decorator)r�r�)rXrYrZrWr[rH9scOs td��dS)Nz�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.)�NotImplementedErrorr�rZrZr[�_overload_dummyIs�r[cCstSrr)r[)r�rZrZr[rJRscCs|SrrrZ)�frZrZr[rBos�T�KT�VT�T_co)r��V_co�VT_co�T_contra)r��CT_co)r�r�cCst||d|d�S)NT)r�r�)rR)r�r�r�rZrZr[�_alias�srerZ)r�a�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. F)r�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, ...]. )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. c@s"eZdZdZeed�dd��ZdS)r2rZ��returncCsdSrrrZr�rZrZr[�__int__�szSupportsInt.__int__N)rbr^r_r�r�intrhrZrZrZr[r2�sc@s"eZdZdZeed�dd��ZdS)r0rZrfcCsdSrrrZr�rZrZr[� __float__szSupportsFloat.__float__N)rbr^r_r�r�floatrjrZrZrZr[r0�sc@s"eZdZdZeed�dd��ZdS)r/rZrfcCsdSrrrZr�rZrZr[� __complex__ szSupportsComplex.__complex__N)rbr^r_r�r�complexrlrZrZrZr[r/sc@s"eZdZdZeed�dd��ZdS)r.rZrfcCsdSrrrZr�rZrZr[� __bytes__szSupportsBytes.__bytes__N)rbr^r_r�r�bytesrnrZrZrZr[r.sc@s"eZdZdZeed�dd��ZdS)r1rZrfcCsdSrrrZr�rZrZr[� __index__szSupportsIndex.__index__N)rbr^r_r�rrirprZrZrZr[r1sc@s"eZdZdZeed�dd��ZdS)r-rZrfcCsdSrrrZr�rZrZr[�__abs__(szSupportsAbs.__abs__N)rbr^r_r�rr`rqrZrZrZr[r-#sc@s&eZdZdZedeed�dd��ZdS)r3rZr)�ndigitsrgcCsdSrrrZ)r�rrrZrZr[� __round__2szSupportsRound.__round__N)r)rbr^r_r�rrir`rsrZrZrZr[r3-sc std��fdd�|D�}t�|dd�|D��}t|�|_|_zt�d�j�dd�|_ Wnt t fk rnYnX|S)NzDNamedTuple('Name', [(f0, t0), (f1, t1), ...]); each t must be a typecsg|]\}}|t|��f�qSrZr��rg�nrhr�rZr[rk9sz!_make_nmtuple..cSsg|] \}}|�qSrZrZrtrZrZr[rk:sr�rbr�) r� namedtupler�r&� _field_typesr�r�r�r�r^r�r�)r�r`�nm_tplrZr�r[� _make_nmtuple7sry) r�r�r��__getnewargs__�_fields�_field_defaultsrw�_make�_replace�_asdictZ_source)r^rbr&cseZdZ�fdd�Z�ZS)�NamedTupleMetac s�|�dd�rt��||||�S|�di�}t||���}g}i}|D]H}||krl||} |�| �| ||<qD|rDtdj|d�|� ��d���qDt |�|j_ t |�|j_ ||_|D]<} | tkr�td| ��q�| tkr�| |jkr�t|| || �q�|S)Nr�Fr&zXNon-default namedtuple field {field_name} cannot follow default field(s) {default_names}r�)� field_nameZ default_namesz&Cannot overwrite NamedTuple attribute )r�r�r�ryrOrlrTrRr�r+r�r&rprDr|� _prohibitedr�rmr{r) r|�typenamer �nsr`rxrGZ defaults_dictr�Z default_value�keyr�rZr[r�Os2     �   zNamedTupleMeta.__new__)rbr^r_r�r�rZrZr�r[r�Msr�c@seZdZdZdd�Zde_dS)r=TcOs�|s td��|^}}|r"|^}}n4d|krN|�d�}ddl}|jdtdd�ntd��|r�z |\}Wq�tk r�tdt|�d�d ��d�Yq�Xnr�r&z?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typecsi|]\}}|t|���qSrZr�)rgrurxr�rZr[� �sz*_TypedDictMeta.__new__..r�) r�r�r�r�r�r�r�rO�updater r&r:r�)r|r�r r�r�Ztp_dictZannsr!r�r�r[r��s   z_TypedDictMeta.__new__)T)rbr^r_r�r�r�r�r�rZrZr�r[r��sr�c@s eZdZdS)r>Nr#rZrZrZr[r>�scCsdd�}||_||_|S)NcSs|SrrrZ)�xrZrZr[�new_typeszNewType..new_type)rbZ __supertype__)r�rxr�rZrZr[rF sc@s�eZdZdZeeed�dd���Zeeed�dd���Zedd�dd ��Z eee d�d d ���Z ee d�d d ��Z edd�dd��Zee d�dd��Zed6e ed�dd��Zee d�dd��Zed7e ed�dd��Zed8e eed�dd��Zed9e e e d�d d!��Zee d�d"d#��Zee d�d$d%��Zed:e e d&�d'd(��Zee d�d)d*��Zeee d+�d,d-��Zeeedd.�d/d0��Zed1d�d2d3��Zedd�d4d5��ZdS);�IOrZrfcCsdSrrrZr�rZrZr[�mode=szIO.modecCsdSrrrZr�rZrZr[r�BszIO.nameNcCsdSrrrZr�rZrZr[�closeGszIO.closecCsdSrrrZr�rZrZr[�closedKsz IO.closedcCsdSrrrZr�rZrZr[�filenoPsz IO.filenocCsdSrrrZr�rZrZr[�flushTszIO.flushcCsdSrrrZr�rZrZr[�isattyXsz IO.isattyr�)rurgcCsdSrrrZ)r�rurZrZr[�read\szIO.readcCsdSrrrZr�rZrZr[�readable`sz IO.readable)�limitrgcCsdSrrrZ)r�r�rZrZr[�readlinedsz IO.readline)�hintrgcCsdSrrrZ)r�r�rZrZr[� readlineshsz IO.readlinesr)�offset�whencergcCsdSrrrZ)r�r�r�rZrZr[�seeklszIO.seekcCsdSrrrZr�rZrZr[�seekablepsz IO.seekablecCsdSrrrZr�rZrZr[�telltszIO.tell)�sizergcCsdSrrrZ)r�r�rZrZr[�truncatexsz IO.truncatecCsdSrrrZr�rZrZr[�writable|sz IO.writable��srgcCsdSrrrZ�r�r�rZrZr[�write�szIO.write)�linesrgcCsdSrrrZ)r�r�rZrZr[� writelines�sz IO.writelinesz IO[AnyStr]cCsdSrrrZr�rZrZr[� __enter__�sz IO.__enter__cCsdSrrrZ)r�rOrH� tracebackrZrZr[�__exit__�sz IO.__exit__)r�)r�)r�)r)N)rbr^r_r��propertyrrQr�r�r�r�r�rir�r�r�r@r�r�r�r9r�r�r�r�r�r�r�r�r�r�rZrZrZr[r�.sX r�c@s>eZdZdZeeeefed�dd��Z edd�dd��Z dS) �BinaryIOrZr�cCsdSrrrZr�rZrZr[r��szBinaryIO.writerfcCsdSrrrZr�rZrZr[r��szBinaryIO.__enter__N) rbr^r_r�rrro� bytearrayrir�r�rZrZrZr[r��s r�c@s�eZdZdZeeed�dd���Zeeed�dd���Z eee ed�dd���Z eee d�d d ���Z eeed�d d ���Zedd�d d��ZdS)�TextIOrZrfcCsdSrrrZr�rZrZr[�buffer�sz TextIO.buffercCsdSrrrZr�rZrZr[�encoding�szTextIO.encodingcCsdSrrrZr�rZrZr[�errors�sz TextIO.errorscCsdSrrrZr�rZrZr[�line_buffering�szTextIO.line_bufferingcCsdSrrrZr�rZrZr[�newlines�szTextIO.newlinescCsdSrrrZr�rZrZr[r��szTextIO.__enter__N)rbr^r_r�r�rr�r�rQr�rr�r�r�rr�r�rZrZrZr[r��s$r�c@s"eZdZdddgZeZeZeZdS)�ior�r�r�N)rbr^r_�__all__r�r�r�rZrZrZr[r��s r�z.ioc@seZdZddgZeZeZdS)�re�Pattern�MatchN)rbr^r_r�r�r�rZrZrZr[r��sr�z.re)T)NN)T)N)�rrrrZcollections.abcr8r�rr�Z stdlib_rer�r`rrrr�r\rerqrvr~r�r�r�r�r�r�rUrrIr r rrr r rr�r�rRrr r�r�Z_TYPING_INTERNALSZ_SPECIAL_NAMESr,r0r3r4r5r>r9rrKrArIra�BuiltinFunctionType� MethodTyperPrQrErDrCrGrHr[rJrBr]r^r_r`rarbrcrOrdrorQr@rerr%r(r'r&rrr,r#rr)rr'r;rr!rrr"r rrprrsr9r�r6r�r�r<rrrr$r6rr7r+r�r7r�r8r:r5r4r?r*rr2r0r/r.r1r-r3ryr�rmr�r=r�r�r�r�r>rFrLrMr�r�r�r�rbrNr�r�rZrZrZr[�s&�X !   I� � �����2a� /[���� b � V       � �     �       @+c#