HEX
Server: Apache/2.4.65 (Unix) OpenSSL/1.1.1k
System: Linux vps109042.inmotionhosting.com 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: cisa (1010)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //opt/imh-python/lib/python3.9/site-packages/astroid/__pycache__/protocols.cpython-39.pyc
a

k�h�{�@s�UdZddlmZddlZddlZddlZddlmZm	Z	m
Z
mZddlm
Z
mZmZddlmZmZmZmZddlmZddlmZmZdd	lmZmZmZmZmZdd
l m!Z!ddl"m#Z#m$Z$m%Z%e
r�edej&ej'�Z(d
Z)ej*ej+ej,ej-d�Z.de/d<dddd�dd�Z0dd�Z1dd�Z2dd�Z3dd�Z4dd �Z5d!d"�d#d"�d$d"�d%d"�d&d"�d'd"�d(d"�d)d"�d*d"�d+d"�d,d"�d-d"�ej6d.�
Z7e8e7�9��D]\Z:Z;e;e7e:d/<�q�ej<d0d1dd2d3d4d5d6�d7d8��Z=dd1d9d3dd:�d;d<�Z>d=d3d>d?�d@dA�Z?ej<dd1dd2d3d4dBdC�dDdE��Z@ej<dFd1dd2d3d4dGdC�dHdI��ZAdJdK�ZBejCd�dLdMdNdOddP�dQdR��ZDd�dSdMdNdOddP�dTdU�ZEd�dVdMdNdOddP�dWdX�ZFdYd3dGdZ�d[d\�ZGd�d]dMdNdOddP�d^d_�ZHejCd�d`dMdNdOddP�dadb��ZId�dcdMdNdOddP�ddde�ZJdfdg�ZKejCd�dhdMdNdOddP�didj��ZLdkdl�ZMejCd�dmdMdNdOddP�dndo��ZNejCd�dpdMdNdOddP�dqdr��ZOej<d�dsdMdNdOddP�dtdu��ZPej<d�dvdwdNdxdydP�dzd{��ZQej<d�d|dwdNdxdydP�d}d~��ZRej<d�ddwdNdxdydP�d�d���ZSej<d�d�dwdNdxdydP�d�d���ZTdS)�zcThis module contains a set of functions to handle python protocols for nodes
where it makes sense.
�)�annotationsN)�Callable�	Generator�Iterator�Sequence)�
TYPE_CHECKING�Any�TypeVar)�bases�
decorators�nodes�util)�Context)�InferenceContext�copy_context)�AstroidIndexError�AstroidTypeError�AttributeInferenceError�InferenceError�	NoDefault)�node_classes)�ConstFactoryResult�InferenceResult�SuccessfulInferenceResult�_TupleListNodeTzcontextlib.contextmanager)�+�-�~�notzdict[str, Callable[[Any], Any]]�_UNARY_OPERATORSr�strr)�obj�op�returncCs(|tur|}nt|}||�}t�|�S)z{Perform unary operation on `obj`, unless it is `NotImplemented`.

    Can raise TypeError if operation is unsupported.
    )�NotImplementedrr�
const_factory)r!r"�value�func�r(��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/astroid/protocols.py�_infer_unary_op/s
r*cCstt|j�|�S�N)r*�tuple�elts��selfr"r(r(r)�tuple_infer_unary_op<sr0cCst|j|�Sr+)r*r-r.r(r(r)�list_infer_unary_op@sr1cCstt|j�|�Sr+)r*�setr-r.r(r(r)�set_infer_unary_opDsr3cCst|j|�Sr+)r*r&r.r(r(r)�const_infer_unary_opHsr4cCstt|j�|�Sr+)r*�dict�itemsr.r(r(r)�dict_infer_unary_opLsr7cCs||Sr+r(��a�br(r(r)�<lambda>S�r;cCs||Sr+r(r8r(r(r)r;Tr<cCs||Sr+r(r8r(r(r)r;Ur<cCs||Sr+r(r8r(r(r)r;Vr<cCs||Sr+r(r8r(r(r)r;Wr<cCs||Sr+r(r8r(r(r)r;Xr<cCs||Sr+r(r8r(r(r)r;Yr<cCs||@Sr+r(r8r(r(r)r;Zr<cCs||BSr+r(r8r(r(r)r;[r<cCs||ASr+r(r8r(r(r)r;\r<cCs||>Sr+r(r8r(r(r)r;]r<cCs||?Sr+r(r8r(r(r)r;^r<)
rr�/z//�*�**�%�&�|�^z<<z>>�@�=znodes.Constznodes.AugAssign | nodes.BinOprrrz4Generator[ConstFactoryResult | util.UninferableBase])r/�opnode�operator�other�context�_r#ccs�t�t�}t|tj�r�|dkr\t|jttf�r\t|jttf�r\|jdksR|jdkr\|VdSzXt|}zt�||j|j��VWn0t	y�|VYnt
y�tjVYn0Wq�t	y�|VYq�0n$t|jt
�r�|dkr�tjVn|VdS)Nr?gj�@r@)r�Constr$�
isinstancer&�int�float�BIN_OP_IMPLr%�	TypeError�	Exceptionr
�Uninferabler )r/rFrGrHrIrJ�not_implemented�implr(r(r)�const_infer_binary_opes6	
�����

rUrM)r/rFr&rIr#csH|j|d�}|dkr"tjg|_|S�fdd�|jD�}t|�||_|S)N��parentg�חAc3s,|]$}t|tj�st�|��p"tjVqdSr+)rLr
�UninferableBaseZ
safe_inferrR)�.0�elt�rIr(r)�	<genexpr>�s�z'_multiply_seq_by_int.<locals>.<genexpr>)�	__class__r
rRr-�list)r/rFr&rI�nodeZ
filtered_eltsr(r[r)�_multiply_seq_by_int�s

�r`zSequence[InferenceResult]z#Iterator[SuccessfulInferenceResult])r-rIr#ccsT|D]J}t|tj�r t��Vq|�|�D]"}t|tj�sB|Vq*t��Vq*qdSr+)rLr
rXr�Unknown�infer)r-rIrZ�inferredr(r(r)�_filter_uninferable_nodes�srdz?Generator[_TupleListNodeT | nodes.Const | util.UninferableBase])r/rFrGrHrI�methodr#c
csddlm}d|_t�t�}t||j�rf|dkrf|j|d�}tt	�
t|j|�t|j|���|_|Vn�t|tj�r�|dkr�t|j
t�s�|VdSt|||j
|�Vn\t|tj�r�|dkr�|�|�}	|	s�tjVn(t|	j
t�s�td��nt|||	j
|�Vn|VdS)z�Infer a binary operation on a tuple or list.

    The instance on which the binary operation is performed is a tuple
    or list. This refers to the left-hand side of the operation, so:
    'tuple() + 1' or '[] + A()'
    r)�helpersNrrVr>zPlease open a bug report.)�astroidrf�	boundnoderrKr$rLr]r^�	itertools�chainrdr-r&rMr`r
�InstanceZclass_instance_as_indexr
rR�AssertionError)
r/rFrGrHrIrerfrSr_Zas_indexr(r(r)�tl_infer_binary_op�s2


��


rmznodes.ClassDefzGenerator[InferenceResult]cCs|�||�Sr+)�infer_call_result)r/rFrGrHrIrer(r(r)�instance_class_infer_binary_op�s	roc	cs0|dd�}|�d�}|D�]}t|tj�r.qt|d�s:qz|��}Wnty\YqYn0z t||tjtj	f�r||g}Wnt
y�Yn0|D]�}t�|�}z|�||�}Wntt
tfy�Yq�Yn0|s�|Vq�t|tj�r�qq�zt|�|�||�EdHWq�t�y&YqYq�0q�qdS)z<Recursive function to resolve multiple assignments on loops.Nr�itered)�poprLr
rX�hasattrrprPrrK�Name�
IndexError�getitem�AttributeErrorrr�_resolve_looppartrbr)	�parts�assign_pathrI�index�partrp�stmt�
index_node�assignedr(r(r)rw�s@






�rwznodes.For | nodes.Comprehensionz&node_classes.AssignedStmtsPossibleNodezInferenceContext | Nonezlist[int] | None)r/r_rIryr#ccs�t|tj�st|dd�r&||||d�S|dur`|j�|�D]"}t|tjtjf�r:|jEdHq:nt	|j�|�||�EdH||||d�S)N�is_asyncF�r_�unknownryrI)
rLr�AsyncFor�getattr�iterrb�Tuple�Listr-rw)r/r_rIry�lstr(r(r)�for_assigned_stmtss ��r�znodes.Tuple | nodes.Listc
Csr|durg}z|j�|�}Wn6tyR}ztd|||d�|�WYd}~n
d}~00|�d|�|jj|||d�S)Nz6Tried to retrieve a node {node!r} which does not exist�r_ryrIr)r_rIry)r-rz�
ValueErrorr�insertrW�assigned_stmts)r/r_rIryrz�excr(r(r)�sequence_assigned_stmts;s"���r�z#nodes.AssignName | nodes.AssignAttrcCs|jj||d�S)N)r_rI)rWr��r/r_rIryr(r(r)�assend_assigned_stmtsSsr�z
str | None)�namerIr#c#s�ddlm}�jstjVdS�fdd��jD�}�jj}|r�t�jddd�|kr�|dkrƈjj��}t|t	j
�o||jdk}|jr�t|jtj
�r�|jj}|s�|dkr�|VdS|d	kr�|��VdS|�r.|j�r.|jj}t|d
�r�|j}q�t|dd��jjk�r.|�|j|j�}	|	��j||�EdHdS|�jk�r�t	�d�}
�|
_|�sv�jjdk�rv�jj��}|��g|
_|
VdS|�jk�r�t	�i�}�|_|VdSz*t|�}��|��|�EdHtjVWnt�y�tjVYn0dS)
Nr��	argumentscs"g|]}|j�j�jfvr|�qSr()r��vararg�kwarg)rY�arg�r/r(r)�
<listcomp>gr<z,_arguments_infer_argname.<locals>.<listcomp>r��staticmethod�	metaclass�classmethodre�_proxiedr(�__init__)rgr�r
rRrW�typer��scoperLr�ClassDefrhr
rkr�Zinstantiate_class�callcontext�calleerrr��CallSiteZ
extra_context�infer_argumentr�r%r-r�r�
default_valuerbr)r/r�rIr��argsZfunctype�clsZis_metaclassr�Z	call_siter�r�r(r�r)�_arguments_infer_argname\sb���



