ʹF (UdZddlmZddlZddlZddlmZddlmZmZddl m Z m Z ddl m Z ddlmZmZmZddlZdd lmZmZmZdd lmZdd lmZdd lmZmZdd lmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1m2Z2ddl3m4Z4erddl5m6Z6ej7dkrddl8m9Z9nddl:m;Z9eej<ej=fZ>hdZ?ddhZ@ejAdejBdejCdejDdejEdejFdiZGejHddZIejHdd ZJdd$ZKdd'ZLdd*ZMdd-ZNdd0ZOGd1d2ZPePZQdd5ZRdd9ZSdd:ZTdd;ZUdd>ZVddAZWddGZXddIZYddNZZidOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpidqdrdsdtdudvgifdwdxdydzd{d|d}d~ddddddddddddddddddddddddddddddZ[de\d<ddZ]GddZ^GddeZ_ dddZ`dS)z Classes checker for Python code.) annotationsN) defaultdict)CallableSequence)chain zip_longest)Pattern) TYPE_CHECKINGAnyUnion)basesnodesutil)LocalsDictNodeNG)SuccessfulInferenceResult) BaseCheckerutils) PYMETHODSclass_is_abstractdecorated_withdecorated_with_propertyget_outer_classhas_known_basesis_attr_privateis_attr_protectedis_builtin_objectis_comprehension is_iterableis_property_setteris_property_setter_or_deleternode_frame_classonly_required_for_messages safe_inferunimplemented_abstract_methodsuninferable_final_decorators)HIGH INFERENCE)MessageDefinitionTuple)PyLinter)cached_property)cachedproperty>boolrangeslice memoryviewbuiltins.propertyzbuiltins.classmethodc"|j|jkSNvalueabs w/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pylint/checkers/classes/class_checker.pyr<<sag0c"|j|jkSr5qnamer8s r;r<r<=sAG!3r=c"|j|jkSr5eltsr8s r;r<r<>saf.r=c"|j|jkSr5rBr8s r;r<r<?sQVqv-r=c"|j|jkSr5)itemsr8s r;r<r<@sQW/r=ct|t|kSr5)setinferr8s r;r<r<As'S^^s17799~~=r=_CallSignaturez!args kws starred_args starred_kws_ParameterSignaturezargs kwonlyargs varargs kwargscall nodes.Callreturnci}g}g}g}|jpgD]q}|j|j}}|5t|tjr||jGt|tjr |j||<ld||<r|jD]}t|tj r?t|jtjr ||jj[t|tjr||j|dt||||Sr5) keywordsargr7 isinstancerNameappendnameargsStarredrJ)rLkwsrV starred_kws starred_argskeywordrQr7s r;_signature_from_callr\Os@ C DKL=&B  ['-U ;:eUZ88;   uz * * * * uz * * zCHHCHHy c5= ) ) jEJ.O.O      / / / / UZ ( (  KK ! ! ! ! KK     $\; ? ??r= argumentsnodes.Argumentsc|j}|j}dt|j|jD}d|jD}t ||||S)Nc2g|]}|jdk |jSselfrU.0rQs r; z-_signature_from_arguments..os1     8v      r=cg|] }|j Srcrds r;rfz-_signature_from_arguments..ts;;;s#(;;;r=)kwargvarargr posonlyargsrV kwonlyargsrK)r]rirjrVrls r;_signature_from_argumentsrmlsj OE  F  . ??   D <;i&:;;;J tZ ? ??r= definitionr/c4jrjjvrdSn jrdSjrjjvrdSn jrdSt fdjDrdSjjkrdStfdjDS)z8Check if a definition signature is equivalent to a call.Fc3*K|] }|jvVdSr5)rX)rekwrLs r; z1_definition_equivalent_to_call..s* > >"2TX  > > > > > >r=c3<K|]}|jvp|jvVdSr5)rVrl)rerqrLrns r;rrz1_definition_equivalent_to_call..s6QQ"rTY=" (="=QQQQQQr=) kwargsrYvarargsrZanyrlrVallrX)rnrLs``r;_definition_equivalent_to_callrxxs  D$4 4 45 5 u  T%6 6 65 7 u > > > > (= > > >>>u$)##u QQQQQQQQ Q QQr=functionnodes.FunctionDefc|r|jrdS|j}t|dkrdS|d}t |t jt jfsdS|j}t |t j rt |j t j sdSt|j j }t |tjjsdS|j j|jkrdS|j}|j|ks4t |jtjr|jj|jkrdSdS)zzCheck whether a function definition is a method consisting only of a call to the same function on the superclass. FrT) is_method decoratorsbodylenrRrExprReturnr7Callfunc Attributer#exprastroidobjectsSuperattrnamerUparentscope mro_pointertypeInstance)ryr statementrL super_call current_scopes r;_is_trivial_super_delegationrsK        u =D 4yyA~~uQI i%*el!; < <u ?D tUZ ( ($)U_55 uDIN++J j'/"7 8 8u yX]**uO))++M-//*/7+;<< 0 ? =#5 5 5u 4r=methodlist[nodes.AssignName]cl|jj}|r|jdvr |dd}|S)N>r classmethodr|)rVis_boundr)r positionals r;_positional_parametersrs>!J $V[,EEE^ r=ceZdZdZdS)_DefaultMissingz=Sentinel value for missing arg default, use _DEFAULT_MISSING.N)__name__ __module__ __qualname____doc__rhr=r;rrsGGGGr=roriginal overriddenc|j|jdSt|j|jD]} ||j}n!#t jj$r t}YnwxYw ||j}|turdSn'#t jj$r|turYYdSwxYwt|}t||sdSt |}|dS|||sdSdS)a,Check if original and overridden methods arguments have different default values. Return True if one of the overridden arguments has a default value different from the default value of the original argument If one of the method doesn't have argument (.args is None) return False NFT) rVrrl default_valuerUr exceptions NoDefault_DEFAULT_MISSINGrrRASTROID_TYPE_COMPARATORSget)rrparamoriginal_defaultoverridden_default original_type is_same_fns r;'_has_different_parameters_default_valuersk}  7ux}h&9:: 0'55ejAA  !+ 0 0 0/    0 !+!9!9%*!E!E #333tt4!+   #333444  -.. ,m<< 448P8T8T 9 9   44z*,>?? 44  5s#A  A'&A'+#BB65B6dummy_parameter_regex Pattern[str] list[str]cg}t||}|D]\}}|sdgcS|s; |j|j/#tj$rdgcYcSwxYwd||fD}t fd|Drs|j|jkr&|d|jd|jd|S)NNumber of parameters cg|] }|j Srhrc)rers r;rfz-_has_different_parameters..sLLLLLLr=c3BK|]}|VdSr5)match)rerUrs r;rrz,_has_different_parameters..s2CCT$**400CCCCCCr=z Parameter 'z' has been renamed to 'z' in)rrrrUrrrvrT)rrrresultzippedoriginal_paramoverridden_paramnamess ` r;_has_different_parametersrs@ F : . .F,2(( -+, , , , 1 1 '556F6KLLL$ 1 1 1/000000 1ML.:J)KLLL CCCCUCCC C C    "2"7 7 7 MM3n133',333    MsAAAcd|D}d|Dtfd|DrdgSD]B}||vr |dj|)#tj$rdgcYcSwxYwgS)zDDetermine if the two methods have different keyword only parameters.cg|] }|j Srhrcreis r;rfz:_has_different_keyword_only_parameters..'s///af///r=cg|] }|j Srhrcrs r;rfz:_has_different_keyword_only_parameters..(s3331333r=c3 K|]}|vV dSr5rh)rerUoverridden_namess r;rrz9_has_different_keyword_only_parameters..*s) C CD4' ' C C C C C Cr=rr)rvrrrr)rroriginal_namesrUrs @r;&_has_different_keyword_only_parametersr"s 0/h///N33 333 C C C CN C C CCC)'(( -- > ! !  - qM . .t 4 4 4 4  - - -+, , , , , , - Is A##A:9A:c g}t|}t|}|jj}|jjrd|D fd|D}|jjr.d|jjD fd|jjD}t |||}t ||jj}|rQ|rOd|dvr:d|dvr0|d||dd z }||dd z }n||z }||z }n|r||z }|r||z }|jtvr| |jjo |jj } |jjo |jj } | s| r|d gz }|S) aEDetermine if the two methods have different parameters. They are considered to have different parameters if: * they have different positional parameters, including different names * one of the methods is having variadics, while the other is not * they have different keyword only parameters. cg|] }|j Srhrcrevs r;rfz)_different_parameters..TsBBBqAFBBBr=c&g|] }|jv |Srhrcrerrs r;rfz)_different_parameters..Us-   af8H.H.HA.H.H.Hr=cg|] }|j Srhrcrs r;rfz)_different_parameters..ZsGGGqAFGGGr=c&g|] }|jv |Srhrcrs r;rfz)_different_parameters..[s-   16=M3M3MA3M3M3Mr=zNumber rrr|NzVariadics removed in) rrVrlrjrirrrTrUrclear) rrroutput_messagesoriginal_parametersoverridden_parametersoriginal_kwonlyargsdifferent_positionaldifferent_kwonly kwarg_lost vararg_lostrs @r;_different_parametersr9s2O0::2:>>#-2  BB,ABBB    *    GGJO,FGGG    }/   524I>Z_7 00 0 ,Q/ / /IAQRSAT4T4T  " "#: ; ; ; 3ABB7 7O /3 3OO 3 3O / /OO  4 3 3O  0 / /O} !! $BZ_-B)BJ-&Ez/E+EK4[4233 r=clsnodes.ClassDefc<|jtvot|Sr5)rUINVALID_BASE_CLASSESrrs r;_is_invalid_base_classrs 8+ + F0A#0F0FFr=attrstrcT||}|D]} |D]`}t|tjrD |d|ddS#tj$rY\wxYway#tj$rYdSwxYwdS)N__get____set__TF)getattrrIrRrr NotFoundErrorInferenceError)rr attributes attributeinferreds r;_has_data_descriptorrsT""J    %OO-- $ $h(899$$ ((333 ((333 $ttt#0!!! ! $ $%   444  5s50B *A:6B:B  B B  BB%$B%rrklassmethods Sequence[str]c&t|tjsdS|D]} ||}n#tj$rY*wxYw|D]}|tjD]} t|j }n#tj tf$rYBwxYwt|tj sa|j}t|tjr|j}|j|jkrdSdS)zCheck if the func was called in any of the given methods, belonging to the *klass*. Returns True if so, False otherwise. FT)rRr FunctionDefrrrnodes_of_classrnextrrIr StopIteration BoundMethod_proxied UnboundMethodrU) rrrrr infer_methodrLboundfunc_objs r;_called_in_methodsrsJ dE- . .u   }}V,,HH$    H $ L$33EJ??  !2!233EE. >H!%)<== >h(=>>1'0H=DI--4444.   5s!8A  A 3&BB3 2B3 rUc ||}n#tj$rYdSwxYwd}|D]}t|tjr t |}n#tj$rYQwxYwt|tj rt|rdS| |krt|}||krdSdS)a/Check if the given attribute *name* is a property in the given *klass*. It will look for `property` calls or for functions with the given name, decorated by `property` or `property` subclasses. Returns ``True`` if the name is a property in the given klass, ``False`` otherwise. Fr3T)rrrrRrUninferableBaserrIrrrrpytyper!declared_metaclass)rUrr property_namerrrs r;_is_attribute_propertyrs(]]4((  uu'M dD0 1 1   DJJLL))HH%    H  h 1 2 2 7N 8 8  44 ??   - - x(( %**,, , , tt 5s++!A22BBslotslist[nodes.Const | None]assigned_value nodes.Namect|}t|tjr=|}t dt||DrdSdS)Nc3DK|]\}}|o|o|j|jkVdSr5r6)re first_slot second_slots r;rrz)_has_same_layout_slots..sO  )[  P; P:+;{?P+P      r=TF)rrIrRrClassDefrrwr)rrr other_slotss r;_has_same_layout_slotsr sN((**++H(EN++nn&&   -8 -L-L      4 5r=F0202)z+Unable to check methods signature (%s / %s)method-check-failedzUsed when Pylint has been unable to check methods signature compatibility for an unexpected reason. Please report this kind if you don't make sense of it.E0202)z4An attribute defined in %s line %s hides this method method-hiddenz~Used when a class defines a method which is hidden by an instance attribute from an ancestor class or set by some client code.E0203)z1Access to member %r before its definition line %saccess-member-before-definitionzGUsed when an instance member is accessed before it's actually assigned.W0201)z%Attribute %r defined outside __init__attribute-defined-outside-initzGUsed when an instance attribute is defined outside the __init__ method.W0212)z1Access to a protected member %s of a client classprotected-accesszUsed when a protected member (i.e. class member with a name beginning with an underscore) is access outside the class or a descendant of the class where it's defined.W0213)z=Flag member %(overlap)s shares bit positions with %(sources)simplicit-flag-aliaszdUsed when multiple integer values declared within an enum.IntFlag class share a common bit position.E0211)zMethod %r has no argumentno-method-argumentzbUsed when a method which should have the bound instance as first argument has no argument defined.E0213)z.Method %r should have "self" as first argumentno-self-argumentzUsed when a method has an attribute different the "self" as first argument. This is considered as an error since this is a so common convention that you shouldn't break it!C0202)z0Class method %s should have %s as first argumentbad-classmethod-argumentzUsed when a class method has a first argument named differently than the value specified in valid-classmethod-first-arg option (default to "cls"), recommended to easily differentiate them from regular instance methods.C0203)z4Metaclass method %s should have %s as first argumentbad-mcs-method-argumentzUsed when a metaclass method has a first argument named differently than the value specified in valid-classmethod-first-arg option (default to "cls"), recommended to easily differentiate them from regular instance methods.C0204)z:Metaclass class method %s should have %s as first argumentbad-mcs-classmethod-argumentzUsed when a metaclass class method has a first argument named differently than the value specified in valid-metaclass-classmethod-first-arg option (default to "mcs"), recommended to easily differentiate them from regular instance methods.W0211)z'Static method with %r as first argumentbad-staticmethod-argumentzUsed when a static method has "self" or a value specified in valid-classmethod-first-arg option or valid-metaclass-classmethod-first-arg option as first argument.W0221)%s %s %r methodarguments-differzUsed when a method has a different number of arguments than in the implemented interface or in an overridden method. Extra arguments with default values are ignored.W0222)z#Signature differs from %s %r methodsignature-differszgUsed when a method signature is different than in the implemented interface or in an overridden method.W0223)zIMethod %r is abstract in class %r but is not overridden in child class %rabstract-methodzbUsed when an abstract method (i.e. raise NotImplementedError) is not overridden in concrete class.W0231)z0__init__ method from base class %r is not calledsuper-init-not-calledzaUsed when an ancestor class method has an __init__ method which is not called by a derived class.W0233)z9__init__ method from a non direct base class %r is callednon-parent-init-calledznUsed when an __init__ method is called on a class which is not in the direct ancestors for the analysed class.W0246z1Useless parent or super() delegation in method %ruseless-parent-delegationzUsed whenever we can detect that an overridden method is useless, relying on parent or super() delegation to do the same thing as another method from the MRO. old_names)W0235zuseless-super-delegationW0236)z7Method %r was expected to be %r, found it instead as %rinvalid-overridden-methodzUsed when we detect that a method was overridden in a way that does not match its base class which could result in potential bugs at runtime.W0237)r$arguments-renamedzoUsed when a method parameter has a different name than in the implemented interface or in an overridden method.W0238)zUnused private member `%s.%s`unused-private-memberzAEmitted when a private member of a class is defined but not used.W0239)zUMethod %r overrides a method decorated with typing.final which is defined in class %roverridden-final-methodzCUsed when a method decorated with typing.final has been overridden.W0240)zAClass %r is a subclass of a class decorated with typing.final: %rsubclassed-final-classzBUsed when a class decorated with typing.final has been subclassed.W0244)zRedefined slots %r in subclassredefined-slots-in-subclassz-Used when a slot is re-defined in a subclass.W0245)zSuper call without bracketssuper-without-bracketsznUsed when a call to super does not have brackets and thus is not an actual call and does not work as expected.E0236)zCInvalid object %r in __slots__, must contain only non empty stringsinvalid-slots-objectz=Used when an invalid (non-string) object occurs in __slots__.E0237)z4Assigning to attribute %r not defined in class slotsassigning-non-slotzCUsed when assigning to an attribute not defined in the class slots.E0238)zInvalid __slots__ object invalid-slotszhUsed when an invalid __slots__ is found in class. Only a string, an iterable or a sequence is permitted.E0239)z$Inheriting %r, which is not a class.inherit-non-classz?Used when a class inherits from something which is not a class.E0240)z1Inconsistent method resolution order for class %rinconsistent-mroz>Used when a class has an inconsistent method resolution order.E0241)zDuplicate bases for class %rduplicate-baseszBDuplicate use of base classes in derived classes raise TypeErrors.E0242)z/Value %r in slots conflicts with class variableclass-variable-slots-conflictzSUsed when a value in __slots__ conflicts with a class variable, property or method.E0243)zNInvalid assignment to '__class__'. Should be a class definition but got a '%s'invalid-class-objectz[Used when an invalid object is assigned to a __class__ property. Only a class is permitted.E0244)z#Extending inherited Enum class "%s"invalid-enum-extensionzfUsed when a class tries to extend an inherited Enum class. Doing so will raise a TypeError at runtime.)z9Consider using a decorator instead of calling classmethodno-classmethod-decoratorzGUsed when a class method is defined without using the decorator syntax.)z:Consider using a decorator instead of calling staticmethodno-staticmethod-decoratorzHUsed when a static method is defined without using the decorator syntax.)z/Class __slots__ should be a non-string iterablesingle-string-used-for-slotszHUsed when a class __slots__ is a simple string, rather than an iterable.)zJClass %r inherits from object, can be safely removed from bases in python3useless-object-inheritancezoUsed when a class inherit from object, which under python3 is implicit, hence can be safely removed from bases.)z-Cannot have defined parameters for propertiesproperty-with-parameterszUsed when we detect that a property also has parameters, which are useless, given that properties cannot be called with additional arguments.)R0202R0203C0205R0205R0206z!dict[str, MessageDefinitionTuple]MSGS$defaultdict[str, list[_AccessNodes]]c*ttSr5)rlistrhr=r;_scope_defaultr`s t  r=c*eZdZdZd dZddZdd Zd S)ScopeAccessMapz'Store the accessed variables per scope.rNNonec8tt|_dSr5)rr`_scopesras r;__init__zScopeAccessMap.__init__s  ' ' r=node _AccessNodesct|}|dS|j||j|dS)zSet the given node as accessed.N)r!rerrTrbrgframes r; set_accessedzScopeAccessMap.set_accessedsC!&& = F UDM*11$77777r=rrdict[str, list[_AccessNodes]]c8|j|iS)z/Get the accessed variables for the given scope.)rer)rbrs r;accessedzScopeAccessMap.accesseds|r***r=NrNrc)rgrhrNrc)rrrNrm)rrrrrfrlrorhr=r;rbrbsV11(((( 8888++++++r=rbceZdZdZdZeZddddddfd d dd d dfd ddd ddfddddddfddddddffZdfd ZddZ e dd Z e d!d"d#d$d%d&d'd(d)d*d+d,d- dd0Z dd1Zdd3Zdd4Zdd5Ze d6d7d8dd9Zdd:Zdd;Zdd<Zdd>Zdd@ZeZddBZddCZddFZddGZddLZddOZddPZeZ ddRZ!ddSZ"e dTdUd8ddWZ#ddXZ$ddYZ%e dZd[d\dd_Z&dd`Z'ddbZ(e)dddZ*ddfZ+e)ddiZ,e)ddkZ-e)ddnZ.ddqZ/ddsZ0ddzZ1dd{Z2dd}Z3ddZ4ddZ5ddZ6xZ7S) ClassCheckerzChecker for class nodes. Checks for : * methods without self as first argument * overridden methods signature * access only to existent members via self * attributes not defined in the __init__ method * unreachable code classeszdefining-attr-methods)rf__new__setUp asyncSetUp __post_init__csvzzGList of method names used to declare (i.e. assign) instance attributes.)defaultrmetavarhelpzvalid-classmethod-first-argrzz=List of valid names for the first argument in a class method.z%valid-metaclass-classmethod-first-arg)mcszGList of valid names for the first argument in a metaclass class method.zexclude-protected)_asdict_fields_replace_source_makezos._exitzzQList of member names, which should be excluded from the protected access warning.z)check-protected-access-in-special-methodsFynzz.s+VV41aQRUXXQXXXXVVr=r<.: >, c3tK|]2}djd|djd|dd|d|zd V3dS) rrrrz> (z & z = )Nrc)resource assignmentsrgoverlaps r;rrz0ClassChecker._check_enum_base..s11%+!ODI!O!O F0CA0F0K!O!Ov!O!O$+!O!O06!O!O;BV;K!O!O!O111111r=)rsourcesrgrVr)rrRrDictrFrrUr' is_subtype_ofrr_r AssignNamerAssignr7intrTrH enumeratereversedbinaddvaluessortedjoin)rbrgrmembers assign_namer7 bit_flagsflag flag_bitsbitoverlapsflagsr conflictsconflictassignment_noderrs ` @@r;_check_enum_basezClassChecker._check_enum_base{s""=11  z'!*ej99 gaj>N    (]$      ! !. 1 1& %d++K#2253CDD ? ? k0%,???#K$6$>>$C((I# - -VV9Xc$ii5H5H+I+IVVV $--CcN&&t,,,,-#4((H"))++ 6 6%+E]]" )66HX&--f55556$  '27';  O$$-,'Y49'Y'Y7K'Y'Yw'Y'Y'Y'+yy111111/7w.?111(($-%     3& & 0  r=c6|jD]}t|}|st|tjr|drEt|t jrt|r*| d| |t|t jr+|dr| |||j tjkr| d|j |dS)zWDetect that a class inherits something which is not a class or a type. z builtins.typerGrz enum.EnumrUN)r r#rRrrrrrrr as_stringrrUobjectrrbrgbasers r;rz ClassChecker._check_proper_basess;J  D!$''H (G$455 (:P:P;; h77 X;Q<< X  !44>>;K;KRV WWW(EN33 68N8N99 6%%dH555}//  0tyt!)  r=c|jsdS|jD]w}t|}|st|tjrIt |dgst|jr$| d|j |j f|xdS)z]Detect that a class does not subclass a class decorated with `typing.final`. N typing.finalr;r) rr r#rRrrrr%r~rrUrs r;rz ClassChecker._check_typing_finals  FJ  D!$''H (EN33 x.)9:: /0CDD   ,)X]3!  r=r7rrc||||||||dS)zChecker for Class nodes. check that instance attributes are defined in __init__ and check access to existent members N)_check_unused_private_functions_check_unused_private_variables _check_unused_private_attributes%_check_attribute_defined_outside_initrs r;leave_classdefzClassChecker.leave_classdefsZ ,,T222 ,,T222 --d333 22488888r=c ,|tjD]r}t|js|j}t|tjr1|jd|tjDvr||tjtj fD] }t|tjr|j|jkrnt|tj r|j |jks||krst|j tjr|j jdd|jhvrn t|j tj r@t|j }t|tjr|j|jkrn g}|}||kr9||j|j}||k9dt#|}|d|jd|jd} |d||j| dftdS) Nc3$K|] }|jV dSr5rc)rens r;rrz?ClassChecker._check_unused_private_functions..s5)) AF))))))r=rbrr(rr7rgrV)rrrrrUrrrRrSrrrrr#rrTrrrVrrlstrip) rbrg function_def parent_scopechildr name_stackcurrouter_level_names function_reprs r;rz,ClassChecker._check_unused_private_functionss //0ABB5 5 L"<#455 '.4466L,(9:: $))$0$?$? $K$K))),,ej%/-JKK+ + eUZ00UZ%>?!c5 5 r=c~|tjD]}t|jtjr#t |js8|tjtj fD]}t|tjr|j|jkrnt|tj rIt|j tjsnO|j |jkr|j jdd|jfvrn'|j|jf}| d||dS)z9Check if private variables are never used within a class.rbrr7rN) rrrrRr ArgumentsrrUrSrrrr)rbrgrrrVs r;rz,ClassChecker._check_unused_private_variables&sE..u/?@@ W WK+,eo>> ";#344 ,,ej%/-JKK W WeUZ00UZ;CS5S5SEeU_55%ej%*==~)999ejo R??  ;#34  !8{QU VVV' W Wr=c|tjD]}t|jrt |jtjs7dg}|}t |tj rG|j dkr<| d|tj D|tj D]}|j|jkrt |jtjs3|jj d|j hvr|jj dd|j hvrnr|jj |vr|jj dkrnR|jj |jj cxkr |j krnn'|j |jf}|d||dS)Nrbrtcdg|]-}t|jtj!|jj.Srh)rRr7rrSrU)re return_nodes r;rfzAClassChecker._check_unused_private_attributes..KsC'%k&7DD#).r=rr7r)rr AssignAttrrrrRrrSrrrUextendrrr)rbrg assign_attracceptable_obj_namesrrrVs r;rz-ClassChecker._check_unused_private_attributes=s ..u/?@@0 W0 WK";#788   %*AA  06h %%''E%!233  i8O8O$+++0+?+? +M+M"00AA W W %)===!).%*==#(I- n)eVTY-GGGE $)-AAA!+v55E#(IN,?LLLL49LLLLLEM  ;#78  !8{QU VVVa0 W0 Wr=cnodec d|jjjvr!|j|jrdS|j|}|jdkr| |||j dsdS|jjj | |j D] \}}|dkr fd|D}|sd|D}t fd|DrF||D]7}d}|j |D]!}|d j vrd}"|rn8 ||#t&j$rd|D]]}|d j vr>t+|d | rE|d|| ^YwxYw"dS) Nr metaclass__dict__cg|]T}t|dtjtjfs|uR|US)Tfuture)rRrrDelete AugAssignroot)rercurrent_modules r;rfzFClassChecker._check_attribute_defined_outside_init..sh!KKtK,,u|U_.M FFHH..  /..r=c3BK|]}|dVdS)TrN)rk)rergs r;rrzEClassChecker._check_attribute_defined_outside_init..s0DD$djjj--DDDDDDr=c3HK|]}|jvpt|VdSr5)rUr)rerkdefining_methodss r;rrzEClassChecker._check_attribute_defined_outside_init..sM ..K2DU2K2Kr=FTrr)rrignored_checks_for_mixinsrrrUrror_check_accessed_membersis_message_enableddefining_attr_methodsrinstance_attrsrFrvinstance_attr_ancestorsrk local_attrrrrr) rbrror nodes_lstframesr attr_definedrgrrs @@r;rz2ClassChecker._check_attribute_defined_outside_initps -{!; < <%++EJ77 < F>**511 : $ $  ( ( 9 9 9{--.NOO  F;-C$399;;5 5 OD)z!!"I ED)DDDF#  77==  $ "1$7,,Dzzz..37GGG'+ E $$T****,    )  ::T:227?OOO 2 $ $ 7 7@P  )!) ,, @tRV-    I5 5 s E66A/G)(G)rzc|sdS|||||jd}|||jdk|jdkr|||dS| |jD]i} ||j}n#t$rYwxYwt|tj s<||||||||jr2|jj D]$}t|tjr |jdvrdSt|tjr|jdkrdSt)|}|sdSt|tj r; t+||}n#t.j$rYdSwxYw t|t.jtjfr-|dr|d rdS#t.j$rY"wxYw ||jd }|d}t|tj r&|jd kr|jd}t|tjr'||sdS| D]h}|j|j!vrtE|jrdS|#|jd D] } t| tj rdS!i|$j|j%f} |&d | |dS#t.j'$rYdSwxYw)z#Check method arguments, overriding.NTrrrf>gettersetterdeleterpropertyrrrrr|rr)(r}_check_useless_super_delegation_check_property_with_parametersrrk_check_first_arg_for_typerrU _check_initlocal_attr_ancestorsKeyErrorrRrr_check_signature _check_invalid_overridden_methodr~rrrSr#rinfer_call_resultrrrrrAttributeInferenceError instance_attrrr@ ancestorsrrlookupr fromlinenorr) rbrgrrparent_function decoratorroverridden_framerobjrVs r;visit_functiondefzClassChecker.visit_functiondefsT~~  F ,,T222 ,,T222!% 1 1 1 > > &&tUZ;-FGGG 9 " "   T5 ) ) ) F44TY??  J ",TY"7      ou/@AA   ! !$ ? ? ?  1 1$ H H H  ?! !_2   i99i>PU?? FFi44 ~33&i00FFh(9::#'(B(B8(L(L#M#M"1"8g.>-OPP$,,Y77%,,Y77 6D  ,,TY77:J)//t/<< +U->?? N$)X55#3#:#@#@#@#M#M +U^<< ''(8(>(>(@(@AA "OO--  9 777ODIO :O O O rycZt|sdS|jdj}|jdkr*|jD]}|jdkrdS|jd}d}||jD]}} ||j}n#t$rYwxYwt|tj r?t|j |j s%|j j |dgkrdSt|j }t!|}||j jrB|j jr4t%|j j t%|j j krdSdd } | |j } | |j } | r | r| | krdS|j=|j6|j|jkrdSt+||r&|d ||jft.dSdS)aRCheck if the given function node is an useless method override. We consider it *useless* if it uses the super() builtin, but having nothing additional whatsoever than not implementing the method at all. If the method uses super() to delegate an operation to the rest of the MRO, and if the method called is the same as the current one, the arguments passed to super() are the same as the parameters that were passed to this method, then the method could be removed altogether, by letting other implementation to take precedence. Nr__hash____eq__Trrbr]r^rNrcRt|jpg|j}d|DS)Nc:g|]}||Sr5)r)reanns r;rfzZClassChecker._check_useless_super_delegation..form_annotations..]s!RRRC#/ ///r=)rposonlyargs_annotationsr)r]rs r;form_annotationszFClassChecker._check_useless_super_delegation..form_annotationsYs8#6<"y?T SR;RRRRr=r/r)r]r^rNr)rrr7rUr mymethodsrkrrrRrrrrVargnamesrmr\rjrreturnsrrxrr') rbryrL other_methodr meth_noderparamsrVr'called_annotationsoverridden_annotationss r;r z,ClassChecker._check_useless_super_delegations,H55  F#=+1 =J & & ( 9 9 ; ;   $00FF1%%T%22 44X]CC  J &x}5       y%*;<< ;NHM N'/H4E4E4G4GF84S4S +8=99#D))  ~$ M( x})**S1D-E-EEE S S S S "2!1(-!@!@ %5%5in%E%E "! &< %)???F ,%1%//11X5E5O5O5Q5QQQ )&$ 7 7    +m%$        s B!! B.-B.c|jjrTt|jjdkr9t|r,t|s|d|dSdSdSdSdS)Nr|rVrg)rVrrrrrs r;rz,ClassChecker._check_property_with_parametersus IN DDIN##a'''--(&t,,(   7d  C C C C C  D D''''''r= function_nodeparent_function_nodect|pt|}t|pt|}|r(|s&|d|jd|jf|n$|s"|r |d|jddf|t |t j}t |t j}|r#|s!|d|jddf|n$|s"|r |d|jddf|t|dgst|j rF|j r=|d|j|j jf|dSdSdS) Nr3r rrasyncz non-asyncrr9)rr rrUrrRrAsyncFunctionDefrr%r~rrrk)rbr2r3parent_is_propertycurrent_is_propertyparent_is_asynccurrent_is_asyncs r;rz-ClassChecker._check_invalid_overridden_method~s& 5   A *+? @ @ 6   : *= 9 9   &9    +#(*m6HI"      $ (;    +#((J?"     %%95;QRR%mU5KLL  #3    +#(';?"      ! %5    +#(+w?"     /.1A B B +,@,KLL o    )#(*>*E*K*K*M*M*RS"           r=cd|jvrdS|dD]:}t|tjrt |s't |s|d|Tt|tj r|d|t|dst|tj rd|j D}n| }t|tjr|D].} |||#tj$rY+wxYw||||.s:::d$q':::r=)localsilookuprRrrrrrrConsthasattrrrFr=_check_slots_eltrr_check_redefined_slots)rbrgrrelts r;rzClassChecker._check_slotss dk ) ) F\\+.. = =E%!566 u%% .>u.E.E   t <<<%--   !?d KKK5(++ %,, (::ek:::&$"677   ))#t4444-H  ' 'eV < < < <7 = =sD//EE slots_node nodes.NodeNG slots_listlist[nodes.NodeNG]c g}|D]}t|tjr||j7t |}t |dd}t|tr||d|dD}| | r'| d fd|Df|dSdS)zGCheck if `node` redefines a slot which is defined in an ancestor class.r7NcNh|]"}|pgD] }|j #Srh)rr7)rerslots r; z6ClassChecker._check_redefined_slots..sP! ! !  ((.B! !  J! ! ! ! r=r<r=cg|]}|v| Srhrh)rerUredefined_slotss r;rfz7ClassChecker._check_redefined_slots..s#OOOt7N7Nt7N7N7Nr=r) rRrrCrTr7r#rrr intersectionr) rbrgrHrJ slots_namesrN inferred_slotinferred_slot_valueancestors_slots_namesrQs @r;rFz#ClassChecker._check_redefined_slotss)"$  <    *( !"[__X^<:KRU!;  r=c|r'|jj|jdSdSdS)zOn method node, check if this method couldn't be a function. ignore class, static and abstract methods, initializer, methods overridden from a parent class. N)r}rVrpoprs r;leave_functiondefzClassChecker.leave_functiondefsK >>   (y~)!%%''''' ( ())r=nodes.Attributec||||r|j|dS|jdsdS||dS)zCheck if the getattr is an access to a class member if so, register it. Also check for access to protected class member from outside its class (but ignore __special__ methods) Nr)_check_super_without_brackets_uses_mandatory_method_paramrrlrr!_check_protected_attribute_accessrs r;visit_attributezClassChecker.visit_attribute#s **4000  , ,T 2 2  N ' ' - - - F{--.@AA  F ..t44444r=c|}t|tjsdSt|jtjsdSt|jtjsdSt|jtjsdS|jj dkr$| d|jtdSdS)zCCheck if there is a function call on a super call without brackets.Nrr?)rgr) rkrRrrrrrrrSrUrr&rjs r;r_z*ClassChecker._check_super_without_brackets6s %!233  F%,,,..??  F$+uz22  F$)UZ00  F 9>W $ $   5DIRV  W W W W W % $r=rCrOnodes.AssignAttrct|tjr/||r|j|||||dSr5) rR assign_typerrr`rrl_check_in_slots_check_invalid_class_objectrs r;visit_assignattrzClassChecker.visit_assignattrEs         .//55 . N ' ' - - - T""" ((.....r=c|jdksdSt|jtjrpd}t |jjD]"\}}t|dr |jdkr|}#|dkrdSt|jjj j|}nt|jj }t|tj tj fs|dS| d||jjt dS)NrrrOr)rrRrrTuplerrCrDr#r7rrrrrrr')rbrg class_indexrrGrs r;rhz(ClassChecker._check_invalid_class_objectPs} ++ F dk5; / / 5K#DK$455 $ $33 ++$ 0K0K"#Kb  !$+"4":"? "LMMHH!$+"344H x%.$2F!G H H  F  "#,      r=ctj}t|tjsdS|j}t |sdSd|jvs|jsdStd| DrdStd| Dr5t|dd}|r"| |j ||j =| }|dStd|DrdStfd|Ds&td|Dstj|rdSjd krt#jj|rdSj|jvrs|j jD]<}|d }t|t(jr |jsdS=t/|jrdSjd krt1|jjrdS|d jft6 dSdSdS)zTCheck that the given AssignAttr node is defined in the class slots. Nr<c3zK|]6}|dk|jdV7dS)zbuiltins.object __setattr__N)r@rArrers r;rrz/ClassChecker._check_in_slots..{sP  zz||000 KOOM * *0000  r=c3FK|]}|dkVdS)ztyping.GenericNr?rqs r;rrz/ClassChecker._check_in_slots..s0HHDtzz||//HHHHHHr=__cachec3>K|]}d|jvo |jdkVdS)r<rN)rArU)rers r;rrz/ClassChecker._check_in_slots..sI   x . L8=H3L      r=c38K|]}|jjkVdSr5)r7r)rerNrgs r;rrz/ClassChecker._check_in_slots..s,AA44:.AAAAAAr=c3,K|]}|jdkVdS)rNr6)rerNs r;rrz/ClassChecker._check_in_slots..s)BBDtzZ/BBBBBBr=rTrrCr)r#rrRrrrrrAnewstylervrrrrrrrr is_class_attrrrrXr7rr rrr')rbrgrrcacher local_namers ` r;rgzClassChecker._check_in_slotslsdi(((G$455  F!u%%  F el * *%. * F           F HHEIIKKHHH H H 'E9d33E '5;//;%+&  = F   !OO--       FAAAA5AAAAA BBEBBBBB )$-??F=K//E4GM555/F=EL00&+l&6&6t}&E&E## $.$8$8$8$E$E &y%/BB#$-O##FF+E4=AA=K//4J4;,55/F  (-)( !7    r=rrRrS assign_node nodes.Assignc|||jd}t|tjsdS||rdS||dSNr)_check_classmethod_declarationtargetsrRrrr`ra)rbr{rgs r; visit_assignzClassChecker.visit_assignst ++K888"1%$ 011  F  , ,T 2 2  F ..t44444r=c6t|jtjsdS|jj}t|tjr |jdvrdS|jdkrdnd}|}t|tjsdS|jj d}t|tjsdS|jtfd| Dr$| ||j ddSdS) a\Checks for uses of classmethod() or staticmethod(). When a @classmethod or @staticmethod decorator should be used instead. A message will be emitted only if the assignment is at a class scope and only if the classmethod's argument belongs to the class where it is defined. `node` is an assign node. N)r staticmethodrrRrSrc3.K|]}|jkVdSr5rc)remember method_names r;rrz>ClassChecker._check_classmethod_declaration..s*QQf{fk)QQQQQQr=r1)rRr7rrrrSrUrrrVrvr(rr)rbrgrmsg parent_class classmeth_argrs @r;rz+ClassChecker._check_classmethod_declarations2$*ej11  Fz$ ++ tyA 0 0  FyM)) ' &, zz|| ,77  F * -44  F#( QQQQ 8N8N8P8PQQQ Q Q 8   St|A  7 7 7 7 7 8 8r="nodes.Attribute | nodes.AssignAttrc |j}t|r||jjjvrdSt j|rdSt|j}|rEt|tj tj fr|j d||jjjvrdSt|}||d||dSt|jtjr;t|jjtjr|jjj dkrdS||jrdSd}|}|j}|d}||D]"}|r ||j krd}nt/|}#|sV||jvsN|jd} t| tjrat9| jd krIt| jd tjr$| jd j } t?| |rdS| |!dr3|"|j|r|#||rdS|$d  } |jjj%s| r|&|rdS|d||dSdSdS) aGiven an attribute access node (set or get), check if attribute access is legitimate. Call _check_first_attr with node before calling this method. Valid cases are: * self._attr in a method or cls._attr in a classmethod. Checked by _check_first_attr. * Klass._attr inside "Klass" class. * Klass2._attr inside "Klass" class when Klass2 is a base class of Klass. NrrrrTFrr|r__)'rrrrexclude_protectedr"is_node_in_type_annotation_contextr#rrRrrModulerUr!rrrrS_is_type_self_callrsplitreverser basenamesrrrrrrr_is_classmethodrk_is_inferred_instance_is_class_or_instance_attribute startswith)check_protected_access_in_special_methods _is_called_inside_special_method) rbrgrrr inside_klass outer_klasscalleeparents_calleestmtrUlicit_protected_members r;raz.ClassChecker._check_protected_attribute_accesssI="(++ 4;-??? F  3D 9 9  Fdi((  8enel%CDD =--8--1C1UUU F && =   /d  J J J F ty%* - - 49>5:66  #w.. F  " "49 - -  F  $$&&c**   $ 7 7F &K,<"<"<$ *+66KK K%/ 9 9;(((55D4..  %%**t|A0@AA+|A+)$66F$$TZZtZ%<%<== ..ty%@@ 885II  )1)<)49ej11 > &( >DI!# >// ! ==  r=rrcbt|tjo|jdkp |jdkS)z1Check if the given *func* node is a class method.r__class_getitem__)rRrrrrU)rs r;rzClassChecker._is_classmethodds5$ 122 I & J$)7J*J r=rcjt|}t|tjsdS|j|uS)z[Check if the inferred value of the given *expr* is an instance of *klass*. F)r#rRrrr)rrrs r;rz"ClassChecker._is_inferred_instanceks9 d##(G$455 5 E))r=rUrctj||rdS ||dS#tj$rYdSwxYw)zCheck if the given attribute *name* is a class or instance member of the given *klass*. Returns ``True`` if the name is a property in the given klass, ``False`` otherwise. TF)rrxrrr)rUrs r;rz,ClassChecker._is_class_or_instance_attributeusa  tU + + 4     % % %4$   55 s0AArormc2 d}|D]|\} ||#tj$rYnwxYw t ||V#t $rYnwxYw ||} fd|D}|s|d fdt|D}t|dkr|d}| d}|j } D]i} | d|urO| j |krDtj | d||s|d| ||f jh#tj$rYzwxYwd S) z(Check that accessed members are defined.)AttributeError Exception BaseExceptioncg|]}|v| Srhrh)rerrs r;rfz8ClassChecker._check_accessed_members..s#OOOTY9N9ND9N9N9Nr=rcRg|]#\}}|dks|u!|$Sr?)r)rerrrs r;rfz8ClassChecker._check_accessed_members..sB4AvvU!:!:!:!:!:r=r|TrrrN)rFrrrrrrrrrrrkr are_exclusiverr) rbrgroexcsrdefstmtsdefstmtrklno_noderrs @@r;rz$ClassChecker._check_accessed_memberss)@'~~//7 7 OD) %%%(     T11$77888     ' --d33 POOOXOOO! ))++#,X#6#6x==A%%&qkG$MMM66E!,C!*  !KKtK44== % 03 6 6$+$9 %t < ! F 9   -a05II Y^  *III   +++!"% 9 & &V## 2 NNN 2 XXX  !<5t TTT$(D b ! ! ! $(;(;(=(= = = F IN& Ly$& Ly& Ly & L   149  M M M M M  LyM)),,K&L2I ,,K&B-I Y- ' '498K+K+K  ( ( ">*      f__   /d  K K K K K_r=r str | Nonerrmessagerc||vryt|dkrt|d}n4dd|ddD}|d|d}||||f|dSdS)Nr|rrc34K|]}t|VdSr5)reprrs r;rrz7ClassChecker._check_first_arg_config..s(!?!?a$q''!?!?!?!?!?!?r=rkz or r)rrrr)rbrrrgrrvalids r;rz$ClassChecker._check_first_arg_configs   6{{aVAY !?!?6#2#;!?!?!??? 44fRj44   WK+?d  K K K K K  r=cNd d}t|rdStt||d}|D]Z\}}|jd }||ur%||jvr/|d |||j|jft [dS)z_Check that the given class node implements abstract methods from base classes. rrzrNr/c.|dS)NF)pass_is_abstract) is_abstract)rs r;rz6ClassChecker._check_bases_classes..is_abstract(s%%u%== =r=Nc|dSr~rh)r@s r;r<z3ClassChecker._check_bases_classes..1s T!Wr=)keyTrr)r)rrzrNr/) rrr$rFrrkrArrUr')rbrgrrrUrowners r;rz!ClassChecker._check_bases_classes#s  > > > > T " "  F *4 = = C C E E$$   $  LD&M''t'44E}}t{""   !EJ 2$       r= klass_nodec|jds|jdsdSt|}t|}t }|t jD]}|j}t|t j r |j dkr0t|j t jrAee!'' 33* * D9DdEO44  8S8S49ej11 ty~uz:: IN'722 !Y__..E!%)=>>! #5'*:;;&u~u~FF.en=="N/7::!%)>??!/!3!3E!:!:1556Fv6N6NOOOO# (<()?)?&|*0*a/*|)0*a/*|.K*c',2I.J.JJ*+.y~/B+C+C( ~,2,1, ~+2,1, ~0O,IN4M0N0NN,!3J:!5::I//116GGGG  HH#%%!4J"">//116GGGG HH "4J"">//116GGGG H   ( IIIIM& J& JP  % & &Y^-D)E)E E EL' F&J   #:w|*D7       F E E Er=1nodes.Attribute | nodes.Assign | nodes.AssignAttrc6||jS)zCheck that attribute lookup name use first attribute variable name. Name is `self` for method, `cls` for classmethod and `mcs` for metaclass. )rrrs r;r`z)ClassChecker._uses_mandatory_method_params..ty999r=c2|jr|jd}n^tj|tj}|dS|sdS|jjsdS|jjdj}t|tj o |j|kS)zCheck if nodes.Name corresponds to first attribute variable name. Name is `self` for method, `cls` for classmethod and `mcs` for metaclass. Static methods return False. rkNFr) rrget_node_first_ancestor_of_typerrrrVrUrRrS)rbrg first_attr closest_funcs r;rz'ClassChecker._is_mandatory_method_params   8*2.JJ!@e'L#u((** u$) u%*/27J$ ++G Z0GGr=)rr)rNrcrp)rNr)rgrrNrc)rgrrrrNrc)rrrNrc)rgrzrNrc)ryrzrNrc)r2rzr3rzrNrc)rgrrHrIrJrKrNrc)rGrrgrrNrc)rgr]rNrc)rgrdrNrc)r{r|rNrc)rgr|rNrc)rgrrNrc)rgrIrNr/)rrIrNr/)rrrNr/)rrIrrrNr/rUrrrrNr/)rgrrormrNrc)rgrzrr/rNrc) rrrrrgrzrrrrrNrc)rgrzrrrNrc)rrzrrzrrrNrc)rgrrNr/)8rrrrrUr\msgsoptionsrfrr-rr"rrrrrrrrrrrvisit_asyncfunctiondefr rrrrFrEr\leave_asyncfunctiondefrbr_rirhrgrrrarrrrrrrrrrrrr`r __classcell__)rs@r;rrrrs D D $+   " *#-     4#-     :9   * 8 %V    sBGH111111 //// 666_6 &'$%  ))))KKKK0000d8* () 9 9 9  96666pWWWW.1W1W1W1WfIIIIX]]]]~/VVVVpDDDD0000d====B    D""""H((((/5555& X X X X 46W////    8HHHHT 68S5555%8%8%8%8NiKiKiKiKV666\6        \ ***\*\"<<<<|LLLLLLLL\LLLL BFFFFPUUUUn::::HHHHHHHHr=rrrfrr)dict[nodes.ClassDef, bases.UnboundMethod]ci}|dD]o} t||}t|tjs@|rU|||<[#tj$rYlwxYw|S)zReturn a dictionary where keys are the list of base classes providing the queried method, and so that should/may be called from the method node. Fr)rrigetattrrRrrrr)rrr base_node init_nodes r;rr s :?? $$&& !*GI  %    H  Nsr s '&&"""""" ######........((((((((,,,,,,,,,,&&&&&&&&&&******444444........(.-------000000.------v)))))))DDDDDDU_e&667 ???)+AB K00 N33 K.. J-- J// J== ('9-k,; @@@@: @ @ @ @RRRR.2222pHHHHHHHH#?$$++++\>.JJJJZGGGG&B!!!!H    k+ k+ k+ k+( )k+2 3k+@ Ak+L Mk+X Yk+f gk+v wk+F Gk+V Wk+d ek+r sk+~ k+J Kk+V Wk+k+b ;#  <=> ck+r sk+@ Ak+L Mk+V Wk+` ak+j kk+t uk+@ Ak+J Kk+T Uk+` ak+j kk+t uk+~ k+H Ik+T Uk+k+`    Kk+k+k+kkkk\ ++++++++,GHGHGHGHGH;GHGHGHV04>r=