bg2tddlmZddlmZddlmZddlmZmZddl m Z m Z ddl m Z mZGddZd S) ) annotations)nodes)Instance) CallContextInferenceContext)InferenceError NoDefault) UninferableUninferableBasecbeZdZdZ dddZedddZd Zdd Zddd Z dddZ dZ dS)CallSiteaClass for understanding arguments passed into a call site. It needs a call context, which contains the arguments and the keyword arguments that were passed into a given call site. In order to infer what an argument represents, call :meth:`infer_argument` with the corresponding function node and the argument name. :param callcontext: An instance of :class:`astroid.context.CallContext`, that holds the arguments for the call site. :param argument_context_map: Additional contexts per node, passed in from :attr:`astroid.context.Context.extra_context` :param context: An instance of :class:`astroid.context.Context`. N callcontextrcontextInferenceContext | NonecJ|i}||_|j}|j}t|_||||_||||_d|jD|_ d|j D|_ dS)Nrc<g|]}t|t|S isinstancer .0args b/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/astroid/arguments.py z%CallSite.__init__...s7% % % jo6V6V% % % % cDi|]\}}t|t||Srrrkeyvalues r z%CallSite.__init__..1s>" " " Ue_55" " " " r) argument_context_mapargskeywordssetduplicated_keywords _unpack_args_unpacked_args_unpack_keywords_unpacked_kwargspositional_argumentsitemskeyword_arguments)selfrr"rr#r$s r__init__zCallSite.__init__s '#% $8!'-0UU "//g/FF $ 5 5h 5 P P% % .% % % !" " "399;;" " " rcp|p t}t|j|j}|||S)zxGet a CallSite object from the given Call node. context will be used to force a single inference path. r)rrr#r$)cls call_noderrs r from_callzCallSite.from_call7s>/-//!).)2DEE s;0000rcVt|jt|jkS)aoCheck if in the current CallSite were passed *invalid* arguments. This can mean multiple things. For instance, if an unpacking of an invalid object was passed, then this method will return True. Other cases can be when the arguments can't be inferred by astroid, for example, by passing objects which aren't known statically. )lenr+r(r.s rhas_invalid_argumentszCallSite.has_invalid_argumentsCs%4,--T5H1I1IIIrreturnboolcVt|jt|jkS)agCheck if in the current CallSite were passed *invalid* keyword arguments. For instance, unpacking a dictionary with integer keys is invalid (**{1:2}), because the keys must be strings, which will make this method to return True. Other cases where this might return True if objects which can't be inferred were passed. )r5r-r*r6s rhas_invalid_keywordszCallSite.has_invalid_keywordsMs%4)**c$2G.H.HHHrci}|p t}|j|_|D]b\}}|T t||}n%#t $r t ||<YDt$rYOwxYwt|tj s t ||<x|j D]\}} t||}n%#t $r t ||<Y@t$rYKwxYwt|tj s t ||<tt|j ts t ||<|j |vr/t ||j <|j|j |||j <ܐ]|||<d|S)Nr)rr" extra_contextnextinferrr StopIterationrrDictr,Constr strr&add) r.r$rvaluesnamer inferreddict_key dict_values rr)zCallSite._unpack_keywordsWs/-// $ 9#% %% %KD%|#EKKK$@$@AAHH%#.F4LH$H"(EJ77#.F4L,4N88(Hj!#'w(G(G#H#H)!!!'2t  (!!! !%h <<!'2t  %hnc::!'2t  ~//1<x~.044X^DDD -7F8>**'8* %t  s/#AA1% A10A1&#C  C, C,+C,cXg}|p t}|j|_|D]}t|tjr t |j|}n5#t$r| tYmt$rYxwxYwt|tr| tt|ds| t||j| | |S)Nrelts)rr"r=rrStarredr>r r?rappendr r@r hasattrextendrK)r.r#rrErrGs rr'zCallSite._unpack_argss4/-// $ 9 # #C#u}-- ##CIOOGO$D$DEEHH%MM+...H$Hh88MM+...x00MM+... hm,,,, c"""" s(A(($B BBc  ||jvrtd|||| |j||S#t$rYnwxYwt |jt |jjkr,|jjs |jj std|||||jdt |jj}|jt |jjd}|j |d}d|jj Dfd|j D}t |t |jjkrG|jjD]:}|j |vr/||j } || ;|ct!|dd} |dkr |jd vr| )|jd kr|r|d| S| |jd } t)| t*jr?|j} | | urt3| fS|jd kr9t)| t4s| } t3| fS|jdkrt3| fS|jd vr| r|dz} |j||S#t8$rYnwxYw|jj|kr|r td|j|j||||t+j |jj!|jj"|j} | #d| Dt3| fS|jj|kr|$r td|j|j%||||t+j&|jj!|jj"|j} | #|t3| fS |j'||S#tP$rYnwxYwtd||||)aInfer a function argument value according to the call context. Arguments: funcnode: The function being called. name: The name of the argument whose value is being inferred. context: Inference context object z9The arguments passed to {func!r} have duplicate keywords.) call_sitefuncrrzJToo many positional arguments passed to {func!r} that does not have *args.Nrch|] }|j Sr)rFrs r z*CallSite.infer_argument..sCCC3chCCCrc$i|] \}}|v || Srr)rrr kwonlyargss rr!z+CallSite.infer_argument..s4   U*$$ $$$r boundnode>method classmethodrXrT)futurerYzInference failed to find values for all keyword arguments to {func!r}: {unpacked_kwargs!r} doesn't correspond to {keyword_arguments!r}.)r-unpacked_kwargsrQrRrr)lineno col_offsetparentc@g|]\}}tj||fSr)r const_factoryrs rrz+CallSite.infer_argument..s,TTTzsE%%c**E2TTTrzInference failed to find values for all positional arguments to {func!r}: {unpacked_args!r} doesn't correspond to {positional_arguments!r}.)r+ unpacked_argsrQrRrrz-No value found for argument {arg} to {func!r}))r&rr-r?KeyErrorr5r+r#vararg posonlyargs find_argnamerVr,rFpoprMgetattrtyper_framerrClassDefscope metaclassiterrinstantiate_class IndexErrorkwargr;r*rAr]r^postinitr7r(Tuple default_valuer )r.funcnoderFr positionalrdargindexkwargsfunc_argrrW method_scoperqr#rVs @rinfer_argumentzCallSite.infer_argumentsh 4+ + + K   )$/55g>> >    D  t( ) )C 0B,C,C C C='  0I $&#!#./HX]5G1H1H/HI *3x}/A+B+B+D+DE=--d33A6CC(-*BCCC     "4::<<    z??S!344 4 4$M. + +=F** **X]33C%%c***  d;;I1}}2K!K!K$()B)Bz)B%a=..w.???$ ( 5 5T 5 B BIi882 $,?#8#8#:#:L#y':':'<'<<<#YL111=H,,%i::B$-$?$?$A$A  ---=M11 ---} 999i9A  0:@@III     = $ & &((** $-'+&<$($9"!#    J}+#=3}E NNTTV\\^^TTT   >> ! = 4 ' '))++ $>*.)B"&"5"!#    ;}+#=3}D MM& ! ! !==  =..t44::7CC C    D  ;     s5A A  A 9L L&%L&8,R%% R21R2)NN)rrrr)N)rr)r8r9) __name__ __module__ __qualname____doc__r/rYr3r7r;r)r'r{rrrr r s&"+/      0 1 1 1 1[ 1JJJIIII*****X2Y Y Y Y Y rr N) __future__rastroidr astroid.basesrastroid.contextrrastroid.exceptionsrr astroid.utilr r r rrrrs #"""""""""""999999998888888855555555g g g g g g g g g g r