r�znodes.Argumentsc	Cs�ddlm}z
|j}Wnty,d}Yn0|rT|jrT|jj}t|d�r`|j}q@nt|||�S|r�t	|dd�|�
�jkr�|j}t|�}d|_|j||d�}|�
|j||�St|||�S)Nrr�r�r�r[)rgr�r�rvr�r�rrr�r�r��framerr�r�rW)	r/r_rIryr�Z	node_namer�r�r�r(r(r)�arguments_assigned_stmts�s"




r�zBnodes.AugAssign | nodes.Assign | nodes.AnnAssign | nodes.TypeAliasccs8|s|jVdSt|j�|�||�EdH||||d�S)Nr�)r&�_resolve_assignment_partsrbr�r(r(r)�assign_assigned_stmts�s�
�r�znodes.AnnAssignccs0t||||�D]}|dur$tjVq|VqdSr+)r�r
rR)r/r_rIryrcr(r(r)�assign_annassigned_stmts�s
r�c
cs�|dd�}|�d�}|D]�}d}t|tj�rZz|j|\}}Wq�tyVYdS0n@t|d�r�t�|�}z|�||�}Wnt	t
fy�YdS0|s�dS|s�|Vqt|tj�r�dSzt
|�|�||�EdHWqt�y�YdS0qdS)z3Recursive function to resolve multiple assignments.Nrru)rqrLr�Dictr6rtrrrKrurrr
rXr�rbr)rxryrIrzr{r~rJr}r(r(r)r��s6



�r�znodes.ExceptHandlerccsHddlm}t�|j�D] }t|tj�r2|�|�}|Vq||||d�S)Nr)�objectsr�)	rgr�rZunpack_inferr�rLrr�ZExceptionInstance)r/r_rIryr�r~r(r(r)�excepthandler_assigned_stmtss
�r�c

cs�zt|j|d��}Wn0tyD}zt|d�|�WYd}~n
d}~00t|tj�r�|j}|jsjtd|d��|jj	D]2}t|j|d�d�}t|t	j
�rr|��tkrrq�qrt|d��zt|�
��VWn0ty�}zt|d�|�WYd}~n
d}~00n�t|tj��r�zt|jd|d��}Wn8tttf�yR}	zt|d�|	�WYd}	~	n
d}	~	00t|tj��slt|d��|�||�EdHn
t|d��dS)Nr[�r_z,No decorators found on inferred generator %s�	__enter__)�nextrb�
StopIterationrrLr
rrWrr�FunctionDefZqname�_CONTEXTLIB_MGRZinfer_yield_typesrkZigetattrrZBoundMethodrn)
r/�mgrrIrc�er'Zdecorator_node�	decoratorZenterr�r(r(r)�_infer_context_managers:"�
$"
r�z
nodes.Withc	#szt�fdd�|jD��}Wnty0YdS0|durNt|||�EdHn�t|||�D]�}|}|D]�}t|d�s�td|�||d��z|j|}Wqfty�}z td|�||d�|�WYd}~qfd}~0t�y}z td|�||d�|�WYd}~qfd}~00qf|VqZ|�||d	�S)
aInfer names and other nodes from a *with* statement.

    This enables only inference for name binding in a *with* statement.
    For instance, in the following code, inferring `func` will return
    the `ContextManager` class, not whatever ``__enter__`` returns.
    We are doing this intentionally, because we consider that the context
    manager result is whatever __enter__ returns and what it is binded
    using the ``as`` keyword.

        class ContextManager(object):
            def __enter__(self):
                return 42
        with ContextManager() as f:
            pass

        # ContextManager().infer() will return ContextManager
        # f.infer() will return 42.

    Arguments:
        self: nodes.With
        node: The target of the assignment, `as (a, b)` in `with foo as (a, b)`.
        context: Inference context used for caching already inferred objects
        assign_path:
            A list of indices, where each index specifies what item to fetch from
            the inference results.
    c3s|]\}}|�kr|VqdSr+r()rYr��varsr�r(r)r\dr<z&with_assigned_stmts.<locals>.<genexpr>Nr-z0Wrong type ({targets!r}) for {node!r} assignment)r_�targetsryrIzCTried to infer a nonexistent target with index {index} in {node!r}.z1Tried to unpack a non-iterable value in {node!r}.r�)	r�r6r�r�rrrr-rtrP)	r/r_rIryr��resultr!rzr�r(r�r)�with_assigned_stmtsBsZ!
������r�znodes.NamedExprccs4|j|kr |jj|d�EdHntd|||d��dS)z:Infer names and other nodes from an assignment expression.r[Nz$Cannot infer NamedExpr node {node!r}r�)�targetr&rbrr�r(r(r)�named_expr_assigned_stmts�s
�r��
nodes.Starredc
#s�ddddd��fdd��|��}t|tjtjf�sDtd||||d	��|d
urRt�}t|tj��r�|j}|jd}t|tj	�s�t
jVd
Stdd
�|�
tj�D��dkr�td||||d��zt|�|��}Wn ttfy�t
jVYd
S0t|t
j��st|d��st
jVd
Szt�|���}Wnt�yBt
jVYd
S0t|j�D]�\}	}
t|
tj��s||�sp�q�|���qNt�t|j|	d
���}|D]`}t|tj��s�|�s��qN|���q�tjtj||j |j!d�}
|
j"t#|�d�|
V�qN�q��qNt|tj��r�zt|j$j|d��}Wn"ttf�yDt
jVYd
S0t|t
j��s`t|d��slt
jVd
Sz|��}Wnt�y�t
jVYd
S0|j%}t|tj&��s�td|d��g}�|||�|�s�td|d��|d\}}||dk}t'||�rd
n||�}|}|D]�}d
}t|�D]�\}	}t|d��s<�q�|	dt(|�u�rT|}n|d}z|��}||}Wn<t)�y�Y�q�Yn&t�y�t
jVYd
S0|}�q"tjtj||j |j!d�}|j"|�p�gd�|Vd
St
jVd
S)aD
    Arguments:
        self: nodes.Starred
        node: a node related to the current underlying Node.
        context: Inference context used for caching already inferred objects
        assign_path:
            A list of indices, where each index specifies what item to fetch from
            the inference results.
    r�znodes.Tuplezlist[tuple[int, int]]�None)�starredr��lookupsr#cs~|��}t|�D]h\}}t|tj�rJ|jj|jjkrJ|�|t|�f�qzt|tj	�r|�|t|���f��|||�qdSr+)
rp�	enumeraterLr�Starredr&r��append�lenr�)r�r�r�rprz�element��$_determine_starred_iteration_lookupsr(r)r��s
��zDstarred_assigned_stmts.<locals>._determine_starred_iteration_lookupszDStatement {stmt!r} enclosing {node!r} must be an Assign or For node.)r_r|r�rINrcss|]
}dVqdS)�Nr()rYrJr(r(r)r\�r<z)starred_assigned_stmts.<locals>.<genexpr>r�z=Too many starred arguments in the assignment targets {lhs!r}.)r_r�r�rIrp)�ctxrW�lineno�
col_offset)r-r[z8Could not make sense of this, the target must be a tuplez5Could not make sense of this, needs at least a lookup���)*Z	statementrLr�Assign�Forrrr&r�Z
BaseContainerr
rR�sumZnodes_of_classr�r�rbr�rXrr�collections�dequerprPr�r-�popleft�reversedrqr�r�Storer�r�Zpostinitr^r�r�r��slicer�rt)r/r_rIryr|r&�lhs�rhsr-rzZ	left_nodeZlhs_eltsZ
right_node�packedZinferred_iterablerpr�r�Zlast_element_indexZlast_element_lengthZis_starred_lastZlookup_sliceZlast_lookupr�Z
found_element�lookupZ
cur_lookupZitered_inner_element�unpackedr(r�r)�starred_assigned_stmts�s��
�	������r�znodes.MatchMappingznodes.AssignNamer�zGenerator[nodes.NodeNG]ccsdS�zbReturn empty generator (return -> raises StopIteration) so inferred value
    is Uninferable.
    Nr(r�r(r(r)�match_mapping_assigned_stmtsjs
r�znodes.MatchStarccsdSr�r(r�r(r(r)�match_star_assigned_stmtsxs
r�z
nodes.MatchAsccs8t|jtj�r4t|jjtj�r4|jdur4|jjjVdS)z}Infer MatchAs as the Match subject if it's the only MatchCase pattern
    else raise StopIteration to yield Uninferable.
    N)rLrWrZ	MatchCase�Match�pattern�subjectr�r(r(r)�match_as_assigned_stmts�s���r�z4nodes.TypeVar | nodes.TypeVarTuple | nodes.ParamSpecccst�d�VdS)zzHack. Return any Node so inference doesn't fail
    when evaluating __class_getitem__. Revert if it's causing issues.
    N)rrKr�r(r(r)�generic_type_assigned_stmts�s
r�)NNN)NNN)NNN)NNN)NNN)NNN)NNN)NNN)NN)NNN)NN)NN)NN)NN)U�__doc__�
__future__rr�rirGZoperator_mod�collections.abcrrrr�typingrrr	rgr
rrr
Z
astroid.constrZastroid.contextrrZastroid.exceptionsrrrrrZ
astroid.nodesrZastroid.typingrrrr�r�rr��pos�neg�invert�not_r�__annotations__r*r0r1r3r4r7�matmulrOr^r6Z_KEYZ_IMPLZyes_if_nothing_inferredrUr`rdrmrorwZraise_if_nothing_inferredr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r(r(r(r)�<module>s��
�$/)���	B���
(�&�O��E�
�
��