idHnddlmZddlZddlZddlZddlmZmZddlm Z ddl m Z m Z mZmZmZmZmZmZmZddlmZmZddlmZddlmZmZmZmZmZdd l m!Z!dd l"m#Z#dd l$m%Z%dd l&m'Z'dd l(m)Z)m*Z*m+Z+e rddlm,Z,ej-dkrddl m.Z.nddl/m.Z.ej-dkrddlm0Z0nddl1m2Z0eddZ3eddZ4eddZ5ededeeddffZ6GddZ7dS)) annotationsN) GeneratorIterator)singledispatch) TYPE_CHECKINGAnyClassVarTupleTypeTypeVarUnioncastoverload) decoratorsutil)InferenceContext) AstroidErrorInferenceErrorParentMissingErrorStatementMissingUseInferenceDefault)AstroidManagerAsStringVisitor) OP_PRECEDENCE)Position)InferenceErrorInfoInferenceResultInferFn)nodes))Literal)cached_property)cachedproperty_NodesTNodeNG)bound_NodesT2_NodesT3.ceZdZUdZdZded< dZded< dZded< dZded<dZ d ed < dZ d ed < dZ d ed < d Z ded< dkd d ddldZ dmdnd Zdod"Zdod#Zdod$Zd%Zdpd'Zdqd(Zdpd)Zdrd+Zed,d-dsd0Zedtd3Zd d-dud5Zd d-dvd7Zdwd9Zdxd;Zd<Zd=Zd>Zd?Ze dyd@Z!e dydAZ"dydBZ#dCZ$dzdFZ%e d{d|dLZ&e d{d}dOZ&e d{d~dRZ&e d{ddTZ& dmddVZ&e'j(dWZ)dXZ*dYZ+dZZ,d[Z- dmdd]Z.d^Z/d_Z0drd`Z1drdaZ2drdbZ3dodcZ4 ddodgZ5dmddhZ6diZ7ddjZ8d S)r'zlA node of the new Abstract Syntax Tree (AST). This is the base class for all Astroid node classes. FzClassVar[bool] is_statementoptional_assign is_function is_lambdazClassVar[tuple[str, ...]]_astroid_fields _other_fields_other_other_fieldsNzInferFn | None_explicit_inference) end_linenoend_col_offsetlineno int | None col_offsetparent NodeNG | Noner5r6returnNonecd||_ ||_ ||_ ||_ ||_ d|_dS)a :param lineno: The line that this node appears on in the source code. :param col_offset: The column that this node appears on in the source code. :param parent: The parent node in the syntax tree. :param end_lineno: The last line this node appears on in the source code. :param end_col_offset: The end column this node appears on in the source code. Note: This is after the last symbol. N)r7r9r:r5r6position)selfr7r9r:r5r6s J/opt/cloudlinux/venv/lib/python3.11/site-packages/astroid/nodes/node_ng.py__init__zNodeNG.__init__]sL,#) D&0F%+ 1&0D*8 *.   contextInferenceContext | Nonekwargsr&Generator[InferenceResult, None, None]c+K||j||}|jV t|j||fi|}||xjt |z c_|Ed{VdS#t $rYnwxYw|s|jdd|i|Ed{VdS||j|j |j f}||j vr|j |Ed{VdSg}tj }t|jdd|i|D]s\}}||ks|j|jkr/|t"jt"jVn*|||V|xjdz c_tt'||j |<dS)aVGet a generator of the inferred values. This is the main entry point to the inference system. .. seealso:: :ref:`inference` If the instance has some explicit inference function set, it will be called instead of the default interface. :returns: The inferred values. :rtype: iterable NrDr0) extra_contextgetr4listnodes_inferredlenr_infer lookupname callcontext boundnodeinferredrmax_inferable_values enumerate max_inferredappendr Uninferabletuple)r@rDrFresultskeylimitiresults rAinferz NodeNG.infers   +//g>>G  # / 7t7gPPPPQQ&**c'll:**""""""""&     "t{==7=f== = = = = = = = FW')OP '" " "', , , , , , , , F3";4;#I#Iw#I&#I#IJJ ( (IAvEzzg4w7KKKt/000&&&& NN6 " " "LLL  " "a ' " " "!&gsAA-- A:9A:strctfddDr"tddptddSdS)zGet a name for nice representation. This is either :attr:`name`, :attr:`attrname`, or the empty string. :returns: The nice name. :rtype: str c3*K|] }|jvVdSN)r1).0namer@s rA z$NodeNG._repr_name..s+QQDt4//QQQQQQrC)reattrnamererg)allgetattrr@s`rA _repr_namezNodeNG._repr_namesT QQQQ> 7 7ED%((EUOi/EN5%@@@KKDQQE1XJEabb  5 5 S9_t34444 MMU55RWWU^^55 6 6 6 6sY.44V<<    rCc|}|rd}nd}|t|j||jt |dzS)Nz.<%(cname)s.%(rname)s l.%(lineno)s at 0x%(id)x>z$<%(cname)s l.%(lineno)s at 0x%(id)x>)rurvr7id)rlrxry fromlinenor)r@rvr~s rA__repr__zNodeNG.__repr__sY!!  <EFF;F$ZZ(oT((     rCcvt|d|jjz}||S)z(Visit this node using the given visitor.visit_)rj __class__rylower)r@visitorfuncs rAacceptz NodeNG.accepts5w4>+B+H+H+J+J JKKtDzzrCIterator[NodeNG]c#K|jD]>}t||}|t|ttfr |Ed{V:|V?dEd{VdS)z$Get the child nodes below this node.Nr0r1rj isinstancerLrYr@rattrs rA get_childrenzNodeNG.get_childrensx)  E4''D|$u ..   rCc|jdddD]>}t||}|st|ttfr |dcS|cSdS)z1An optimized version of list(get_children())[-1].Nrrs rA last_childzNodeNG.last_child sj)$$B$/  E4''D $u .. BxKKKtrCc#:K|j}||V|j}| dSdS)z7Yield parent, grandparent, etc until there are no more.N)r:)r@r:s rAnode_ancestorszNodeNG.node_ancestorss7 LLL]F     rCboolc^tfd|DS)zCheck if this node is the parent of the given node. :param node: The node to check if it is the child. :type node: NodeNG :returns: Whether this node is the parent of the given node. c3 K|]}|uV dSrcr0)rdr:r@s rArfz#NodeNG.parent_of..$s'FFf46>FFFFFFrC)anyrr@nodes` rA parent_ofzNodeNG.parent_ofs4FFFF0C0C0E0EFFFFFFrC.futurernodes.Statement | nodes.ModulecdSrcr0r@rs rA statementzNodeNG.statement& rC Literal[True]nodes.StatementcdSrcr0rs rArzNodeNG.statement*rrCLiteral[None, True]c|jrtd|S|js@|rt|t jdt dt|d|j|S)aPThe first parent node, including self, marked as statement node. TODO: Deprecate the future parameter and only raise StatementMissing and return nodes.Statement :raises AttributeError: If self has no parent attribute :raises StatementMissing: If self has no parent attribute and future is True rtargetzIn astroid 3.0.0 NodeNG.statement() will return either a nodes.Statement or raise a StatementMissing exception. AttributeError will no longer be raised. This behaviour can already be triggered by passing 'future=True' to a statement() call.rn stacklevel! object has no attribute 'parent'r) r,rr:rwarningswarnDeprecationWarningAttributeErrorrrs rArzNodeNG.statement.s   1)400 0{ M 4&d3333 MB#     !D!K!K!KLL L{$$F$333rC@nodes.FunctionDef | nodes.Module | nodes.ClassDef | nodes.Lambdac|j@|rt|tjdtdt |d|j|S)zThe first parent frame node. A frame node is a :class:`Module`, :class:`FunctionDef`, :class:`ClassDef` or :class:`Lambda`. :returns: The first parent frame node. NrzIn astroid 3.0.0 NodeNG.frame() will return either a Frame node, or raise ParentMissingError. AttributeError will no longer be raised. This behaviour can already be triggered by passing 'future=True' to a frame() call.rnrrr)r:rrrrrframers rArz NodeNG.frameIs} ;  6(5555 M>#     !D!K!K!KLL L{   ///rCnodes.LocalsDictNodeNGcb|jst||jS)zThe first parent node defining a new scope. These can be Module, FunctionDef, ClassDef, Lambda, or GeneratorExp nodes. :returns: The first parent scope node. r)r:rscoperks rArz NodeNG.scopebs3{ 2$D111 1{  """rC nodes.ModulecF|jr|jS|S)zSReturn the root node of the syntax tree. :returns: The root node. )r:rootrks rArz NodeNG.rootms' ; &;##%% % rCc|jD]?}t||}||ur|gcSt|ttfr||vr|cS@d}t |t |t |fz)a_Search for the sequence that contains this child. :param child: The child node to search sequences for. :type child: NodeNG :returns: The sequence containing the given child node. :rtype: iterable(NodeNG) :raises AstroidError: If no sequence could be found that contains the given child. "Could not find %s in %s's childrenr1rjrrYrLrreprr@childrnode_or_sequencemsgs rAchild_sequencezNodeNG.child_sequencevs) ( (E&tU33 5((())))+eT];; (---''''23$u++tDzz!::;;;rCc|jD]B}t||}||ur||fcSt|ttfr ||vr||fcSCd}t |t |t |fz)aFind the field of this node that contains the given child. :param child: The child node to search fields for. :type child: NodeNG :returns: A tuple of the name of the field that contains the child, and the sequence or node that contains the child node. :rtype: tuple(str, iterable(NodeNG) or NodeNG) :raises AstroidError: If no field could be found that contains the given child. rrrs rA locate_childzNodeNG.locate_childs) / /E&tU33 (((e|###+eT];; /---.....23$u++tDzz!::;;;rCc4|jS)z|The next sibling statement node. :returns: The next sibling statement node. :rtype: NodeNG or None )r: next_siblingrks rArzNodeNG.next_siblings {'')))rCc4|jS)zThe previous sibling statement. :returns: The previous sibling statement node. :rtype: NodeNG or None )r:previous_siblingrks rArzNodeNG.previous_siblings {++---rCcF|j|S|jS)zz8NodeNG.repr_tree.._repr_tree..sCCC:,CCCrCN)rzr{maxrNr|rWextend)rr^donerdepthr max_widths ` rA _repr_treez$NodeNG.repr_tree.._repr_trees NC C OO ;Q??j  MM%( # # # MMCCCCqrrCCC D D Du::? "rCc|z }|d|sd}n3t|dkr|d||||}n t|dkro|d||||}|s|dn*|d|||d||||p|}n|d|||d d D];}||||||d||<|d ||||d }|d |S) z_Outputs a representation of a sequence that's contained within an AST. [FrIrrnz, rt NrT])rWrN) rr^rrrbrokenrrrps rA _repr_seqz#NodeNG.repr_tree.._repr_seqs & J MM#    Ta#DGVT:uMMTa#DGVT:uMM.MM$''''MM%(((MM*---#DGVT:uMMWQW d### j)))!#2#Y..EJufdJFFFMM%(((MM*---- 48VT:uEEE MM#   MrCc L||vr?| dt|jdt|zdS|| r| kr|ddS|dz }| z } r<|t|jdt|ddn*|t|jd g} r|d ||j||j r||j|sd}n5t|dkrB||d d t||d ||||}n|d |||ddD]h}|dkr ||d t|||||||d||i||dd t||d||||d}|d|S)z4Outputs a strings representation of an astroid node.z( ()r7r9rrsrNrdocrtT)) rWrxryraddrr2r1r3rNrj)rr^rrrrwrrr ast_stateidsinclude_linenosrp max_depths rA _repr_nodez$NodeNG.repr_tree.._repr_nodest|| Vd4jj.AVVBtHHVVVu HHTNNN UY.. e$$$u QJE & J 9 d!4IIDIIIIJJJJ d!4777888F 8 6777 MM$, - - - MM$. / / / 8 d6777 V!! ooo...#D&),,fdJ d### j)))#CRC[..E~~ MMU+++...JwtU33VT:uUUUMM%(((MM*---- .../// 7444fdJPUVVV MM#   MrC)rhrI)_singledispatchregisterrYrLr'setr}) r@r$r%r#rpr&rrr'r^rs `````` @rA repr_treezNodeNG.repr_trees L  # # # # #  #   U # #   T " "       # " $ # >   V $ $/ / / / / / / / / /  % $/ b 4'''wwvrCctjS)akDetermine the boolean value of this node. The boolean value of a node can have three possible values: * False: For instance, empty data structures, False, empty strings, instances which return explicitly False from the __nonzero__ / __bool__ method. * True: Most of constructs are True by default: classes, functions, modules etc * Uninferable: The inference engine is uncertain of the node's value. :returns: The boolean value of this node. :rtype: bool or Uninferable )rrX)r@rDs rA bool_valuezNodeNG.bool_values $rCcdtj|jjt tSrc)rrKrryrNrks rA op_precedencezNodeNG.op_precedence(s" !8#m:L:LMMMrCcdS)NTr0rks rAop_left_associativezNodeNG.op_left_associative,strC)NNN) r7r8r9r8r:r;r5r8r6r8r<r=rc)rDrErFrr<rG)r<r`)r<r)r<r;)r<r)rr=r<r)rrr<r)rrr<r)rrr<r)r<r)r<r)r<r8)rer`rr'r<r=).)rrrrr<r)rrrrr<r)rrrrr<r)rrrrr<r)rrrrr<r)rDrErFrr<r)FFFr rro)rDrE)r<r)9ry __module__ __qualname____doc__r,__annotations__r-r.r/r1r2r3r4rBr_rlrrrrrrrrrrrrrrrrr$rrrrrrrcachedrrrrrrOrSrrrrr r+r-r/r1r0rCrAr'r';s] $)L((((2  #(K''''1 %I%%%%24O333302M1111:5777777*....."!% $ - "&%)- - - - - - `2688888t        4             ####GGGG*-     X    X 044444448040000002 # # # #<<<4<<<:***..._  # # #_ #$ % % % * * * *"%    X "%    X "%    X "%    X "&DDDDDB444   26     """   '''' HHHHHT     (NNNrC)8 __future__rrzsysrcollections.abcrr functoolsrr(typingrrr r r r r rrastroidrrastroid.contextrastroid.exceptionsrrrrrastroid.managerrastroid.nodes.as_stringrastroid.nodes.constrastroid.nodes.utilsrastroid.typingrrrr version_infor#typing_extensionsr$astroid.decoratorsr%r&r)r*rr'r0rCrArGs #""""" ////////777777                      %$$$$$$$,,,,,,+*****333333------((((((GGGGGGGGGGv))))))v)))))))DDDDDD ')8 , , , 7:X . . . 7:X . . . 4htH~s/B)CC D s s s s s s s s s s rC