bgcdZddlmZddlZddlZddlZddlmZddlmZm Z m Z ddl m Z m Z ddlmZddlmZmZmZmZdd lmZmZmZmZdd lmZmZmZdd lmZm Z m!Z!m"Z"ej#d krdd lm$Z$ndd l%m$Z$erddl&m'Z'e"dZ(e"dZ)e"dZ*dZ+dZ,ddhZ-ere-.dhdZ/d4d5dZ0GddZ1 d4d6d$Z2d%Z3Gd&d'e1Z4Gd(d)e4Z5Gd*d+e1Z6Gd,d-e6Z7Gd.d/e4Z8Gd0d1e8Z9Gd2d3e4Z:dS)7zXThis module contains base classes and functions for the nodes and some inference utils. ) annotationsN)Sequence) TYPE_CHECKINGAnyClassVar) decoratorsnodes) PY310_PLUS) CallContextInferenceContextbind_context_to_node copy_context)AstroidTypeErrorAttributeInferenceErrorInferenceErrorNameInferenceError) InferBinaryOpInferenceErrorInfoInferenceResult) UninferableUninferableBaselazy_descriptor lazy_import))Literal) Constraintzinterpreter.objectmodelhelpersmanager__bool__builtinszbuiltins.propertyzabc.abstractpropertyz enum.property> lazyreify LazyProperty lazyproperty lazy_property lazyattributecache_readonlycachedpropertylazy_attributecached_propertyDynamicClassAttributecontextInferenceContext | Nonereturnboolc(||}t|rdSd|DtfdtDrdS|jsdS|jjpdD]}t||}|t|tr6|j j dkrR|j D]J}|j j dkr||j\}}|jd kr|jd krdSKdS) Nr-Tcnh|]2}t|t|dd3S).) isinstancersplit).0names ^/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/astroid/bases.py z_is_property..QsG $00 3c3 K|]}|vV dSN)r8r9strippeds r: z_is_property..Vs( < <48  < < < < < > ;*,,J1N1N444 5r<c@eZdZUdZdZded< dddZd Z dddZdS)ProxyzA simple proxy object. Note: Subclasses of this object will need a custom __getattr__ if new instance attributes are created. See the Const class N,nodes.ClassDef | nodes.Lambda | Proxy | None_proxiedproxiedr/Nonecn|+t|tjttfsJdS||_dSr>)r6r Const Generator UnionTyperY)selfrZs r:__init__zProxy.__init__xs; ?dU[)Y$GHH H HH H H#DMMMr<c||dkr |jjS||jvr |j|St|j|S)NrY)rKrY__dict__getattr)r`r9s r: __getattr__zProxy.__getattr__sD :  >* * 4= =& &t}d+++r<r-r.kwargsrKcollections.abc.Generator[InferenceResult, None, InferenceErrorInfo | None]c+K|VdSr>r?)r`r-rfs r:inferz Proxy.infers r<r>)rZrXr/r[)r-r.rfrr/rg) rL __module__ __qualname____doc__rY__annotations__rarerir?r<r:rWrWks   GK $ $ $ $ $,,,26r<rWstmts3Sequence[nodes.NodeNG | UninferableBase | Instance]framenodes.NodeNG | Instance | None6collections.abc.Generator[InferenceResult, None, None]c# Kd}d}|7|j}|}|j|i}nd}i}t }|D]}t |t r|Vd}||||_ t}| D]/\} } | |s| | 0| |D]& t fd|Dr Vd}$d}'#t$rYt$rt Vd}YwxYw|s |r t VdS|std|||dS)zGReturn an iterator on statements inferred by each statement in *stmts*.FNTr2c3BK|]}|VdSr>) satisfied_by)r8 constraintinfs r:rAz_infer_stmts..s1WW z..s33WWWWWWr<z.Inference failed for all members of {stmts!r}.)rnrpr-) lookupnameclone constraintsgetr r6r _infer_namesetitems parent_ofupdateriallrrr) rnr-rprQconstraint_failedr9rzstmtstmt_constraintsconstraint_stmtpotential_constraintsrws @r: _infer_stmtsrs  H!--//)--dB77  "$$ dO , , JJJH !--eT:: 03 :E:K:K:M:M C C6!6&0066C$++,ABBBzz'z22 - -WWWWFVWWWWW-III#HH(,%%  - "    H      HHH   )    <       sBD E+EEc$t|||d}|rt|dr|stS t g||_|||D]x}t|tr|cS t| |}n##t$r}t||d}~wwxYw| cSn#t$rYnwxYwtS)Nr2infer_call_resultargscallee)nextigetattrhasattrcallablerr callcontextrr6rri StopIterationr bool_value)instance method_namer-rOvaluerQes r:_infer_method_result_truthrsK !!+w!?? F FD 122}}   "-2d"C"C"CG //'/JJ - -e_55! LLLA#EKKK$@$@AAHH$AAA(999q@A**,,,,, -    D  s7AC;#CC; C! CC!!C;; DDcHeZdZdZdZddZddd Zddd Zddd Z dddZ dS) BaseInstancezWAn instance base class, which provides lookup methods for potential instances. Nr/strcdSNz Instance ofr?r`s r: display_typezBaseInstance.display_type}r<Tr-r.c |j||}ny#t$rl}|jr)||jvr |j|gcYd}~S|r"|j||dcYd}~St||||d}~wwxYw|r1 ||j||dzS#t$rYnwxYw|S)NF class_context)target attributer-)rY instance_attrrspecial_attributesrNrd)r`r9r- lookupclassvaluesexcs r:rdzBaseInstance.getattrs; ]00w??FF&   & >443J+J+J/66t<<======= Q},,T7%,PPPPPPPP)tW      5 5'!6!!+     s> B*BBB6B<BBB:: CCc #4K|st} ||_||jrt d|||||d}t |||||Ed{VdS#t$r |jj j dkr|j ||d}|||Ed{VYdS#t$r}t d it||d}~wwxYwwxYw) zInferred getattr.z%Cannot infer the same attribute again)messagenoder-F)r)rpNrBrr?) r rxpushrYrrdr _wrap_attrrrKrLrvars)r`r9r-get_attrattrserrors r:rzBaseInstance.igetattrs )&((G ?!%G ||DM** $C#||D'u|EEH#'22G4         ' ? ? ? ?=*3zAA ..tWE.RR??5'::::::::::::* ? ? ?$33tE{{33> ? ?s+A7B DAC** D4DDDc#xK|D]}t|tr?t|r|||Ed{VCt ||VVt |drJ|jdkr?|jjr.|jjdjdkrt ||V|V|VdS)z8Wrap bound methods of attrs in a InstanceMethod proxies.Nr9zrr`) r6 UnboundMethodrUr BoundMethodrr9r arguments)r`rr-attrs r:rzBaseInstance._wrap_attr!s  D$ .. %%2#55dGDDDDDDDDDD%dD111111v&& 49 +B+B9&49+>q+A+F&+P+P%dD11111    r<callernodes.Call | Proxyc#Kt||}d}t|tjrHt|jtjr)||jj|D]}d}|V |jd|D]K}t|ts| s,| ||D]}d}|V L|st|||dS)z5Infer what a class instance is returning when called.FT__call__)rrr-N) r r6r Callfunc AttributerattrnamerYrrrr)r`rr-rQresrs r:rzBaseInstance.infer_call_result1s 'w55 fej ) ) jeo.V.V }}V[%97CC   M**:w??  D$00   --fg>>     L d67KKK K L Lr<r/rNTr-r.r>)rrr-r.) rLrjrkrlrrrdrrrr?r<r:rrs4?????>"NRLLLLLLLr<rceZdZUdZded<edZdfd Zd ed <dd ZddZ ddZ ddZ ddZ dddZ dddZxZS)Instancez-A special node representing a class instance.nodes.ClassDefrYc4tSr>) objectmodel InstanceModelr?r<r:zInstance.Os1J1J1L1Lr<rZnodes.ClassDef | Noner/r[cJt|dSr>)superra)r`rZrKs r:razInstance.__init__Qs! !!!!!r<z!ClassVar[InferBinaryOp[Instance]]infer_binary_oprcd|jj|jjt |S)Nz)formatrYrootr9idrs r:__repr__zInstance.__repr__Vs=,33 M   %t}'92d88   r<c^d|jjd|jjS)Nz Instance of r4)rYrr9rs r:__str__zInstance.__str__[s.Ndm00227NN$-:LNNNr<r0cb |jdddS#t$rYdSwxYw)NrFrT)rYrdrrs r:rzInstance.callable^sI  M ! !*E ! B B B4&   55 s  ..c4|jSr>)rYqnamers r:pytypezInstance.pytypees}""$$$r<cdSrr?rs r:rzInstance.display_typehrr<Nr-r.c|p t}||_ t|t|}nC#tt f$r/ t|d|}n#t tf$rYYdSwxYwYnwxYw|S)aWInfer the truth value for an Instance. The truth value of an instance is determined by these conditions: * if it implements __bool__ on Python 3 or __nonzero__ on Python 2, then its bool value will be determined by calling this special method and checking its result. * when this method is not defined, __len__() is called, if it is defined, and the object is considered true if its result is nonzero. If a class defines neither __len__() nor __bool__(), all its instances are considered true. __len__T)r boundnoderBOOL_SPECIAL_METHODrr)r`r-results r:rzInstance.bool_valueks/-//  /6I7SSFF 78    3D)WMM+^<   ttt    s30A0AA0A*%A0)A**A0/A0ct||}|s|}t|d|d}t|g||_t |t std||t|j j dkrtd||t| ||dS)N __getitem__r2rz(Could not find __getitem__ for {node!r}.)rr-z8__getitem__ for {node!r} does not have correct signature) r rrr rr6rrlenrrrr)r`indexr- new_contextmethods r:getitemzInstance.getitems*7D99  "!GdmmM7mCCTJJ"-E76"J"J"J &+..  :w  v{$ % % * *"J  F,,T;??FFFr<)rZrr/r[r)r/r0r>r)rLrjrkrlrmrrrarrrrrrr __classcell__rKs@r:rrIs77))L)LMM""""""7666    OOOO%%%%4GGGGGGGGGr<rcneZdZdZedZddZddZdd Zddd Z dddZ dZ ddZ dddZ d S)rz>A special node representing a method not bound to an instance.c4tSr>)rUnboundMethodModelr?r<r:rzUnboundMethod.s1O1O1Q1Qr<r/rc|jjd}d|jj|jj|t|S)NTfuturez<{} {} of {} at 0x{}) rYparentrprrKrLr9rr)r`rps r:rzUnboundMethod.__repr__sV $**$*77%,, N #T]%74   r< Literal[0]cdS)Nrr?rs r:implicit_parametersz!UnboundMethod.implicit_parameterssqr<Literal[False]cdSNFr?rs r:is_boundzUnboundMethod.is_boundur<Nr-r.c||jvr|j|gS|j||Sr>)rrNrYrdr`r9r-s r:rdzUnboundMethod.getattrsB 4* * *+224889 9}$$T7333r<c||jvr(t|j|fS|j||Sr>)riterrNrYrrs r:rzUnboundMethod.igetattrsJ 4* * *077==?@@ @}%%dG444r<c|jjdkrc|jjd}|dr|dkr|||S|j||S)a The boundnode of the regular context with a function called on ``object.__new__`` will be of type ``object``, which is incorrect for the argument in general. If no context is given the ``object.__new__`` call argument will be correctly inferred except when inside a call that requires the additional context (such as a classmethod) of the boundnode to determine which class the method was called from __new__Trz builtins. builtins.type)rYr9rrpr startswith_infer_builtin_newr)r`rr-rs r:rzUnboundMethod.infer_call_results =  * *M(..d.;;AACCE ,, @/1I1I..vw???}..vw???r<r nodes.Callr Ocollections.abc.Generator[nodes.Const | Instance | UninferableBase, None, None]c#K|jsdSt|jdkrd}t|jdtjr|jdj}nNt |jdd}t|tjr|j}|tj|VdS|j |jd}|jd|D]L}t|tr|Vt|tj rt|VtdS)Nrr2)rrr6r r]rrri const_factory extra_contextr{rrBrr)r`rr-r inferred_arg node_contextrQs r:rz UnboundMethod._infer_builtin_newsO{  F v{  a  E&+a.%+66 / A,#FKN$8$8$:$:DAA lEK88/(.E )%00000,00Q@@  A,,\,BB ! !H(O44 (EN33 )x(((((  ! !r< Literal[True]cdSrr?r`r-s r:rzUnboundMethod.bool_valuetr<r)r/rr/rr>r)rrr-r r/rr-r.r/r )rLrjrkrlrrrrrrdrrrrr?r<r:rrsHH))Q)QRR    44444 55555 @@@(!!!!<r<rcheZdZdZedZfdZddZddZd Z ddfd Z dddZ xZ S)rz:A special node representing a method bound to an instance.c4tSr>)rBoundMethodModelr?r<r:rzBoundMethod.s1M1M1O1Or<cXt|||_dSr>)rrabound)r`proxyrrKs r:razBoundMethod.__init__s&  r<r/ Literal[0, 1]c |jdkrdSdS)Nrrr)r9rs r:rzBoundMethod.implicit_parameterss 9 ! !1qr<r cdSrr?rs r:rzBoundMethod.is_boundrr<cddlm} t|jd}n##t $r}t |d}~wwxYw|jjdkrdS| dsdS t|jd}n##t $r}t |d}~wwxYw|jjdkrdSt|j tsdS t|jd }n##t $r}t |d}~wwxYw|jjd krdS fd |j D}n##t $r}t |d}~wwxYwtd |DrdS t|jd } n##t $r}t |d}~wwxYw| jjdkrdStjt"} | jD]\} } t| } n##t $r}t |d}~wwxYw t| } n##t $r}t |d}~wwxYw| jjdkr:t| j tr | | j | ||j |j|j|} |}| |j |ggd|g| | _| S)zTry to infer what type.__new__(mcs, name, bases, attrs) returns. In order for such call to be valid, the metaclass needs to be a subtype of ``type``, the name needs to be a string, the bases needs to be a tuple of classes r)Passr2NrBrrr]rTuplecVg|]%}t|&S)r2)rri)r8eltr-s r: z4BoundMethod._infer_type_new_call..)s/UUU3d399W9#=#=>>UUUr<c36K|]}|jjdkVdS)rBN)rKrL)r8bases r:rAz3BoundMethod._infer_type_new_call..,s,PPt~&*4PPPPPPr<rDict)r9lineno col_offsetrT)rMbodyrnewstyle metaclasskeywords) astroid.nodesrrrrirrrKrL is_subtype_ofr6rreltsrH collections defaultdictlistr~appendr#r$postinitlocals)r`rr-rmcsrr9rMinferred_basesr cls_localskeyrclsemptys ` r:_infer_type_new_callz BoundMethod._infer_type_new_calls '&&&&& 9v{1~++G+<<==CC 9 9 9 111q 8 9 = !Z / /4  11 4 9 A,,W,==>>DD 9 9 9 111q 8 9 > "g - -4$*c** 4 9Q--g->>??EE 9 9 9 111q 8 9 ? #w . .4 9UUUU%*UUUNN 9 9 9 111q 8 9 PPPPP P P 4 9Q--g->>??EE 9 9 9 111q 8 9 ? #v - -4 ,T22 + 4 4JC =399W95566  = = =$W5551< = =U[[[99::  = = =$W5551< =}%00Z 35O5O039%,,U333mm=(     *       s.8 AAA.B44 C>CC.D55 E?EE+E?? F FF>.G-- H 7HH #I,, J 6JJ #J44 K>KKNr-r.cRt||j}|jjjdkr[|jjdkrK|jdkr@t |jdkr(|||}|rt|fSt ||S)NrBtyper) r rrKrLr9rrr8rrr)r`rr-new_clsrKs r:rzBoundMethod.infer_call_resultYs&w ;; J )Z 7 7 6)) Y&&FK  A%%//@@G (WJ'''ww((999r<cdSrr?r s r:rzBoundMethod.bool_valuehrr<)r/r)r/r r>rr) rLrjrkrlrrrarrr8rrrrs@r:rrsDD))O)OPP YYYv : : : : : : :r<rceZdZUdZded<eejZ ddfd Z e j dZ dd Z dd ZddZdddZddZddZxZS)r^zeA special node representing a generator. Proxied class is set once for all in raw_building. rrYNgenerator_initial_contextr.c~t||_t||_dSr>)rrarr _call_context)r`rr?rKs r:razGenerator.__init__vs9  )*CDDr<c#TK|j|jEd{VdSr>)rinfer_yield_resultrArs r:infer_yield_typeszGenerator.infer_yield_types}s7;11$2DEEEEEEEEEEEr<r/rcdSrr?rs r:rzGenerator.callablerr<Literal['builtins.generator']cdS)Nzbuiltins.generatorr?rs r:rzGenerator.pytypes##r<rcdS)Nr^r?rs r:rzGenerator.display_type{r<r-r cdSrr?r s r:rzGenerator.bool_valuerr<cRd|jjd|jdt|dS)Nz rYr9r#rrs r:rzGenerator.__repr__0ST]/SST[SS4SSSSr<c"d|jjdS)Nz Generator()rYr9rs r:rzGenerator.__str__1DM.1111r<)NN)r?r.r)r/rFrr>r)rLrjrkrlrmrrGeneratorModelrrarcachedrDrrrrrrrrs@r:r^r^ls  ()CDDQUEEEEEEEFFF$$$$TTTT22222222r<r^c2eZdZdZd dZd dZd dZd dZd S) AsyncGeneratorz-Special node representing an async generator.r/#Literal['builtins.async_generator']cdS)Nzbuiltins.async_generatorr?rs r:rzAsyncGenerator.pytypes))r<rcdS)NrXr?rs r:rzAsyncGenerator.display_typesr<cRd|jjd|jdt|dS)Nz)rrarr_ra)r`r_rarrKs r:razUnionType.__init__s4    r<rcdSrr?rs r:rzUnionType.callablerr<r-r.r cdSrr?r s r:rzUnionType.bool_valuerr<Literal['types.UnionType']cdS)Nztypes.UnionTyper?rs r:rzUnionType.pytypes  r<rcdS)Nr_r?rs r:rzUnionType.display_typerIr<cRd|jjd|jdt|dS)Nz )r_r`rar`rrbr/r[rr)r/rfr) rLrjrkrlrmrarrrrrrrrs@r:r_r_s  '+       !!!!TTTT22222222r<r_r>)r-r.r/r0)rnror-r.rprqr/rr);rl __future__rr,collections.abcsysrtypingrrrastroidrr astroid.constr astroid.contextr r r rastroid.exceptionsrrrrastroid.typingrrr astroid.utilrrrr version_infortyping_extensionsastroid.constraintrrrrrBUILTINSrFaddrIrUrWrrrrrrr^rXr_r?r<r:rzs #""""" $$$$$$//////////%%%%%%%%$$$$$$  NMMMMMMMMMSSSSSSSSSSSSv)))))).------k344 +i  +i ! !#9 :  $NN?###   <&&&&&&&&X-11 1 1 1 1 h,hLhLhLhLhL5hLhLhLVMGMGMGMGMG|MGMGMG`OOOOOEOOOd~~~~~-~~~B%2%2%2%2%2 %2%2%2P 7 7 7 7 7Y 7 7 7 #2#2#2#2#2 #2#2#2#2#2r<