bgjUdZddlmZddlZddlZddlmZmZmZm Z m Z erddl m Z m Z ddlmZmZee deeeeeefe dfZiZded <dd ZGd dZGddZddZddZdS)zIVarious context related utilities, including inference and call contexts.) annotationsN) TYPE_CHECKINGDictOptionalSequenceTuple) constraintnodes)KeywordNodeNGr _InferenceCache_INFERENCE_CACHEreturnNonec8tdSN)rclear`/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/astroid/context.py_invalidate_cachersrceZdZdZdZdZ dddZedd Zej dd ZeddZ ddZ ddZ e jdZddZdS)InferenceContextzProvide context for inference. Store already inferred nodes to save time Account for already visited nodes to stop infinite recursion )path lookupname callcontext boundnode extra_context constraints_nodes_inferreddNnodes_inferredlist[int] | Nonec| dg|_n||_|p t|_ d|_ d|_ d|_ i|_ i|_dSNr)r setrrrrrr)selfrr"s r__init__zInferenceContext.__init__/s{  !$%3D #1D MCEE  '+ 04D   SU''rrintc|jdS)z Number of nodes inferred in this context and all its clones/descendents. Wrap inner value in a mutable cell to allow for mutating a class variable in the presence of __slots__ rr r's rr"zInferenceContext.nodes_inferred]s#A&&rvaluerc||jd<dSr%r+)r'r-s rr"zInferenceContext.nodes_inferredgs"'Qrr ctS)z Inferred node contexts to their mapped results. Currently the key is ``(node, lookupname, callcontext, boundnode)`` and the value is tuple of the inferred results )rr,s rinferredzInferenceContext.inferredks  rboolcf|j}||f|jvrdS|j||fdS)zPush node into inference path. :return: Whether node is already in context path. Allows one to see if the given node has already been looked at for this inference context TF)rradd)r'nodenames rpushzInferenceContext.pushus> $<49 $ $4 tTl###urct|j|j}|j|_|j|_|j|_|j|_|S)zClone inference path. For example, each side of a binary operation (BinOp) starts with the same context but diverge as each side is inferred so the InferenceContext will need be cloned )r")rrcopyr rrrr)r'clones rr9zInferenceContext.clones`!!1!1$BVWWW ,."0 ,1133 rc#HKt|j}dV||_dSr)r&r)r'rs r restore_pathzInferenceContext.restore_paths'49~~  rstrcfdjD}dtjd|S)Nc 3K|]=}|dtjt|dt|z V>dS)=P)widthN)pprintpformatgetattrlen).0fieldr's r z+InferenceContext.__str__..sh   T Tv~gdE&:&:"s5zz/RRR T T      rz{}({})z, ) __slots__formattype__name__join)r'states` r__str__zInferenceContext.__str__sX       tDzz2INN54I4IJJJrNN)r"r#)rr))r-r)rr)rr )rr1)rr)rr<)rL __module__ __qualname____doc__rI max_inferredr(propertyr"setterr0r6r9 contextlibcontextmanagerr;rOrrrrrs IL+/,(,(,(,(,(\'''X'((((   X          KKKKKKrrc$eZdZdZdZ d d d ZdS) CallContextz"Holds information for a call site.argskeywordscalleeNr\ list[NodeNG]r]list[Keyword] | Noner^ NodeNG | NonecR||_|r d|D}ng}||_||_dS)Nc*g|]}|j|jfSr)argr-)rFrds r z(CallContext.__init__..s!HHH3HHHrr[)r'r\r]r^arg_value_pairss rr(zCallContext.__init__s?   !HHxHHHOO O'  rrP)r\r_r]r`r^ra)rLrQrRrSrIr(rrrrZrZs@,,.I *. $       rrZcontextInferenceContext | NonecJ||StS)z4Clone a context if given, or return a fresh context.)r9r)rgs r copy_contextrjs"}}   rc2t|}||_|S)a{Give a context a boundnode to retrieve the correct function name or attribute value with from further inference. Do not use an existing context since the boundnode could then be incorrectly propagated higher up in the call stack. :param node: Node to do name lookups from :type node NodeNG: :returns: A new context :rtype: InferenceContext )rjr)rgr4s rbind_context_to_noderls7##GG Nr)rr)rgrhrr)rS __future__rrWrBtypingrrrrrastroidr r astroid.nodes.node_classesr r r<r r__annotations__rrrZrjrlrrrrrs POO"""""" AAAAAAAAAAAAAA;)))))))):::::::: (HSM8C=(3- ?@(8BTT%'&&&&BKBKBKBKBKBKBKBKJ(r