bgDdZddlmZddlZddlmZmZddlmZddl m Z ddl m Z m Z mZddlmZejd krdd l mZndd lmZe e je je je jfZGd d eZGd deZd!dZeefZ d"dZ d#d$d ZdS)%zHClasses representing different types of constraints on inference values.) annotationsN)ABCabstractmethod)Iterator)Union)basesnodesutil)InferenceResult) )Selfc^eZdZdZddZee dddZeddZdS) Constraintz-Represents a single constraint on a variable.node nodes.NodeNGnegateboolreturnNonec$||_ ||_dS)Nrr)selfrrs c/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/astroid/constraint.py__init__zConstraint.__init__s 7 QQFcls type[Self] _NameNodesexpr Self | NonecdS)zReturn a new constraint for node matched from expr, if expr matches the constraint pattern. If negate is True, negate the constraint. N)rrr rs rmatchzConstraint.match!rinferredr cdS)HReturn True if this constraint is satisfied by the given inferred value.Nr#rr&s r satisfied_byzConstraint.satisfied_by,r%rN)rrrrrrF rrrrr rrrrr!r&r rr) __name__ __module__ __qualname____doc__r classmethodrr$r*r#rrrrs77RRRR NS    ^[ WWW^WWWrrcbeZdZUdZejdZded<e dddZ ddZ dS)NoneConstraintz4Represents an "is None" or "is not None" constraint.Nz nodes.Const CONST_NONEFrrrrr rrrrr!c&t|tjrvt|jdkr^|j}|jd\}}|dvrCt ||r3t ||jr|dkr|p|dko| }|||SdS)zReturn a new constraint for node matched from expr, if expr matches the constraint pattern. Negate the constraint based on the value of negate. r>isis notr8r9rN) isinstancer Comparelenopsleft_matchesr5)rrr rr>oprights rr$zNoneConstraint.match6s dEM * * 5s48}}/A/A9D IB%%%t$$&)1%)H)H&*/SR8^5RF sV4444trr&r ctt|tjrdS|jt ||jz S)r(T)r:r UninferableBaserr?r5r)s rr*zNoneConstraint.satisfied_byJs9 h 4 5 5 4{Xh@@@@rr+r,r-) r.r/r0r1r Constr5__annotations__r2r$r*r#rrr4r41sy>>)ek$//J////NS[&AAAAAArr4r rframenodes.LocalsDictNodeNGrdict[nodes.If, set[Constraint]]cT|}i}|||ur|j}t|tjrt||\}}d}|dkr#t t ||j}n*|dkr$t t ||jd}|r|||<|}|||u|S)aHReturns the constraints for the given expression. The returned dictionary maps the node where the constraint was generated to the corresponding constraint(s). Constraints are computed statically by analysing the code surrounding expr. Currently this only supports constraints generated from if conditions. NbodyorelseT)invert)parentr:r If locate_childset_match_constrainttest)r rF current_nodeconstraints_mappingrMbranch_ constraintss rget_constraintsrXTs)-L;=  "|5'@'@$ feh ' ' :++L99IFA26K!"3D&+"F"FGG 8##!"3D&+d"S"S"STT  :.9#F+   "|5'@'@ rnode1nodes.NodeNG | bases.Proxynode2rrct|tjr*t|tjr|j|jkSt|tjrDt|tjr*|j|jkot |j|jSt|tjr*t|tjr|j |j kSdS)z$Returns True if the two nodes match.F) r:r Namename Attributeattrnamer?r rDvalue)rYr[s rr?r?vs%$$(E5:)F)F(zUZ''%))Uj.P.PU~/THUZ4T4TT%%%**UEK*H*H*{ek)) 5rFrrLIterator[Constraint]c#XKtD]}||||}|r|V dS)z3Yields all constraint patterns for node that match.N)ALL_CONSTRAINT_CLASSESr$)rr rLconstraint_cls constraints rrQrQsM1#))$f==     r)r rrFrGrrH)rYrZr[rrrr+)rrr rrLrrrb) r1 __future__rsysabcrrcollections.abcrtypingrastroidrr r astroid.typingr version_infortyping_extensions AssignAttrr_ AssignNamer]rrr4rX frozensetrdr?rQr#rrrss ON"""""" ########$$$$$$&&&&&&&&&&******w&&&&&& 5#U_e6F R S WWWWWWWW2 A A A A AZ A A AF<#N#455%    :?r