a �DOg�,�@sddlmZmZddlZddlZddlZddlZddlZddlZ ddl Z ddl Z ddl m Z m Z mZmZgd�Zd�dd�dd�Zd�dd�d d �Zd d �Zdd�Zdd�Zdd�Zdd�Zdd�ZgZd�dd�dd�Ze�fdd�ZGdd�d�ZGdd �d �ZGd!d"�d"ed d#�ZGd$d%�d%ed d#�Z ed&d'��Z!ed(d)��Z"ed*d+��Z#ed,d-��Z$ed.d/��Z%ed0d1��Z&e ed d�d2d3���Z'Gd4d5�d5ed d#�Z(Gd6d7�d7eed d#�Z)d8d9�Z*Gd:d;�d;ed d#�Z+Gdd?�d?e+d d#�Z-Gd@dA�dAe,d d#�Z.GdBdC�dCe-d d#�Z/GdDdE�dEe-d d#�Z0GdFdG�dGe,d d#�Z1dHdI�Z2GdJdK�dKe,d d#�Z3GdLdM�dM�Z4GdNdO�dO�Z5GdPdQ�dQ�Z6gdR�Z7gdS�Z8e7e8dTgZ9dUdV�Z:dWdX�Z;dYdZ�ZGdadb�dbe�Z?Gdcdd�dde4e?de�Z@Gdfdg�dge,d d#�ZAGdhdi�di�ZBdjdk�ZCdldm�ZDdndo�ZEe jFe jGe jHe jIe e efZJd�dpdq�ZKdrds�ZLdtdu�ZMdvdw�ZNdxdy�ZOdzd{�ZPd|d}�ZQd~d�ZRd�d��ZSe)d��ZTe)d��ZUe)d��ZVe)d�d d��ZWe)d�d d��ZXe)d�d d��ZYe)d�d d��ZZe)d�d e[d��Z\e)d�e]e^�Z_e-Z`e`ejjad�Zae`ejjbd��Zbe`ejjcd��Zce`ejjdd��Zde`ejjed��Zee`ejjfd��Zfe`ejjgd��Zge`ejjhd��Zhe`ejjid�Zie`ejjjd��Zje`ejjkd��Zke/ejjld��Zld�el_me`ejjnd�d�d��Zoe`ejjpd��Zpe`ejjqd��Zqe`ejjrd��Zre`ejjsd��Zse`ejjtd��Zte`ejjud�Zue0evd�dd�d��Zwd�ew_me`exd�dd�d��Zye`ejzd�d�d��Z{e`e|d�dd�d��Zne`ed�dd�d��Z}e`ejj~d��Z~e`ejjd��Ze`ejj�d��Z�e`ejj�d��Z�e`ej�d�d�d��Z�e`ej�d�d�d��Z�e`e�d�dd�d��Z�e`ej�d�d�d��Z�e`ej�d��Z�e`ej�d��Z�e`ej�d��Z�e`ejj�d��Z�e`ejj�d��Z�e`e[d�dd�d��Z�d�e�_meCGd�d��d�e@��Z�eCGd�d��d�e@��Z�eCGd�d��d�e@��Z�eCGd�d��d�e@��Z�eCGd�d��d�e@��Z�eCGd�d��d�e@eW��Z�eCGd�d��d�e@eW��Z�d�d�d��Z�ehd���Z�ehd���Z�Gd�d��d�e[�Z�d�d�d��Z�e[��e�d�d�i�Z�d�d��Z�e�e�_�Gd�d��d�e[�Z�d�d d��d�d��Z�e[��e�d�d�i�Z�d�d��e�_�d�dÄZ�e^Z�dZ�Gd�dńd�e4e_�Z�Gd�dDŽd�e�e]�Z�Gd�dɄd�e�e^�Z�Gd�d˄d˃Z�e�d�e�_�e�e j�e�j�<e`e j�d��Z�e`e j�d��Z�Gd�d΄d΃Ze�d�e_�ee j�ej�<dS)��)�abstractmethod�ABCMetaN)�WrapperDescriptorType�MethodWrapperType�MethodDescriptorType� GenericAlias)M� Annotated�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�BinaryIO�IO�Match�Pattern�TextIO�AnyStr�cast�final�get_args� get_origin�get_type_hints�NewType� no_type_check�no_type_check_decorator�NoReturn�overload�runtime_checkable�Text� TYPE_CHECKINGF��allow_special_formscCs,|durtd�St|t�r(t|||d�S|S)N)�module�is_class)�type� isinstance�strr )�argrWrV�r]�/usr/lib64/python3.9/typing.py� _type_convert�s  r_TcCs�ttf}|s$|tf7}|r$|tf7}t|||d�}t|t�rT|j|vrTt|�d���|t t tfvrf|St|t �s||ttfvr�td|�d���t|t t tf�r�|St|�s�t|�d|d�d���|S)N)rWrVz is not valid as type argumentzPlain z Got z.100�.)rrr r r_rZ� _GenericAlias� __origin__� TypeErrorr rP� _SpecialFormrYrr �callable)r\�msg� is_argumentrWrV�invalid_generic_formsr]r]r^� _type_check�s&    �ricCsft|tj�rt|�St|t�r@|jdkr.|jS|j�d|j��S|durLdSt|tj�r^|jSt|�S)N�builtinsr`.z...) rZ�typesr�reprrY� __module__� __qualname__� FunctionType�__name__)�objr]r]r^� _type_repr�s    rrcsZg�|D]H}t|t�r(|�vr(��|�t|ttf�r���fdd�|jD��qt��S)Ncsg|]}|�vr|�qSr]r]��.0�t��tvarsr]r^� ��z&_collect_type_vars..)rZr�appendrar�extend�__parameters__�tuple)rkrur]rvr^�_collect_type_vars�s r~c CsR|st|�d���t|�}||krNtd||kr2dnd�d|�d|�d|����dS)Nz is not a generic classzToo �many�fewz parameters for z ; actual z , expected )rc�len)�cls� parameters�elen�alenr]r]r^�_check_generic�s��r�cCsJt|�}t|�t|�krFg}|D] }||vr |�|�|�|�q |}|S�N)�setr�rz�remove)�params� all_params� new_paramsrur]r]r^� _deduplicate�s  r�cCsrg}|D]\}t|t�r$|�|j�qt|t�rZt|�dkrZ|dturZ|�|dd��q|�|�qtt|��S)Nr�) rZ�_UnionGenericAliasr{�__args__r}r�rrzr��r�r��pr]r]r^�_remove_dups_flatten�s " r�cCs8g}|D]&}t|t�r$|�|j�q|�|�qt|�Sr�)rZ�_LiteralGenericAliasr{r�rzr}r�r]r]r^�_flatten_literal_params�s   r���typedcs �fdd�}|dur||�S|S)Ncs8tj�d����t��j�t�����fdd��}|S)Nr�cs2z�|i|��WSty"Yn0�|i|��Sr��rc��args�kwds��cached�funcr]r^�inners  z+_tp_cache..decorator..inner)� functools� lru_cache� _cleanupsrz� cache_clear�wraps)r�r�r�r�r^� decorator s  z_tp_cache..decoratorr])r�r�r�r]r�r^� _tp_caches r�cstt|t�r|�����St|ttf�rpt���fdd�|jD��}||jkrP|St|t�rft|j|�S|�|�S|S)Nc3s|]}t|����VqdSr�)� _eval_type�rt�a��globalns�localns�recursive_guardr]r^� &ryz_eval_type..) rZr � _evaluaterarr}r�rb� copy_with)rur�r�r��ev_argsr]r�r^r�s     r�c@seZdZdZdd�ZdS)�_Final)� __weakref__cOsd|vrtd��dS)N�_rootz&Cannot subclass special typing classesr���selfr�r�r]r]r^�__init_subclass__5sz_Final.__init_subclass__N)rprmrn� __slots__r�r]r]r]r^r�0sr�c@s eZdZdZdd�Zdd�ZdS)� _Immutabler]cCs|Sr�r]�r�r]r]r^�__copy__=sz_Immutable.__copy__cCs|Sr�r])r��memor]r]r^� __deepcopy__@sz_Immutable.__deepcopy__N)rprmrnr�r�r�r]r]r]r^r�9sr�c@sTeZdZdZdd�Zdd�Zdd�Zdd �Zd d �Zd d �Z dd�Z e dd��Z dS)rd)�_name�__doc__�_getitemcCs||_|j|_|j|_dSr�)r�rpr�r�)r��getitemr]r]r^�__init__Isz_SpecialForm.__init__cCstd|����dS)NzCannot subclass r�)r��basesr]r]r^�__mro_entries__Nsz_SpecialForm.__mro_entries__cCs d|jS�N�typing.�r�r�r]r]r^�__repr__Qsz_SpecialForm.__repr__cCs|jSr�r�r�r]r]r^� __reduce__Tsz_SpecialForm.__reduce__cOstd|����dS)NzCannot instantiate r�r�r]r]r^�__call__Wsz_SpecialForm.__call__cCst|�d���dS)Nz! cannot be used with isinstance()r��r�rqr]r]r^�__instancecheck__Zsz_SpecialForm.__instancecheck__cCst|�d���dS)Nz! cannot be used with issubclass()r��r�r�r]r]r^�__subclasscheck__]sz_SpecialForm.__subclasscheck__cCs |�||�Sr�)r��r�r�r]r]r^� __getitem__`sz_SpecialForm.__getitem__N) rprmrnr�r�r�r�r�r�r�r�r�r�r]r]r]r^rdFsrd)r�c@seZdZdd�ZdS)�_LiteralSpecialFormcCs"t|t�s|f}|j|g|�R�Sr�)rZr}r�r�r]r]r^r�fs z_LiteralSpecialForm.__getitem__N)rprmrnr�r]r]r]r^r�esr�cCst|�d���dS�Nz is not subscriptabler�r�r]r]r^r ls r cCst|�d���dSr�r�r�r]r]r^rPzs rPcCst||�d��}t||f�S�Nz accepts only single type.�rira�r�r��itemr]r]r^r �sr cCst||�d��}t||f�Sr�r�r�r]r]r^r �sr cs`|dkrtd��t|t�s |f}d�t�fdd�|D��}t|�}t|�dkrV|dSt||�S)Nr]z Cannot take a Union of no types.z)Union[arg, ...]: each arg must be a type.c3s|]}t|��VqdSr��ri�rtr��rfr]r^r��ryzUnion..r�r)rcrZr}r�r�r�r�r]r�r^r�s  rcCs t||�d��}t|td�fS)Nz requires a single type.)rirrY)r�r�r\r]r]r^r�srcGsHt|�}z"tdd�ttt|���D��}Wnty<Yn0t||�S)Ncss|]\}}|VqdSr�r])rtr��_r]r]r^r��ryzLiteral..)r�r}r��list�_value_and_type_iterrcr�r�r]r]r^r�s " rc@s@eZdZdZddd�dd�Zdd �Zd d �Zd d �Zdd�ZdS)r )�__forward_arg__�__forward_code__�__forward_evaluated__�__forward_value__�__forward_is_argument__�__forward_is_class__�__forward_module__TNF)rXcCsxt|t�std|����zt|dd�}Wn tyHtd|����Yn0||_||_d|_d|_||_ ||_ ||_ dS)Nz*Forward reference must be a string -- got z�evalz/Forward reference must be an expression -- got F) rZr[rc�compile� SyntaxErrorr�r�r�r�r�r�r�)r�r\rgrWrX�coder]r]r^r� s  zForwardRef.__init__cCs�|j|vr|S|jr||ur�|dur6|dur6i}}n|durD|}n |durP|}|jdurrttj�|jd�d|�}tt|j ||�d|j |j d�}t |||||jhB�|_ d|_|j S)N�__dict__z*Forward references must evaluate to types.)rgrVT)r�r�r��getattr�sys�modules�getrir�r�r�r�r�r�)r�r�r�r��type_r]r]r^r�s0   � ��zForwardRef._evaluatecCsJt|t�stS|jr2|jr2|j|jko0|j|jkS|j|jkoH|j|jkSr�)rZr �NotImplementedr�r�r�r��r��otherr]r]r^�__eq__5s    �  �zForwardRef.__eq__cCst|j|jf�Sr�)�hashr�r�r�r]r]r^�__hash__>szForwardRef.__hash__cCsd|j�d�S)Nz ForwardRef(�))r�r�r]r]r^r�AszForwardRef.__repr__)TN) rprmrnr�r�r�r�r�r�r]r]r]r^r s  r c@s2eZdZdZdddd�dd�Zdd�Zd d �ZdS) r)rp� __bound__�__constraints__� __covariant__�__contravariant__r�NF)�bound� covariant� contravariantc s�||_|r|rtd��t|�|_t|�|_|r>|dur>td��|rVt|�dkrVtd��d�t�fdd�|D��|_|r�t |d�|_ nd|_ zt � d�j �d d �}Wnttfy�d}Yn0|d kr�||_dS) Nz"Bivariant types are not supported.z-Constraints cannot be combined with bound=...r�z"A single constraint is not allowedz:TypeVar(name, constraint, ...): constraints must be types.c3s|]}t|��VqdSr�r�rsr�r]r^r��ryz#TypeVar.__init__..zBound must be a type.rp�__main__�typing)rp� ValueError�boolr�r�rcr�r}r�rir�r�� _getframe� f_globalsr��AttributeErrorrm)r��namer�r�r�� constraints�def_modr]r�r^r�ts(    zTypeVar.__init__cCs&|jr d}n|jrd}nd}||jS)N�+�-�~)r�r�rp)r��prefixr]r]r^r��s zTypeVar.__repr__cCs|jSr�)rpr�r]r]r^r��szTypeVar.__reduce__)rprmrnr�r�r�r�r]r]r]r^rEs ,�  rcCs|�d�o|�d�S)N�__)� startswith�endswith)�attrr]r]r^� _is_dunder�srcsTeZdZddd�dd�Zdd�Zdd �Zd d �Z�fd d �Zdd�Zdd�Z �Z S)�_BaseGenericAliasTN��instrcCs||_||_||_d|_dSr�)�_instr�rbr�)r��originrrr]r]r^r��sz_BaseGenericAlias.__init__cOsT|js"td|j�d|jj�d���|j|i|��}z ||_WntyNYn0|S)NzType z cannot be instantiated; use z () instead)rrcr�rbrp�__orig_class__r)r�r��kwargs�resultr]r]r^r��s �   z_BaseGenericAlias.__call__cCsdg}|j|vr|�|j�|�|�}||dd�D]}t|t�sLt|t�r4q\q4|�t�t|�S)Nr�)rbrz�indexrZr� issubclassrr})r�r��res�i�br]r]r^r��s    z!_BaseGenericAlias.__mro_entries__cCs*d|jvrt|�st|j|�St|��dS)Nrb)r�rr�rbr)r�r r]r]r^� __getattr__�s z_BaseGenericAlias.__getattr__cs2t|�s|dvr t��||�nt|j||�dS)N)r�r�_nparams)r�super� __setattr__�setattrrb)r�r �val�� __class__r]r^r�sz_BaseGenericAlias.__setattr__cCs|�t|��Sr�)r�rYr�r]r]r^r��sz#_BaseGenericAlias.__instancecheck__cCs td��dS)NzBSubscripted generics cannot be used with class and instance checksr�r�r]r]r^r��sz#_BaseGenericAlias.__subclasscheck__) rprmrnr�r�r�rrr�r�� __classcell__r]r]r"r^r�s    rcsdeZdZddd��fdd� Zdd�Zdd �Zed d ��Zd d �Zdd�Z dd�Z �fdd�Z �Z S)raTNrcsPt�j|||d�t|t�s"|f}tdd�|D��|_t|�|_|sL|j|_dS)Nrcss*|]"}|turdn|turdn|VqdS).r]N)�_TypingEllipsis� _TypingEmptyr�r]r]r^r��s�  z)_GenericAlias.__init__..)rr�rZr}r�r~r|rm)r�rr�rrr"r]r^r��s �  z_GenericAlias.__init__cCs&t|t�stS|j|jko$|j|jkSr�)rZrar�rbr�r�r]r]r^r��s    �z_GenericAlias.__eq__cCst|j|jf�Sr�)r�rbr�r�r]r]r^r��sz_GenericAlias.__hash__cs�|jttfvrtd|����t|t�s,|f}d�t�fdd�|D��}t||t|j��t t |j|���g}|j D]X}t|t �r��|}n6t|t tf�r�|j}|r�t�fdd�|D��}||}|�|�qr|�t|��S)Nz%Cannot subscript already-subscripted �*Parameters to generic types must be types.c3s|]}t|��VqdSr�r�r�r�r]r^r��ryz,_GenericAlias.__getitem__..c3s|]}�|VqdSr�r])rt�x)�substr]r^r� ry)rbrrrcrZr}r�r�r|�dict�zipr�rrarrzr�)r�r��new_argsr\� subparams�subargsr])rfr)r^r��s&     z_GenericAlias.__getitem__cCs|j|j||j|jd�S�N)rr)r#rbr�r�r�r�r]r]r^r�sz_GenericAlias.copy_withcCsB|jrd|j}n t|j�}d�dd�|jD��}|�d|�d�S)Nr��, cSsg|] }t|��qSr]�rrr�r]r]r^rxryz*_GenericAlias.__repr__..�[�])r�rrrb�joinr�)r�rr�r]r]r^r�s   z_GenericAlias.__repr__cCsR|jrt�|j}n|j}t|j�}t|�dkrDt|dt�sD|\}tj||ffS)Nr�r) r��globalsrbr}r�r�rZ�operatorr�)r�rr�r]r]r^r�s z_GenericAlias.__reduce__csh|jrt��|�S|jtur`t|vr(dS|�|�}||dd�D]}t|t�rB||urBdSqB|jfS)Nr]r�) r�rr�rbrrrrZr)r�r�rrr"r]r^r�$s   z_GenericAlias.__mro_entries__) rprmrnr�r�r�r�r�r�r�r�r�r$r]r]r"r^ra�s   racsTeZdZddd��fdd� Zedd��Zdd �Zd d �Z�fd d �Zdd�Z �Z S)�_SpecialGenericAliasTNrcs^|dur|j}t�j|||d�||_|jdkrBd|j�d�|_nd|j�d|j�d�|_dS)NrrjzA generic version of r`)rprr�rrmrnr�)r�r�nparamsrrr"r]r^r�6s z_SpecialGenericAlias.__init__csBt|t�s|f}d�t�fdd�|D��}t|||j�|�|�S)Nr'c3s|]}t|��VqdSr�r�r�r�r]r^r�Eryz3_SpecialGenericAlias.__getitem__..)rZr}r�rr�r0r]r�r^r�@s  z _SpecialGenericAlias.__getitem__cCst|j||j|jd�Sr/)rarbr�rr0r]r]r^r�Is�z_SpecialGenericAlias.copy_withcCs d|jSr�r�r�r]r]r^r�Msz_SpecialGenericAlias.__repr__cs:t|t�rt|j|j�St|t�s.t||j�St��|�Sr�)rZr8rrbrarr�r�r"r]r^r�Ps    z&_SpecialGenericAlias.__subclasscheck__cCs|jSr�r�r�r]r]r^r�Wsz_SpecialGenericAlias.__reduce__) rprmrnr�r�r�r�r�r�r�r$r]r]r"r^r85s   r8cs$eZdZ�fdd�Zdd�Z�ZS)�_CallableGenericAliascs\t|j�dkr&|jdtur&t���Sdd�dd�|jdd�D���dt|jd��d �S) N�rztyping.Callable[[r1cSsg|] }t|��qSr]r2r�r]r]r^rxaryz2_CallableGenericAlias.__repr__..�����z], r4)r�r��Ellipsisrr�r5rrr�r"r]r^r�\s � �z_CallableGenericAlias.__repr__cCsD|j}t|�dkr|ddus6t|dd��|df}tjt|ffS)Nr;r.r<)r�r�r�r7r�r �r�r�r]r]r^r�dsz _CallableGenericAlias.__reduce__)rprmrnr�r�r$r]r]r"r^r:[s r:c@s(eZdZdd�Zdd�Zedd��ZdS)� _CallableTypecCst|j||j|jd�Sr/)r:rbr�rr0r]r]r^r�ls�z_CallableType.copy_withcCsPt|t�rt|�dkrtd��|\}}t|t�r>t|�|f}n||f}|�|�S)Nr;z6Callable must be used as Callable[[arg, ...], result].)rZr}r�rcr��__getitem_inner__)r�r�r�rr]r]r^r�ps z_CallableType.__getitem__cCsb|\}}d}t||�}|tur,|�t|f�St|t�s<|f}tdd�|D��}||f}|�|�S)Nz.Callable[args, result]: result must be a type.css|]}t|�VqdSr�)r_)rtr\r]r]r^r��ryz2_CallableType.__getitem_inner__..)rir=r�r%rZr})r�r�r�rrfr]r]r^r@~s   z_CallableType.__getitem_inner__N)rprmrnr�r�r�r@r]r]r]r^r?ksr?c@seZdZedd��ZdS)� _TupleTypecs�|dkr|�tf�St|t�s$|f}t|�dkr\|ddur\d�t|d��}|�|tf�Sd�t�fdd �|D��}|�|�S) Nr]r;r�.z Tuple[t, ...]: t must be a type.rz*Tuple[t0, t1, ...]: each t must be a type.c3s|]}t|��VqdSr�r�r�r�r]r^r��ryz)_TupleType.__getitem__..)r�r&rZr}r�rir%)r�r�r�r]r�r^r��s  z_TupleType.__getitem__N)rprmrnr�r�r]r]r]r^rA�srAcs4eZdZdd�Zdd�Zdd�Z�fdd�Z�ZS) r�cCst|Sr�)rr0r]r]r^r��sz_UnionGenericAlias.copy_withcCs"t|t�stSt|j�t|j�kSr�)rZr�r�r�r�r�r]r]r^r��s z_UnionGenericAlias.__eq__cCstt|j��Sr�)r�� frozensetr�r�r]r]r^r��sz_UnionGenericAlias.__hash__csd|j}t|�dkrZ|dtd�ur6dt|d��d�S|dtd�urZdt|d��d�St���S)Nr;rztyping.Optional[r�r4)r�r�rYrrrr�r>r"r]r^r��s z_UnionGenericAlias.__repr__)rprmrnr�r�r�r�r$r]r]r"r^r��sr�cCsdd�|D�S)Ncss|]}|t|�fVqdSr�)rYr�r]r]r^r��ryz'_value_and_type_iter..r])r�r]r]r^r��sr�c@seZdZdd�Zdd�ZdS)r�cCs*t|t�stStt|j��tt|j��kSr�)rZr�r�r�r�r�r�r]r]r^r��s z_LiteralGenericAlias.__eq__cCsttt|j���Sr�)r�rBr�r�r�r]r]r^r��sz_LiteralGenericAlias.__hash__N)rprmrnr�r�r]r]r]r^r��sr�cs0eZdZdZdZedd��Z�fdd�Z�ZS)rr]Fcs�t|t�s|f}|s.|tur.td|j�d���d�t�fdd�|D��}|ttfvr�tdd�|D��sxtd|j�d���t t |��t |�kr�td|j�d ���nt ||t |j ��t ||�S) NzParameter list to z[...] cannot be emptyr'c3s|]}t|��VqdSr�r�r�r�r]r^r��ryz,Generic.__class_getitem__..css|]}t|t�VqdSr�)rZrr�r]r]r^r��ryzParameters to z [...] must all be type variablesz[...] must all be unique)rZr}rrcrnrr�allrpr�r�r�r|ra)r�r�r]r�r^�__class_getitem__�s&   �  � �zGeneric.__class_getitem__c st�j|i|��g}d|jvr,t|jv}nt|jvo>|jdk}|rLtd��d|jv�rt|j�}d}|jD].}t |t �rl|j turl|dur�td��|j }ql|du�rt |�}t |��|�k�sd��fdd�|D��}d�dd�|D��} td |�d | �d ���|}t|�|_ dS) N�__orig_bases__rz!Cannot inherit from plain Genericz0Cannot inherit from Generic[...] multiple types.r1c3s|]}|�vrt|�VqdSr��r[rs��gvarsetr]r^r� ryz,Generic.__init_subclass__..css|]}t|�VqdSr�rF)rt�gr]r]r^r� ryzSome type variables (z) are not listed in Generic[r4)rr�r�rrE� __bases__rprcr~rZrarbr|r�r5r}) r�r�rrw�error�gvars�base�tvarset�s_vars�s_argsr"rGr^r��s<      ��   � zGeneric.__init_subclass__) rprmrnr�� _is_protocolr�rDr�r$r]r]r"r^r�s  rc@s eZdZdS)r&N�rprmrnr]r]r]r^r&sr&c@s eZdZdS)r%NrRr]r]r]r^r%sr%)r|rErrQ�_is_runtime_protocol) �__abstractmethods__�__annotations__r�r�r�rm�__new__r��__subclasshook__r�rD�_MutableMapping__markercCsrt�}|jdd�D]X}|jdvr$qt|di�}t|j���t|���D] }|�d�sJ|tvrJ|� |�qJq|S)Nr<)rrrU�_abc_) r��__mro__rpr�r�r��keysr �EXCLUDED_ATTRIBUTES�add)r��attrsrM� annotationsr r]r]r^�_get_protocol_attrs)s  r`cst�fdd�t��D��S)Nc3s|]}tt�|d��VqdSr�)rer��rtr �r�r]r^r�<ryz,_is_callable_members_only..)rCr`rbr]rbr^�_is_callable_members_only:srccOstt|�}|jrtd��|jtur$dS|jD]$}|j�dt�}|tur*||_qXq*tj|_|j|g|�Ri|��dS)Nz Protocols cannot be instantiatedr�) rYrQrcr��_no_init_or_replace_initrZr�r��object)r�r�rr�rM�initr]r]r^rd?s  rdc Cs4zt�d�jddvWSttfy.YdS0dS)N�rp)�abcr�T)r�rrrr�r]r]r]r^�_allow_reckless_class_cheks]sri) r r'rrr)rr%rr+r.�AbstractContextManager�AbstractAsyncContextManager)zcollections.abc� contextlibcseZdZ�fdd�Z�ZS)� _ProtocolMetacsVt�dd�rt��r$t�j��r$dS�jrJt��fdd�t��D��rJdSt����S)NrQFTc3s8|]0}t�|�o.tt�|d�� p.t�|�duVqdSr�)�hasattrrer�ra�r��instancer]r^r�}s� z2_ProtocolMeta.__instancecheck__..) r�rcrr#rQrCr`rr�ror"ror^r�us � ��z_ProtocolMeta.__instancecheck__)rprmrnr�r$r]r]r"r^rmrsrmcs(eZdZdZdZdZ�fdd�Z�ZS)rr]TFcs�t�j|i|���j�dd�s6tdd��jD���_�fdd�}d�jvrR|�_�js\dS�jD]F}|tt fvsb|j t vr�|j t |j vsbt |t �r�|jsbtd|��qbt�_dS) NrQFcss|]}|tuVqdSr�)r)rtrr]r]r^r��ryz-Protocol.__init_subclass__..cs��j�dd�stSt�dd�s0t�r(tStd��t��sJt�rBtStd��t|t�s\td��t ��D]v}|j D]b}||jvr�|j|dur�tSqdt|di�}t|t j j �rn||vrnt|t�rn|jrnqdqntSqddS) NrQFrSzLInstance and class checks can only be used with @runtime_checkable protocolsz._proto_hookrWz7Protocols can only inherit from other protocols, got %r)rr�r�r��anyrJrQrWrerrm�_PROTO_WHITELISTrprrcrdr�)r�r�rrrrMr"rbr^r��s, &   �����zProtocol.__init_subclass__)rprmrnr�rQrSr�r$r]r]r"r^r�sr)� metaclasscsDeZdZ�fdd�Zdd�Zdd�Zdd�Zd d �Zd d �Z�Z S) �_AnnotatedAliascs2t|t�r|j|}|j}t��||�||_dSr�)rZrv� __metadata__rbrr�)r�r�metadatar"r]r^r��s   z_AnnotatedAlias.__init__cCs|d}t||j�S)Nr)rvrw)r�r��new_typer]r]r^r��sz_AnnotatedAlias.copy_withcCs$d�t|j�d�dd�|jD���S)Nztyping.Annotated[{}, {}]r1css|]}t|�VqdSr�)rlr�r]r]r^r��ryz+_AnnotatedAlias.__repr__..)�formatrrrbr5rwr�r]r]r^r��s�z_AnnotatedAlias.__repr__cCstjt|jf|jffSr�)r7r�rrbrwr�r]r]r^r�s�z_AnnotatedAlias.__reduce__cCs&t|t�stS|j|jko$|j|jkSr�)rZrvr�rbrwr�r]r]r^r�s    �z_AnnotatedAlias.__eq__cCst|j|jf�Sr�)r�rbrwr�r]r]r^r� sz_AnnotatedAlias.__hash__) rprmrnr�r�r�r�r�r�r$r]r]r"r^rv�s  rvc@s,eZdZdZdd�Zedd��Zdd�ZdS) rr]cOs td��dS)Nz&Type Annotated cannot be instantiated.r��r�r�rr]r]r^rV2szAnnotated.__new__cCsNt|t�rt|�dkrtd��d}t|d|dd�}t|dd��}t||�S)Nr;zUAnnotated[...] should be used with at least two arguments (a type and an annotation).z$Annotated[t, ...]: t must be a type.rTrUr�)rZr}r�rcrirv)r�r�rfrrxr]r]r^rD5s zAnnotated.__class_getitem__cOstd�|j���dS)NzCannot subclass {}.Annotated)rcrzrmr{r]r]r^r�@s �zAnnotated.__init_subclass__N)rprmrnr�rVr�rDr�r]r]r]r^rs  rcCs&t|t�r|jstd|��d|_|S)NzB@runtime_checkable can be only applied to protocol classes, got %rT)rrrQrcrSrbr]r]r^rRFs �rRcCs|Sr�r])�typr!r]r]r^rH_srHc Cs�z |j}Wnty iYS0|j}|j}|d|�}|jpBd}|j}|rVt|�ni}|t|�}t||d�|�D]\}} | ||<qx|S)Nr]) �__code__r� co_argcount� co_varnames� __defaults__�__kwdefaults__r*r�r+) r�r�� pos_count� arg_names�defaults� kwdefaultsr� pos_offsetr�valuer]r]r^� _get_defaultsjs       r�c Cs�t|dd�riSt|t�r�i}t|j�D]|}|durDtj|jj}n|}|j� di�}|� �D]D\}} | durvtd�} t| t �r�t | ddd�} t | ||�} | ||<q^q(|r�|Sdd�|� �D�S|du�rt|tj�r�|j}n"|} t| d�r�| j} q�t| d i�}|du�r|}n|du�r|}t|dd�}|du�rRt|t��rDiStd �|���t|�} t|�}|� �D]t\}} | du�r�td�} t| t ��r�t | t|tj� dd�} t | ||�} || v�r�| |du�r�t| } | ||<�qj|�r�|Sd d�|� �D�S) N�__no_type_check__rUFT)rgrXcSsi|]\}}|t|��qSr]��_strip_annotations�rt�krur]r]r^� �ryz"get_type_hints..� __wrapped__� __globals__z1{!r} is not a module, class, method, or function.cSsi|]\}}|t|��qSr]r�r�r]r]r^r��ry)r�rZrY�reversedrZr�r�rmr�r��itemsr[r r�rk� ModuleTypernr��_allowed_typesrcrzr�r*r) rqr�r��include_extras�hintsrM� base_globals�annrr��nsobjr�r]r]r^rL�sf              �   �  rLcCs�t|t�rt|j�St|t�rJtdd�|jD��}||jkr@|S|�|�St|t�r�tdd�|jD��}||jkrv|St|j|�S|S)Ncss|]}t|�VqdSr�r�r�r]r]r^r��ryz%_strip_annotations..css|]}t|�VqdSr�r�r�r]r]r^r��ry) rZrvr�rbrar}r�r�r)ru� stripped_argsr]r]r^r��s        r�cCs2t|t�rtSt|ttf�r"|jS|tur.tSdSr�)rZrvrrrrbr)�tpr]r]r^rK�s rKcCsft|t�r|jf|jSt|ttf�rb|j}|jtjj ur^|dt ur^t |dd��|df}|SdS)Nrr<r]) rZrvrbrwrarr�rqrhr r=r�)r�rr]r]r^rJ s rJcCs�t|t�rt|j��}|j��D]"\}}||j|fvr|�|�q|��D](}t|tj �r`d|_ t|t�rJt |�qJz d|_ Wnt y�Yn0|S)NT) rZrYr��copyr�rJ�pop�valuesrkror�rNrc)r\� arg_attrsr r!rqr]r]r^rNs         rNcst����fdd��}|S)Ncs�|i|��}t|�}|Sr�)rN)r�r�r��r�r]r^�wrapped_decorator?sz2no_type_check_decorator..wrapped_decorator)r�r�)r�r�r]r�r^rO8srOcOs 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�r]r]r^�_overload_dummyHs�r�cCstSr�)r�)r�r]r]r^rQQsrQcCs|Sr�r])�fr]r]r^rInsrI�T�KT�VT�T_co)r��V_co�VT_co�T_contra)r��CT_co)r�r�rGr�rgr;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. r)rr<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, ...]. r;r8r=r>rr-r9r:ra�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)r4r]��returncCsdSr�r]r�r]r]r^�__int__�szSupportsInt.__int__N)rprmrnr�r�intr�r]r]r]r^r4�sr4c@s"eZdZdZeed�dd��ZdS)r2r]r�cCsdSr�r]r�r]r]r^� __float__�szSupportsFloat.__float__N)rprmrnr�r�floatr�r]r]r]r^r2�sr2c@s"eZdZdZeed�dd��ZdS)r1r]r�cCsdSr�r]r�r]r]r^� __complex__ szSupportsComplex.__complex__N)rprmrnr�r�complexr�r]r]r]r^r1sr1c@s"eZdZdZeed�dd��ZdS)r0r]r�cCsdSr�r]r�r]r]r^� __bytes__szSupportsBytes.__bytes__N)rprmrnr�r�bytesr�r]r]r]r^r0sr0c@s"eZdZdZeed�dd��ZdS)r3r]r�cCsdSr�r]r�r]r]r^� __index__szSupportsIndex.__index__N)rprmrnr�rr�r�r]r]r]r^r3sr3c@s"eZdZdZeed�dd��ZdS)r/r]r�cCsdSr�r]r�r]r]r^�__abs__'szSupportsAbs.__abs__N)rprmrnr�rr�r�r]r]r]r^r/"sr/c@s&eZdZdZedeed�dd��ZdS)r5r]r)�ndigitsr�cCsdSr�r])r�r�r]r]r^� __round__1szSupportsRound.__round__N)r)rprmrnr�rr�r�r�r]r]r]r^r5,sr5r]cCs@dd�|D�}dd�|D�}tj||||d�}||_|j_|S)NcSsg|] \}}|�qSr]r]�rt�nrur]r]r^rx7ryz!_make_nmtuple..cSs$i|]\}}|t|d|�d���qS)zfield z annotation must be a typer�r�r]r]r^r�8s�z!_make_nmtuple..�r�rW)rq� namedtuplerUrV)rrkrWr��fields�nm_tplr]r]r^� _make_nmtuple6s��r�> �_source�_fields�__getnewargs__�_maker�r�rV�_field_defaults�_replace�_asdict>rmrprUc@seZdZdd�ZdS)�NamedTupleMetac s���di�}g}|D]L}|�vr,|�|�q|rtd|�dt|�dkrJdnd�dd�|�����qt||���fd d �|D��d d �}�D]<}|tvr�td |��q�|t vr�||j vr�t ||�|�q�|S)NrUzNon-default namedtuple field z cannot follow default fieldr��s�� r1csg|] }�|�qSr]r])rtr���nsr]r^rxWryz*NamedTupleMeta.__new__..rmr�z&Cannot overwrite NamedTuple attribute ) r�rzrcr�r5r�r�� _prohibitedr�_specialr�r ) r��typenamer�r�rk� default_names� field_namer��keyr]r�r^rVJs*   ��  �zNamedTupleMeta.__new__N)rprmrnrVr]r]r]r^r�Hsr�c Ks`|dur|��}n |rtd��zt�d�j�dd�}WnttfyPd}Yn0t|||d�S)NzIEither list of fields or keywords can be provided to NamedTuple, not bothr�rpr��rW) r�rcr�rrr�rr�r�)r�r�rrWr]r]r^r?bs  r?cCst|�dkrtd��tfS)Nr�z5Multiple inheritance with NamedTuple is not supported)r�rc� _NamedTuple�r�r]r]r^�_namedtuple_mro_entries�s r�c@s&eZdZddd�ZeZdd�ZeZdS)�_TypedDictMetaTc s|D]}t|�turtd��qt�t|tf|��i}|�di�}t|���}d���fdd�|��D�}t�} t�} |D]@}|� |j �di��| � |j �dd��| � |j �dd��qx|� |�|r�| � |�n | � |�|�_ t | ��_ t | ��_t�d ��s |�_�S) NzHcannot inherit from both a TypedDict type and a non-TypedDict base classrUz?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typecs"i|]\}}|t|��jd��qS)r�)rirm)rtr�r��rf�tp_dictr]r^r��s�z*_TypedDictMeta.__new__..�__required_keys__r]�__optional_keys__� __total__)rYr�rcrVr*r�r�r[r��updater�rUrBr�r�rnr�) r�rr�r��totalrMr_�own_annotations�own_annotation_keys� required_keys� optional_keysr]r�r^rV�s6     �      z_TypedDictMeta.__new__cCs td��dS)Nz4TypedDict does not support instance and class checksr�)r�r�r]r]r^r��sz _TypedDictMeta.__subclasscheck__N)T)rprmrnrVr*r�r�r�r]r]r]r^r��s +r��r�c Ksj|dur|}n |rtd��dt|�i}zt�d�j�dd�|d<WnttfyXYn0t|d||d�S) Nz@TypedDict takes either a dict or keyword arguments, but not bothrUr�rpr�rmr]r�) rcr*r�rrr�rr�r�)r�r�r�rr�r]r]r^r@�s* r@cCstfSr�)� _TypedDictr�r]r]r^��ryr�cCsdd�}||_||_|S)NcSs|Sr�r])r(r]r]r^ryszNewType..new_type)rp� __supertype__)rr�ryr]r]r^rMsrMc@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);rCr]r�cCsdSr�r]r�r]r]r^�mode4szIO.modecCsdSr�r]r�r]r]r^r9szIO.nameNcCsdSr�r]r�r]r]r^�close>szIO.closecCsdSr�r]r�r]r]r^�closedBsz IO.closedcCsdSr�r]r�r]r]r^�filenoGsz IO.filenocCsdSr�r]r�r]r]r^�flushKszIO.flushcCsdSr�r]r�r]r]r^�isattyOsz IO.isattyr<)r�r�cCsdSr�r])r�r�r]r]r^�readSszIO.readcCsdSr�r]r�r]r]r^�readableWsz IO.readable)�limitr�cCsdSr�r])r�r�r]r]r^�readline[sz IO.readline)�hintr�cCsdSr�r])r�r�r]r]r^� readlines_sz IO.readlinesr)�offset�whencer�cCsdSr�r])r�r�r�r]r]r^�seekcszIO.seekcCsdSr�r]r�r]r]r^�seekablegsz IO.seekablecCsdSr�r]r�r]r]r^�tellkszIO.tell)�sizer�cCsdSr�r])r�r�r]r]r^�truncateosz IO.truncatecCsdSr�r]r�r]r]r^�writablessz IO.writable�r�r�cCsdSr�r]�r�r�r]r]r^�writewszIO.write)�linesr�cCsdSr�r])r�rr]r]r^� writelines{sz IO.writelinesz IO[AnyStr]cCsdSr�r]r�r]r]r^� __enter__sz IO.__enter__cCsdSr�r])r�rYr�� tracebackr]r]r^�__exit__�sz IO.__exit__)r<)r<)r<)r)N)rprmrnr��propertyrr[r�rr�r�r�r�r�r�r�rGr�r�r�r;r�r�r�r�r�r�r�rrrr]r]r]r^rC%sX rCc@s>eZdZdZeeeefed�dd��Z edd�dd��Z dS) rBr]r�cCsdSr�r]r�r]r]r^r��szBinaryIO.writer�cCsdSr�r]r�r]r]r^r�szBinaryIO.__enter__N) rprmrnr�rrr�� bytearrayr�r�rr]r]r]r^rB�s rBc@s�eZdZdZeeed�dd���Zeeed�dd���Z eee ed�dd���Z eee d�d d ���Z eeed�d d ���Zedd�d d��ZdS)rFr]r�cCsdSr�r]r�r]r]r^�buffer�sz TextIO.buffercCsdSr�r]r�r]r]r^�encoding�szTextIO.encodingcCsdSr�r]r�r]r]r^�errors�sz TextIO.errorscCsdSr�r]r�r]r]r^�line_buffering�szTextIO.line_bufferingcCsdSr�r]r�r]r]r^�newlines�szTextIO.newlinescCsdSr�r]r�r]r]r^r�szTextIO.__enter__N)rprmrnr�rrrBrr[rrr r�r r r rr]r]r]r^rF�s$rFc@s eZdZgd�ZeZeZeZdS)�io)rCrFrBN)rprmrn�__all__rCrFrBr]r]r]r^r �sr z.ioc@seZdZddgZeZeZdS)�rerErDN)rprmrnr rErDr]r]r]r^r�srz.re)N)TN)N)NNF)r])N)N)�rhrrrq�collections.abcrlr�r7r� stdlib_rer�rkrrrrr r_rirrr~r�r�r�r�r�r�rBr�r�r�rdr�r rPr r rrrr rrrrar8r:r?rAr�r�r�rr&r%�_TYPING_INTERNALS�_SPECIAL_NAMESr\r`rcrdrirtrmrrvrrRrHr�ro�BuiltinFunctionType� MethodTyper�r�rLr�rKrJrNrOr�rQrIr�r�r�r�r�r�r�rYr�r�r[rG�_aliasrr'r*r)r(rrr.r%rr+r r�r=rr#rr!r$r"rr}rr�r;�dequer8r�r>r rrr&rjrrkr-r*r9� defaultdictr:r<r7r6rAr,rr4r2r1r0r3r/r5r�r�r�r�r?rVr�r�r�r�r@r�rMrSrTrCrBrFr rpr�rErDr]r]r]r^�sf` !         %  !ATFS&! Q � b)5 � ]      � �    �         #59 c#