
    5 f}d                      U d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZmZ ddlmZ ddlmZmZmZmZ dd	lZdd
lmZmZmZ ddlmZ ddlmZ ddlmZmZ ddl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.m/Z/m0Z0m1Z1 ddl2m3Z3m4Z4 ddl5m6Z6 erddl7m8Z8 eej9        ej:        f         Z;h dZ<ddhZ=ddhZ>ej?        d ej@        d ejA        d ejB        d ejC        d ejD        d iZE G d de          ZF G d d e          ZGdd$ZHdd'ZIdd*ZJdd-ZKdd0ZL G d1 d2          ZM eM            ZNdd5ZOdd9ZPdd:ZQdd;ZRdd>ZSddAZTddGZUddIZVddNZWi dOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpi dqdrdsdtdudvgifdwdxdydzd{d|d}d~ddddddddddddddddddddddddddddddZXdeYd<   ddZZ G d d          Z[ G d de          Z\	 dddZ]d	S )z Classes checker for Python code.    )annotations)defaultdict)CallableSequence)cached_property)chainzip_longest)Pattern)TYPE_CHECKINGAny
NamedTupleUnionN)basesnodesutil)LocalsDictNodeNG)SuccessfulInferenceResult)BaseCheckerutils)	PYMETHODSclass_is_abstractdecorated_withdecorated_with_propertyget_outer_classhas_known_basesis_attr_privateis_attr_protectedis_builtin_objectis_comprehensionis_iterableis_property_setteris_property_setter_or_deleternode_frame_classonly_required_for_messages
safe_inferunimplemented_abstract_methodsuninferable_final_decorators)HIGH	INFERENCE)MessageDefinitionTuple)PyLinter>   boolrangeslice
memoryviewzbultins.propertyzfunctools.cached_propertybuiltins.propertyzbuiltins.classmethodc                "    | j         |j         k    S Nvalueabs     [/var/www/equiseq/venv/lib/python3.11/site-packages/pylint/checkers/classes/class_checker.py<lambda>r9   7   s    ag0     c                "    | j         |j         k    S r2   qnamer5   s     r8   r9   r9   8   s    AG!3 r:   c                "    | j         |j         k    S r2   eltsr5   s     r8   r9   r9   9   s    af. r:   c                "    | j         |j         k    S r2   r?   r5   s     r8   r9   r9   :   s    QVqv- r:   c                "    | j         |j         k    S r2   )itemsr5   s     r8   r9   r9   ;   s    QW/ r:   c                    t          |                                           t          |                                          k    S r2   )setinferr5   s     r8   r9   r9   <   s'    S^^s17799~~= r:   c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )	_CallSignaturezlist[str | None]argszdict[str | None, str | None]kws	list[str]starred_argsstarred_kwsN__name__
__module____qualname____annotations__ r:   r8   rH   rH   C   sB         %%%%r:   rH   c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )_ParameterSignaturerK   rI   
kwonlyargsstrvarargskwargsNrN   rS   r:   r8   rU   rU   J   s7         OOOLLLKKKKKr:   rU   call
nodes.Callreturnc                   i }g }g }g }| j         pg D ]q}|j        |j        }}|5t          |t          j                  r|                    |j                   Gt          |t          j                  r|j        ||<   ld ||<   r| j        D ]}t          |t          j	                  r?t          |j        t          j                  r |                    |j        j                   [t          |t          j                  r|                    |j                   |                    d            t          ||||          S r2   )keywordsargr4   
isinstancer   NameappendnamerI   StarredrH   )rZ   rJ   rI   rM   rL   keywordr_   r4   s           r8   _signature_from_callrf   Q   s@   
CDKL=&B 	 	['-U;:eUZ88; uz****uz** 	zCHHCHHy  c5=)) 	jEJ.O.O 	 	////UZ(( 	KK!!!!KK$\;???r:   	argumentsnodes.Argumentsc                    | j         }| j        }d t          | j        | j                  D             }d | j        D             }t          ||||          S )Nc                2    g | ]}|j         d k    |j         S selfrc   .0r_   s     r8   
<listcomp>z-_signature_from_arguments.<locals>.<listcomp>q   s1       8v 	r:   c                    g | ]	}|j         
S rS   rm   rn   s     r8   rp   z-_signature_from_arguments.<locals>.<listcomp>v   s    ;;;s#(;;;r:   )kwargvarargr   posonlyargsrI   rV   rU   )rg   rr   rs   rI   rV   s        r8   _signature_from_argumentsru   n   sj    OEF .	??  D
 <;i&:;;;JtZ???r:   
definitionr,   c                4     j         r j         j        vrdS n	j        rdS  j        r j        j        vrdS n	j        rdS t	          fd j        D                       rdS  j        j        k    rdS t           fdj        D                       S )z8Check if a definition signature is equivalent to a call.Fc              3  *   K   | ]}|j         vV  d S r2   )rJ   )ro   kwrZ   s     r8   	<genexpr>z1_definition_equivalent_to_call.<locals>.<genexpr>   s*      
>
>"2TX
>
>
>
>
>
>r:   c              3  <   K   | ]}|j         v p|j        v V  d S r2   )rI   rV   )ro   ry   rZ   rv   s     r8   rz   z1_definition_equivalent_to_call.<locals>.<genexpr>   s6      QQ"rTY="
(="=QQQQQQr:   )	rY   rM   rX   rL   anyrV   rI   allrJ   )rv   rZ   s   ``r8   _definition_equivalent_to_callr~   z   s      D$4445 5		 u T%6665 7		 u

>
>
>
>
(=
>
>
>>> u$)##u QQQQQQQQQQQr:   functionnodes.FunctionDefc                   |                                  r| j        rdS | j        }t          |          dk    rdS |d         }t	          |t
          j        t
          j        f          sdS |j        }t	          |t
          j	                  rt	          |j
        t
          j                  sdS t          |j
        j                  }t	          |t          j        j                  sdS |j
        j        | j        k    rdS | j                                        }|j        |k    s4t	          |j        t          j                  r|j        j        |j        k    rdS dS )zzCheck whether a function definition is a method consisting only of a
    call to the same function on the superclass.
    F   r   T)	is_method
decoratorsbodylenr`   r   ExprReturnr4   Callfunc	Attributer%   exprastroidobjectsSuperattrnamerc   parentscopemro_pointertypeInstance)r   r   	statementrZ   
super_callcurrent_scopes         r8   _is_trivial_super_delegationr      sK   
    	 u=D
4yyA~~ uQIi%*el!;<< u?DtUZ(( $)U_55
 u DIN++Jj'/"788 u yX]**u O))++M-//*/7+;<< 	0?=#555u4r:   methodlist[nodes.AssignName]c                l    | j         j         }|                                 r| j        dv r
|dd          }|S )N>   r   classmethodr   )rI   is_boundr   )r   
positionals     r8   _positional_parametersr      s>    !J $V[,EEE^
r:   c                      e Zd ZdZdS )_DefaultMissingz=Sentinel value for missing arg default, use _DEFAULT_MISSING.N)rO   rP   rQ   __doc__rS   r:   r8   r   r      s        GGGGr:   r   original
overriddenc                   | j         |j         dS t          | j         | j                  D ]}	 |                     |j                  }n!# t
          j        j        $ r
 t          }Y nw xY w	 |                    |j                  }|t          u r dS n'# t
          j        j        $ r |t          u rY Y  dS w xY wt          |          }t          ||          s dS t                              |          }| dS  |||          s dS dS )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)rI   r   rV   default_valuerc   r   
exceptions	NoDefault_DEFAULT_MISSINGr   r`   ASTROID_TYPE_COMPARATORSget)r   r   paramoriginal_defaultoverridden_defaultoriginal_type
is_same_fns          r8   '_has_different_parameters_default_valuer      sk    }
 7ux}h&9::  	0'55ejAA!+ 	0 	0 	0/	0
	!+!9!9%*!E!E#333tt 4 !+ 	 	 	#333444	 -..,m<< 	448P8T8T9
 9

 44z*,>?? 	44	 5s#   A		A'&A'+#BB65B6dummy_parameter_regexPattern[str]rK   c                   g }t          | |          }|D ]\  }}|sdgc S |s;	 |j                            |j                   /# t          j        $ r dgcY c S w xY wd ||fD             }t          fd|D                       rs|j        |j        k    r&|                    d|j         d|j         d           |S )NNumber of parameters c                    g | ]	}|j         
S rS   rm   )ro   r   s     r8   rp   z-_has_different_parameters.<locals>.<listcomp>  s    LLLLLLr:   c              3  B   K   | ]}                     |          V  d S r2   )match)ro   rc   r   s     r8   rz   z,_has_different_parameters.<locals>.<genexpr>  s2      CCT$**400CCCCCCr:   zParameter 'z' has been renamed to 'z' in)r	   r   r   rc   r   r   r|   rb   )r   r   r   resultzippedoriginal_paramoverridden_paramnamess     `     r8   _has_different_parametersr     s@   
 F:..F,2  (( 	-+,,,, 	11 '556F6KLLL$ 1 1 1/0000001 ML.:J)KLLLCCCCUCCCCC 	"2"777MM3n1 3 3',3 3 3  
 Ms   AAAc                    d | D             }d |D             t          fd|D                       rdgS D ]B}||v r	 |d         j                            |           )# t          j        $ r dgcY c S w xY wg S )zDDetermine if the two methods have different keyword only parameters.c                    g | ]	}|j         
S rS   rm   ro   is     r8   rp   z:_has_different_keyword_only_parameters.<locals>.<listcomp>)  s    ///af///r:   c                    g | ]	}|j         
S rS   rm   r   s     r8   rp   z:_has_different_keyword_only_parameters.<locals>.<listcomp>*  s    3331333r:   c              3      K   | ]}|vV  	d S r2   rS   )ro   rc   overridden_namess     r8   rz   z9_has_different_keyword_only_parameters.<locals>.<genexpr>,  s)      
C
CD4''
C
C
C
C
C
Cr:   r   r   )r|   r   r   r   r   )r   r   original_namesrc   r   s       @r8   &_has_different_keyword_only_parametersr   $  s    
 0/h///N33
333

C
C
C
CN
C
C
CCC )'((  - ->!!	-qM ..t4444  	- 	- 	-+,,,,,,	- Is    A##A:9A:c                   g }t          |           }t          |          }| j        j        }|j        j        rd |D             fd|D             }|j        j        r.d |j        j        D             fd| j        j        D             }t          |||          }t          ||j        j                  }|rQ|rOd|d         v r:d|d         v r0|                    d           ||dd	         z  }||dd	         z  }n||z  }||z  }n|r||z  }|r||z  }| j        j        o|j        j         }	| j        j        o|j        j         }
|	s|
r|d
gz  }| j        t          v r|
                                 |S )aE  Determine 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.
    c                    g | ]	}|j         
S rS   rm   ro   vs     r8   rp   z)_different_parameters.<locals>.<listcomp>V  s    BBBqAFBBBr:   c                &    g | ]}|j         v |S rS   rm   ro   r   r   s     r8   rp   z)_different_parameters.<locals>.<listcomp>W  s-     
 
 
af8H.H.HA.H.H.Hr:   c                    g | ]	}|j         
S rS   rm   r   s     r8   rp   z)_different_parameters.<locals>.<listcomp>\  s    GGGqAFGGGr:   c                &    g | ]}|j         v |S rS   rm   r   s     r8   rp   z)_different_parameters.<locals>.<listcomp>]  s-     
 
 
16=M3M3MA3M3M3Mr:   zNumber r   r   r   NzVariadics removed in)r   rI   rV   rs   rr   r   r   rb   rc   r   clear)r   r   r   output_messagesoriginal_parametersoverridden_parametersoriginal_kwonlyargsdifferent_positionaldifferent_kwonly
kwarg_lostvararg_lostr   s              @r8   _different_parametersr   ;  s2    O0::2:>> #-2  
BB,ABBB
 
 
 
*
 
 
  
GGJO,FGGG
 
 
 
}/
 
 
 524I  >Z_7   00 0,Q///IAQRSAT4T4T""#:;;;3ABB77O/33OO33O//OO 	433O 	0//O $BZ_-B)BJ-&Ez/E+EK 4[ 4233}	!! 	r:   clsnodes.ClassDefc                <    | j         t          v ot          |           S r2   )rc   INVALID_BASE_CLASSESr   r   s    r8   _is_invalid_base_classr     s    8++F0A#0F0FFr:   attrrW   c                T   |                      |          }|D ]}	 |                                D ]`}t          |t          j                  rD	 |                     d           |                     d             dS # t          j        $ r Y \w xY way# t          j        $ r Y  dS w xY wdS )N__get____set__TF)getattrrF   r`   r   r   NotFoundErrorInferenceError)r   r   
attributes	attributeinferreds        r8   _has_data_descriptorr     s    T""J  		%OO-- $ $h(899 $$ ((333 ((333  $ttt #0 ! ! ! !	$$ % 	 	 	444	 5s5   0B*A:6B:B	BBBB%$B%r   r   klassmethodsSequence[str]c                &   t          | t          j                  sdS |D ]}	 |                    |          }n# t          j        $ r Y *w xY w|D ]}|                    t          j                  D ]}	 t          |j	        
                                          }n# t          j        t          f$ r Y Bw xY wt          |t          j                  sa|j        }t          |t          j                  r|j        }|j        | j        k    r   dS dS )zCheck if the func was called in any of the given methods,
    belonging to the *klass*.

    Returns True if so, False otherwise.
    FT)r`   r   FunctionDefr   r   r   nodes_of_classr   nextr   rF   r   StopIterationBoundMethod_proxiedUnboundMethodrc   )	r   r   r   r   r   infer_methodrZ   boundfunc_objs	            r8   _called_in_methodsr     sJ    dE-.. u    	}}V,,HH$ 	 	 	H	$ 	  	 L$33EJ??     !2!233EE.>   H!%)<==  >h(=>> 1'0H=DI--4444 . 	  5s!   8A
	A
3&BB3	2B3	rc   c                   	 |                     |           }n# t          j        $ r Y dS w xY wd}|D ]}t          |t          j                  r	 t          |                                          }n# t          j        $ r Y Qw xY wt          |t          j
                  rt          |          r dS |                                |k    rt          |          }||                                k    r dS dS )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.
    Fr0   T)r   r   r   r`   r   UninferableBaser   rF   r   r   r   r   pytyper#   declared_metaclass)rc   r   r   property_namer   r   r   s          r8   _is_attribute_propertyr     s(   ]]4((

    uu'M  dD011 		DJJLL))HH% 	 	 	H	h 122 	7N8
 8
 	 44??--x((%**,,,,tt5s    ++!A22BBslotslist[nodes.Const | None]assigned_value
nodes.Namec                    t          |                                          }t          |t          j                  r=|                                }t          d t          | |          D                       rdS dS )Nc              3  D   K   | ]\  }}|o|o|j         |j         k    V  d S r2   r3   )ro   
first_slotsecond_slots      r8   rz   z)_has_same_layout_slots.<locals>.<genexpr>  sO       
 
)[ P;P:+;{?P+P
 
 
 
 
 
r:   TF)r   rF   r`   r   ClassDefr  r}   r	   )r  r  r   other_slotss       r8   _has_same_layout_slotsr    s     N((**++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 %saccess-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 classprotected-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)simplicit-flag-aliaszdUsed when multiple integer values declared within an enum.IntFlag class share a common bit position.E0211)zMethod %r has no argumentno-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 argumentno-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 argumentbad-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 argumentbad-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 argumentbad-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 argumentbad-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 methodarguments-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 methodsignature-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 %rabstract-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 calledsuper-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 callednon-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 %ruseless-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)W0235zuseless-super-delegationW0236)z7Method %r was expected to be %r, found it instead as %rinvalid-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)zUnused 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 %roverridden-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: %rsubclassed-final-classzBUsed when a class decorated with typing.final has been subclassed.W0244)zRedefined slots %r in subclassredefined-slots-in-subclassz-Used when a slot is re-defined in a subclass.W0245)zSuper call without bracketssuper-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 stringsinvalid-slots-objectz=Used when an invalid (non-string) object occurs in __slots__.E0237)z4Assigning to attribute %r not defined in class slotsassigning-non-slotzCUsed when assigning to an attribute not defined in the class slots.E0238)zInvalid __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 %rinconsistent-mroz>Used when a class has an inconsistent method resolution order.E0241)zDuplicate bases for class %rduplicate-baseszBDuplicate use of base classes in derived classes raise TypeErrors.E0242)z/Value %r in slots conflicts with class variableclass-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 classmethodno-classmethod-decoratorzGUsed when a class method is defined without using the decorator syntax.)z:Consider using a decorator instead of calling staticmethodno-staticmethod-decoratorzHUsed when a static method is defined without using the decorator syntax.)z/Class __slots__ should be a non-string iterablesingle-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 python3useless-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 propertiesproperty-with-parameterszUsed when we detect that a property also has parameters, which are useless, given that properties cannot be called with additional arguments.)R0202R0203C0205R0205R0206z!dict[str, MessageDefinitionTuple]MSGS$defaultdict[str, list[_AccessNodes]]c                 *    t          t                    S r2   )r   listrS   r:   r8   _scope_defaultra    s    tr:   c                  *    e Zd ZdZddZddZddZdS )ScopeAccessMapz'Store the accessed variables per scope.r\   Nonec                8    t          t                    | _        d S r2   )r   ra  _scopesrk   s    r8   __init__zScopeAccessMap.__init__  s     '' 	r:   node_AccessNodesc                    t          |          }|dS | j        |         |j                                     |           dS )zSet the given node as accessed.N)r#   rf  r   rb   rl   rh  frames      r8   set_accessedzScopeAccessMap.set_accessed  sA     &&=FUDM*11$77777r:   r   r   dict[str, list[_AccessNodes]]c                8    | j                             |i           S )z/Get the accessed variables for the given scope.)rf  r   )rl   r   s     r8   accessedzScopeAccessMap.accessed  s    |r***r:   Nr\   rd  )rh  ri  r\   rd  )r   r   r\   rn  )rO   rP   rQ   r   rg  rm  rp  rS   r:   r8   rc  rc    sV        11( ( ( (
8 8 8 8+ + + + + +r:   rc  c                      e Zd ZdZdZeZddddddfd	d
ddddfddddddfddddddfddddddffZd fdZddZ	e
dd             Z ed!d"d#d$d%d&d'd(d)d*d+d,d-          dd0            Zdd1Zdd3Zdd4Zdd5Z ed6d7d8          dd9            Zdd:Zdd;Zdd<Zdd>Zdd@ZeZddBZddCZddFZddJZddKZddPZddSZddTZ e Z!ddUZ"ddVZ# edWdXd8          ddZ            Z$dd[Z%dd\Z& ed]d^d_          ddb            Z'ddcZ(ddeZ)e*ddf            Z+ddhZ,e*ddk            Z-e*ddm            Z.e*ddp            Z/ddsZ0dduZ1dd|Z2dd}Z3ddZ4ddZ5ddZ6ddZ7 xZ8S )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
    classeszdefining-attr-methods)rg  __new__setUp
asyncSetUp__post_init__csvz<method names>zGList of method names used to declare (i.e. assign) instance attributes.)defaultr   metavarhelpzvalid-classmethod-first-argr   z<argument names>z=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.zexclude-protected)_asdict_fields_replace_source_makezos._exitz<protected access exclusions>zQList of member names, which should be excluded from the protected access warning.z)check-protected-access-in-special-methodsFynz<y or n>z<Warn about protected attribute access inside special methodslinterr+   r\   rd  c                ~    t                                          |           t                      | _        g | _        d S r2   )superrg  rc  	_accessed_first_attrs)rl   r  	__class__s     r8   rg  zClassChecker.__init__M  s6       ')).0r:   c                j    | j         j        j        | _        | j         j        j        }|dk    | _        d S )N)      )r  configmixin_class_rgx_mixin_class_rgx
py_version
_py38_plus)rl   r  s     r8   openzClassChecker.openR  s/     $ 2 B['2
$.r:   r   c                $    | j         j        j        S r2   )r  r  dummy_variables_rgxrk   s    r8   
_dummy_rgxzClassChecker._dummy_rgxW  s    {!55r:   r*  rF  rU  rB  rN  rH  rV  rJ  rL  r>  rR  r<  r  rh  r   c                    |                      |           |                     |           |                     |           |                     |           |                     |           dS )zInit visit variable _accessed.N)_check_bases_classes_check_slots_check_proper_bases_check_typing_final_check_consistent_mrorl   rh  s     r8   visit_classdefzClassChecker.visit_classdef[  sn    " 	!!$'''$  &&&  &&&""4(((((r:   c                    	 |                                  dS # t          j        $ r! |                     d|j        |           Y dS t          j        $ r! |                     d|j        |           Y dS w xY w)z<Detect that a class has a consistent mro or duplicate bases.rJ  rI   rh  rL  N)mror   InconsistentMroErroradd_messagerc   DuplicateBasesErrorr  s     r8   r  z"ClassChecker._check_consistent_mror  s    	KHHJJJJJ+ 	L 	L 	L/didKKKKKK* 	K 	K 	K.TYTJJJJJJ	Ks    ,A6+A65A6ancestorc                <   |                     d          }|rt          |d         t          j                  ru|d         j        rh|d         j        D ]Z\  }}t          d |                     |j                  D                       r7|                     d|j        t                      |	                    d          rt          t                                        t          j                  D ]l}t          |j        t          j                  rKt          |j        j        dd           }t          |t"                    r|                             |           mt          t&                    }D ]U}	d t)          t+          t-          |	                              D             }
|
D ]}||                             |	           Vt          t                    }|                                D ]3}t3          |          ^}}|D ]}||                             |           4|D ]k         D ]^}|                     d	|d
j         d|j         d dd                    fd|         D                       dt                     _jd S d S )N__members__r   c              3  p   K   | ]1}t          |j        t          j                  o|j        j        d u V  2d S r2   )r`   r   r   	AnnAssignr4   ro   items     r8   rz   z0ClassChecker._check_enum_base.<locals>.<genexpr>  sX          t{EO<< 2)T1     r:   rR  rI   rh  
confidencezenum.IntFlagr4   c              3  ,   K   | ]\  }}|d k    |V  dS )1NrS   )ro   r   cs      r8   rz   z0ClassChecker._check_enum_base.<locals>.<genexpr>  s+      VV41aQRUXXQXXXXVVr:   r  <.: >, c              3  t   K   | ]2}d j          d|         d         j          d| d d| d|z   dV  3dS )	r  r  r   r  z> (z & z = )Nrm   )ro   sourceassignmentsrh  overlaps     r8   rz   z0ClassChecker._check_enum_base.<locals>.<genexpr>  s       1 1 %+!ODI !O !OF0CA0F0K !O !Ov !O !O$+!O !O06!O !O;BV;K!O !O !O1 1 1 1 1 1r:   )r  sourcesrh  rI   r  )r   r`   r   DictrC   r}   rc   r  r)   is_subtype_ofr   r`  r   
AssignNamer   Assignr4   intrb   rE   	enumeratereversedbinaddvaluessortedjoin)rl   rh  r  members_	name_nodeassign_namer4   	bit_flagsflag	flag_bitsbitoverlapsflagsr  	conflictsconflictassignment_noder  r  s    `                @@r8   _check_enum_basezClassChecker._check_enum_base{  s1   ""=11 	z'!*ej99 	gaj>N 	 '
 0  9   !) 0 0 @ @     
   ,!(	 !    !!.11 &	%d++K#2253CDD ? ?k0%,?? ?#K$6$<gtLLE!%-- ?#E*11+>>> $C((I# - -VV9Xc$ii5H5H+I+IVVV	$ - -CcN&&t,,,,- #4((H"))++ 6 6%+E]]" ) 6 6HX&--f55556 $  '27';  O$$-,'Y49'Y'Y7K'Y'Yw'Y'Y'Y'+yy 1 1 1 1 1 1 /7w.?1 1 1 ( (  $- %    3&	 &	0 r:   c                `   |j         D ]$}t          |          }|st          |t          j                  r+|                    d          s|                    d          rZt          |t          j                  rt          |          r*| 	                    d|
                                |           t          |t          j                  r+|                    d          r|                     ||           |j        t          j        k    r| 	                    d|j        |           &dS )zWDetect that a class inherits something which is not
        a class or a type.
        zbuiltins.typez	.ProtocolrH  r  z	enum.EnumrV  N)r   r%   r`   r   r   r  r   r	  r   r  	as_stringr  rc   objectrO   rl   rh  baser  s       r8   r  z ClassChecker._check_proper_bases  sM    J 	 	D!$''H (G$455 &&77))+66 h77 X;Q< < X   !44>>;K;KRV WWW(EN33 68N8N9 9 6 %%dH555}//  0tyt !   +	 	r:   c                   | j         sdS |j        D ]w}t          |          }|st          |t          j                  rIt          |dg          st          |j                  r$| 	                    d|j
        |j
        f|           xdS )z]Detect that a class does not subclass a class decorated with
        `typing.final`.
        Ntyping.finalr<  r  )r  r   r%   r`   r   r	  r   r'   r   r  rc   r  s       r8   r  z ClassChecker._check_typing_final  s      	FJ 	 	D!$''H (EN33 x.)9::/0CDD   ,)X]3 !   	 	r:   r8  r  r  c                    |                      |           |                     |           |                     |           |                     |           dS )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_initr  s     r8   leave_classdefzClassChecker.leave_classdef  sZ     	,,T222,,T222--d33322488888r:   c           	     ,   |                     t          j                  D ]r}t          |j                  s|j                                        }t          |t          j                  r1|j        d |                     t          j                  D             v r||                     t          j        t          j	        f          D ]
}t          |t          j                  r|j        |j        k    r nt          |t          j	                  r|j
        |j        k    s|                                |k    rst          |j        t          j                  r|j        j        dd|j        hv r n t          |j        t          j                  r@t          |j                  }t          |t          j                  r|j        |j        k    r ng }|}||k    r9|                    |j                   |j                                        }||k    9d                    t#          |                     }| d|j         d|j                                         d}	|                     d||j        |	                    d          f           td S )	Nc              3  $   K   | ]}|j         V  d S r2   rm   )ro   ns     r8   rz   z?ClassChecker._check_unused_private_functions.<locals>.<genexpr>  s5       ) ) AF) ) ) ) ) )r:   rl   r   r  (r  r8  rh  rI   )r   r   r   r   rc   r   r   r`   ra   r   r   r   r   r%   r	  rb   r  r  rI   r  r  lstrip)
rl   rh  function_defparent_scopechildr   
name_stackcurrouter_level_namesfunction_reprs
             r8   r  z,ClassChecker._check_unused_private_functions  s    //0ABB 5	 5	L"<#455 '.4466L,(9:: $ ) )$0$?$?
$K$K) ) )   ,,ej%/-JKK + + eUZ00 UZ<CT5T5TEeU_55 " ,*;;; ;;==L88  "%*ej99 ejo	R ? ?
  "%*ej99 "#-ej#9#9&x@@" ( : :!E
#dll%%di000;,,..D dll (+xx0D0D'E'E$G!#4 k k|7H k k<K\KfKfKhKh k k k  +%)]%9%9#%>%>? !   c5	 5	r:   c                ~   |                     t          j                  D ]}t          |j        t          j                  r#t          |j                  s8|                     t          j        t          j	        f          D ]}t          |t          j                  r|j        |j        k    r nt          |t          j	                  rIt          |j
        t          j                  s nO|j        |j        k    r|j
        j        dd|j        fv r n'|j        |j        f}|                     d||           dS )z9Check if private variables are never used within a class.rl   r   r8  r  N)r   r   r  r`   r   	Argumentsr   rc   ra   r   r   r   r  )rl   rh  r  r  rI   s        r8   r  z,ClassChecker._check_unused_private_variables0  sE   ..u/?@@ 	W 	WK+,eo>> ";#344 ,,ej%/-JKK W WeUZ00 UZ;CS5S5SEeU_55 %ej%*== ~)999ejo	R ? ?
 	;#34  !8{QU VVV'	W 	Wr:   c                   |                     t          j                  D ]}t          |j                  rt          |j        t          j                  s7dg}|                                }t          |t          j	                  rG|j
        dk    r<|                    d |                     t          j                  D                        |                     t          j                  D ]}|j        |j        k    rt          |j        t          j                  s3|j        j
        d|j
        hv r|j        j
        dd|j
        hv r nr|j        j
        |v r|j        j
        dk    r nR|j        j
        |j        j
        cxk    r|j
        k    rn  n'|j
        |j        f}|                     d||           d S )Nrl   ru  c                d    g | ]-}t          |j        t          j                  !|j        j        .S rS   )r`   r4   r   ra   rc   )ro   return_nodes     r8   rp   zAClassChecker._check_unused_private_attributes.<locals>.<listcomp>U  sC       '%k&7DD#).  r:   r   r8  r  )r   r   
AssignAttrr   r   r`   r   ra   r   r   rc   extendr   r   r  )rl   rh  assign_attracceptable_obj_namesr   r   rI   s          r8   r  z-ClassChecker._check_unused_private_attributesG  s
   ..u/?@@ 0	W 0	WK";#788 
 %*A A  
 06h %%''E%!233 
i8O8O$++ +0+?+?+M+M     "00AA W W	%)===!).%*== #(I-    n)eVTY-GGGE  $)-AAA!+v55 E#(IN,?LLLL49LLLLLE M
 	;#78  !8{QU VVVa0	W 0	Wr:   cnodec                  	
 d| j         j        j        v r!| j                            |j                  rd S | j                            |          }|j        dk    r| 	                    ||           | j         
                    d          sd S | j         j        j        
|                                	|j                                        D ]\  }}|dk    r	fd|D             }|sd |D             }t          
fd|D                       rF|                    |          D ]5}d}|j        |         D ]}|                                j        
v rd} |r n6	 |                    |           # t&          j        $ r` |D ]Y}|                                j        
vr<t+          |                                |
          rA|                     d||	           ZY w xY wd S )
Nr  	metaclass__dict__c                    g | ]R}t          |                                t          j        t          j        f          s|                                u P|SS rS   )r`   r   r   Delete	AugAssignroot)ro   r  current_modules     r8   rp   zFClassChecker._check_attribute_defined_outside_init.<locals>.<listcomp>  s]       !!++--%,1PQQ FFHH..  /..r:   c              3  >   K   | ]}|                                 V  d S r2   )rl  )ro   rh  s     r8   rz   zEClassChecker._check_attribute_defined_outside_init.<locals>.<genexpr>  s*      99tdjjll999999r:   c              3  H   K   | ]}|j         v pt          |          V  d S r2   )rc   r!   )ro   rl  defining_methodss     r8   rz   zEClassChecker._check_attribute_defined_outside_init.<locals>.<genexpr>  sM         
..K2DU2K2K     r:   FTr  )r  r  ignored_checks_for_mixinsr  r   rc   r  rp  r   _check_accessed_membersis_message_enableddefining_attr_methodsr   instance_attrsrC   r|   instance_attr_ancestorsrl  
local_attrr   r   r   r  )rl   r  rp  r   	nodes_lstframesr   attr_definedrh  r  r  s            @@r8   r  z2ClassChecker._check_attribute_defined_outside_initz  s    -{!;< <%++EJ77< F>**511:$$((999{--.NOO 	F;-C$399;; 3	 3	OD)z!!   "  I   :9y999F    #        77==  $"1$7 , ,Dzz||(,<<<'+ E
$$T****,    )  ::<<,4DDD  2 $

e5E    ) !) ,, @tRV -     E3	 3	s   E44A+G#"G#r   c                $   |                                 sdS |                     |           |                     |           |j                                        }|                     ||j        dk               |j        dk    r|                     ||           dS |	                    |j                  D ]i}	 ||j                 }n# t          $ r Y w xY wt          |t          j                  s<|                     |||           |                     ||            |j        rg|j        j        D ]Y}t          |t          j                  r|j        dv r dS t          |t          j                  r|j        t(          v r dS t          |t          j                  r|                     |          r dS t-          |          }|s dS t          |t          j                  r;	 t/          |                    |                    }n# t2          j        $ r Y  dS w xY w	 t          |t2          j        t          j        f          r-|                    d          r|                    d          r dS E# t2          j        $ r Y Ww xY w	 |                    |j                  d         }|                                }t          |t          j                  r$|j        dk    r|j                                        }t          |t          j                  r'|                     |!                                          sdS |"                                D ]h}|j        |j#        v rtI          |j                  r dS |%                    |j                  d	         D ] }	t          |	t          j                  r  dS !i|&                                j        |j'        f}
| (                    d
|
|           dS # t2          j)        $ r Y dS w xY w)z#Check method arguments, overriding.Nr  rg  >   gettersetterdeleterr   r   r   r   r   r  r  )*r   _check_useless_super_delegation_check_property_with_parametersr   rl  _check_first_arg_for_typer   rc   _check_initlocal_attr_ancestorsKeyErrorr`   r   r   _check_signature _check_invalid_overridden_methodr   r   r   ra   ALLOWED_PROPERTIES_check_functools_or_notr%   r   infer_call_resultr   r   r   r	  r   AttributeInferenceErrorinstance_attrr  r=   	ancestorsr	  r   lookupr   
fromlinenor  r   )rl   rh  r   r   parent_function	decoratorr   overridden_framer  objrI   s              r8   visit_functiondefzClassChecker.visit_functiondef  sw    ~~ 	F,,T222,,T222 !% 1 1 3 3&&tUZ;-FGGG9
""T5)))F44TY?? 	 	J",TY"7    	
 ou/@AA !!$???11$HHH? %	!_2 $ $	i99 i>P U ? ? FFi44  ~);;; i99 33I>>  &i00 FFh(9:: #'(B(B8(L(L#M#M"1   "8g.>-OPP$,,Y77 %,,Y77
 6   D
	,,TY77:J)//11+U->??C$)X55#3#:#@#@#B#B +U^<<''(8(>(>(@(@AA  "OO--  9 777ODI<V<V7FF#??4955a8  C!#u'899  OO%%*J,ABD_4dCCCCC$ 	 	 	DD	s\   9C
CC)"HH H $AI99JJB3O< 9O<  >O<  :O< <PPr   c                V   t          |          sdS |j        d         j        }|j        dk    r*|j                                        D ]}|j        dk    r dS |j                                        }d}|                    |j                  D ]}}	 ||j                 }n# t          $ r Y w xY wt          |t          j                  r?t          |j        |j                  s%|j        j        |                                dgk    r dS  t          |j                  }t!          |          }||j        j        rB|j        j        r4t%          |j        j                  t%          |j        j                  k    rdS dd
}	 |	|j                  }
 |	|j                  }|
r
|r|
|k    rdS |j        =|j        6|j                                        |j                                        k    rdS t+          ||          r&|                     d||j        ft.                     dS dS )aR  Check 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__rl   rg   rh   r\   rK   c                R    t          | j        pg | j                  }d |D             S )Nc                :    g | ]}||                                 S r2   )r  )ro   anns     r8   rp   zZClassChecker._check_useless_super_delegation.<locals>.form_annotations.<locals>.<listcomp>i  s!    RRRC#////r:   )r   posonlyargs_annotationsr   )rg   r   s     r8   form_annotationszFClassChecker._check_useless_super_delegation.<locals>.form_annotationse  s8    #6<"y?T  SR;RRRRr:   r0  r  )rg   rh   r\   rK   )r   r   r4   rc   r   	mymethodsrl  r  r  r`   r   r   r   rI   argnamesru   rf   rs   r   returnsr  r~   r  r)   )rl   r   rZ   other_methodr   	meth_noder   paramsrI   r/  called_annotationsoverridden_annotationss               r8   r  z,ClassChecker._check_useless_super_delegation)  s    ,H55 	F#=+1 =J&& ( 9 9 ; ;  $00FF 1 %%''	44X]CC 	 	J&x}5		    	 y%*;<<
 ;NHM 	
 N'/H4E4E4G4GF84S4S +8=99#D)) ~$ M(x})**S1D-E-EEES S S S "2!1(-!@!@%5%5in%E%E"! &< %)???F  ,%1%//11X5E5O5O5Q5QQQ )&$77 	+m%$	      	 	s   B
B,+B,c                    t          |j        j                  dk    r=t          |          r0t	          |          s#|                     d|t                     d S d S d S d S )Nr   rW  rh  r  )r   rI   rg   r   r!   r  r(   r  s     r8   r  z,ClassChecker._check_property_with_parameters  sr    	#$$q(('-- )&t,, ) 7dtTTTTT	 )(((((r:   function_nodeparent_function_nodec                   t          |          pt          |          }t          |          pt          |          }|r(|s&|                     d|j        d|j        f|           n$|s"|r |                     d|j        ddf|           t          |t          j                  }t          |t          j                  }|r#|s!|                     d|j        ddf|           n$|s"|r |                     d|j        ddf|           t          |dg          st          |j
                  rF| j        r=|                     d|j        |j                                        j        f|           d S d S d S )	Nr4  propertyr  r   asyncz	non-asyncr  r:  )r   r"   r  rc   r   r`   r   AsyncFunctionDefr   r'   r   r  r   rl  )rl   r:  r;  parent_is_propertycurrent_is_propertyparent_is_asynccurrent_is_asyncs          r8   r  z-ClassChecker._check_invalid_overridden_method  s&   
 5 
 
 A*+?@@ 	 6
 
 :*=99 	  	&9 	+#(*m6HI"     
 $ 	(; 	+#((J?"     %%95;QRR%mU5KLL 	#3 	+#(';?"      ! 	%5 	+#(+w?"     /.1ABB	+,@,KLL	 o	 )#(*>*E*K*K*M*M*RS"      		 	 	 	r:   r$  nodes.Attributer,   c                @   |j         dk    rdS t          |j        t          j                  sdS |j                            |j        j                  \  }}|sdS |d         }t          |t          j        t          j	        f          sdS dt          |j                  v S )Nr   Fr   	functools)r   r`   r   r   ra   r!  rc   r   Import
ImportFromdictr   )rl   r$  r  import_nodesimport_nodes        r8   r  z$ClassChecker._check_functools_or_not  s    !2225).%*55 	5#.//	0CDD< 	5"1o+8J'KLL 	5d;#45555r:   c                   d|j         vrd S 	 t          |                    d                    }n# t          j        $ r Y d S w xY w|D ]:}t          |t          j                  rt          |          s't          |          s| 
                    d|           Tt          |t          j                  r| 
                    d|           t          |d          st          |t          j                  rd |j        D             }n|                                }t          |t          j                  r|D ].}	 |                     ||           # t          j        $ r Y +w xY w|                     |||           <d S )N	__slots__rF  rh  rU  iteredc                    g | ]
}|d          S r   rS   r  s     r8   rp   z-ClassChecker._check_slots.<locals>.<listcomp>  s    :::d$q':::r:   )localstupleilookupr   r   r`   r   r   r    r   r  r   Consthasattrr  rC   rO  _check_slots_elt_check_redefined_slots)rl   rh  inferred_slotsr  r  elts         r8   r  zClassChecker._check_slots  s   dk))F	"4<<#<#<==NN% 	 	 	FF	# 	= 	=E%!566 u%% .>u.E.E   t <<<%--   !?d KKK5(++ %,, (::ek:::&$"677   ))#t4444-   H''eV<<<<7	= 	=s!   "0 AA?EE('E(
slots_nodenodes.NodeNG
slots_listlist[nodes.NodeNG]c                  	 g }|D ]}t          |t          j                  r|                    |j                   7t          |          }t          |dd          }t          |t                    r|                    |           d |                    d          D             }|	                    |          		r'| 
                    d	fd|D             f|           dS dS )zGCheck if `node` redefines a slot which is defined in an ancestor class.r4   Nc                N    h | ]"}|                                 pg D ]	}|j        
#S rS   )r  r4   )ro   r  slots      r8   	<setcomp>z6ClassChecker._check_redefined_slots.<locals>.<setcomp>  sP     !
 !
 !
 ((.B!
 !
  J!
 !
 !
 !
r:   rM  r>  c                    g | ]}|v |	S rS   rS   )ro   rc   redefined_slotss     r8   rp   z7ClassChecker._check_redefined_slots.<locals>.<listcomp>  s#    OOOt7N7Nt7N7N7Nr:   r  )r`   r   rU  rb   r4   r%   r   rW   r  intersectionr  )
rl   rh  r[  r]  slots_namesra  inferred_slotinferred_slot_valueancestors_slots_namesrd  s
            @r8   rX  z#ClassChecker._check_redefined_slots  s)    "$ 	< 	<D$,, <""4:.... *4 0 0&-mWd&K&K#1377 <&&':;;;!
 !
 55kBB!
 !
 !
 0<<[II 	-OOOOOOOQ      	 	r:   rZ  r   c                   |                                 D ]=}t          |t          j                  rt          |t          j                  rt          |j        t                    s1|                     d|	                                |t                     |j        s0|                     d|	                                |t                     |j                            |j                  }|rbt          |          dk    r1|d         j        }t          |t          j                  r
|j         d S |                     d|j        f|           ?d S )NrB  r  r   r   rN  r  )rF   r`   r   r   r   rU  r4   rW   r  r  r)   rR  r   r   r   r  )rl   rZ  rh  r   class_variabler   s         r8   rW  zClassChecker._check_slots_elt  sh    		 	 	H(D$899 h44 	J= = 	   *(	 !    >   *(	 !    "[__X^<<N ~&&!+++A.5F!&%/:: v|?S  38>:KRU !   ;	 	r:   c                    |                                 r'|j        j        | j                                         dS dS dS )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   rI   r  popr  s     r8   leave_functiondefzClassChecker.leave_functiondef8  sK     >> 	(y~)!%%'''''	( 	())r:   c                    |                      |           |                     |          r| j                            |           dS | j                            d          sdS |                     |           dS )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_paramr  rm  r  r  !_check_protected_attribute_accessr  s     r8   visit_attributezClassChecker.visit_attributeD  s     	**4000 ,,T22 	N''---F{--.@AA 	F..t44444r:   c                   |                                 }t          |t          j                  sdS t          |j                                         t          j                  sdS t          |j        t          j                  sdS t          |j        t          j                  sdS |j        j	        dk    r$| 
                    d|j        t                     dS dS )zCCheck if there is a function call on a super call without brackets.Nr  r@  r9  )rl  r`   r   r   r   r	  r   r   ra   rc   r  r(   rk  s      r8   rp  z*ClassChecker._check_super_without_bracketsW  s     

%!233 	F%,,,..?? 	F$+uz22 	F$)UZ00 	F9>W$$5DIRVWWWWW %$r:   rD  rP  nodes.AssignAttrc                   t          |                                t          j                  r/|                     |          r| j                            |           |                     |           |                     |           d S r2   )	r`   assign_typer   r  rq  r  rm  _check_in_slots_check_invalid_class_objectr  s     r8   visit_assignattrzClassChecker.visit_assignattrf  s     
 
 	.//55	. N''---T"""((.....r:   c                   |j         dk    sd S t          |j        t          j                  rpd}t          |j        j                  D ]"\  }}t          |d          r|j         dk    r|}#|dk    rd S t          |j        j        j	        j        |                   }nt          |j        j	                  }t          |t          j
        t          j        f          s|d S |                     d||j        j        t                      d S )Nr  r   rP  r  )r   r`   r   r   Tupler  r@   rV  r%   r4   r	  r   r   r  r  rO   r)   )rl   rh  class_indexr   rZ  r   s         r8   ry  z(ClassChecker._check_invalid_class_objectq  s   }++Fdk5;// 	5K#DK$455 $ $33
++ $0K0K"#Kb   !$+"4":"?"LMMHH!$+"344Hx%.$2F!GHH	 F"#, 	 	 	
 	
 	
 	
 	
r:   c                   t          j                  }t          |t          j                  sdS |j        }t          |          sdS d|j        vs|j        sdS t          d |
                                D                       rdS t          d |
                                D                       r5t          |dd          }|r"|                    |j                  ||j        = |                                }|dS t          d |                                D                       rdS t          fd|D                       s$t          d |D                       st          j        |          rdS j        d	k    rt#          j        j        |          rdS j        |j        v rq|j                            j                  D ]:}|                                }t          |t(          j                  r
|j        s dS ;t/          |j                  rdS j        d	k    rt1          |j        j                  rdS |                     d
j        ft6                     dS dS dS )zTCheck that the given AssignAttr node
        is defined in the class slots.
        NrM  c              3  z   K   | ]6}|                                 d k    |j                            d          V  7dS )zbuiltins.object__setattr__N)r=   rR  r   ro   r  s     r8   rz   z/ClassChecker._check_in_slots.<locals>.<genexpr>  sP       
 
zz||000 KOOM**0000
 
r:   c              3  F   K   | ]}|                                 d k    V  dS )ztyping.GenericNr<   r  s     r8   rz   z/ClassChecker._check_in_slots.<locals>.<genexpr>  s0      HHDtzz||//HHHHHHr:   __cachec              3  :   K   | ]}d |j         vo|j        dvV  dS )rM  )Genericr  N)rR  rc   )ro   r  s     r8   rz   z/ClassChecker._check_in_slots.<locals>.<genexpr>  sO       
 
  x. ;%::
 
 
 
 
 
r:   c              3  8   K   | ]}|j         j        k    V  d S r2   )r4   r   )ro   ra  rh  s     r8   rz   z/ClassChecker._check_in_slots.<locals>.<genexpr>  s,      AA44:.AAAAAAr:   c              3  ,   K   | ]}|j         d k    V  dS )r  Nr3   )ro   ra  s     r8   rz   z/ClassChecker._check_in_slots.<locals>.<genexpr>  s)      BBDtzZ/BBBBBBr:   r  rD  r  )r%   r   r`   r   r   r   r   rR  newstyler|   r  r   r   r  r   r   r   r   is_class_attrr   r   r  r4   r   r  r   r  r)   )rl   rh  r   r   cacher  
local_namer   s    `      r8   rx  zClassChecker._check_in_slots  s    di(((G$455 	F!u%% 	Fel**%.*F  
 
		
 
 
 
 
 	
 F HHEIIKKHHHHH 	'E9d33E '5;//;%+&=F  
 
 "OO--
 
 
 
 
 	
 FAAAA5AAAAA  	 BBEBBBBB )$-??  F=K//E4GM55 5/ F=EL00&+l&6&6t}&E&E # #
$.$8$8$:$:	&y%/BB#$-O# #FF+E4=AA =K//4J4;,5 5/ F  (-)(	 !     7 	  	 r:   r  rS  rT  assign_nodenodes.Assignc                    |                      |           |j        d         }t          |t          j                  sd S |                     |          rd S |                     |           d S Nr   )_check_classmethod_declarationtargetsr`   r   r  rq  rr  )rl   r  rh  s      r8   visit_assignzClassChecker.visit_assign  st     	++K888"1%$ 011 	F,,T22 	F..t44444r:   c                6   t          |j        t          j                  sdS |j        j        }t          |t          j                  r	|j        dvrdS |j        dk    rdnd}|                                }t          |t          j                  sdS |j        j	        d         }t          |t          j                  sdS |j        t          fd|                                D                       r$|                     ||j        d                    dS dS )	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   staticmethodr   rS  rT  r   c              3  .   K   | ]}|j         k    V  d S r2   rm   )ro   membermethod_names     r8   rz   z>ClassChecker._check_classmethod_declaration.<locals>.<genexpr>	  s*      QQf{fk)QQQQQQr:   rN  )r`   r4   r   r   r   ra   rc   r   r	  rI   r|   r0  r  r  )rl   rh  r   msgparent_classclassmeth_argr  s         @r8   r  z+ClassChecker._check_classmethod_declaration  s2    $*ej11 	F z$
++ 	ty A
 0
 0
 F yM)) '&, 	 zz||,77 	F 
*-44 	F#(QQQQ8N8N8P8PQQQQQ 	8St|A77777	8 	8r:   "nodes.Attribute | nodes.AssignAttrc                   |j         }t          |          r|| j        j        j        v rdS t          j        |          rdS t          |j                  }|rEt          |t          j        t          j        f          r|j         d| | j        j        j        v rdS t          |          }||                     d||           dS t          |j        t          j                  r;t          |j        j        t          j                  r|j        j        j        dk    rdS |                     |j                  rdS d}|}|j                                        }|                    d          }|                                 |D ]"}|r||j        k    rd} nt/          |          }#|sR||j        v sJ|j                                        }	t          |	t          j                  rat9          |	j                  dk    rIt          |	j        d	         t          j                  r$|	j        d	         j        }
t?          |
|          rdS |                      |!                                          r3| "                    |j        |          r| #                    ||          rdS |$                    d
           }| j        j        j%        s|r| &                    |          rdS |                     d||           dS dS dS )a  Given 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.
        Nr  r  r  r  TFr   r   __)'r   r   r  r  exclude_protectedr   "is_node_in_type_annotation_contextr%   r   r`   r   r	  Modulerc   r#   r  r   r   ra   _is_type_self_callr  splitreverser   	basenamesr   r   r  r   r  r  r   _is_classmethodrl  _is_inferred_instance_is_class_or_instance_attribute
startswith)check_protected_access_in_special_methods _is_called_inside_special_method)rl   rh  r   r   r   inside_klassouter_klasscalleeparents_calleestmtrc   licit_protected_members               r8   rr  z.ClassChecker._check_protected_attribute_access  s>    = "(++	4;-???F 3D99 	F di((	8enel%CDD	 =--8--1C1UUUF &&=/dJJJF ty%*--	49>5:66	 	#w..F ""49-- 	F $$&&c**   $ 	7 	7F &K,<"<"<$ *+66KK   	K%/ 9 9 ;((**D4..%%**t|A0@AA + |A+)$66 F $$TZZ\\22..ty%@@ 885II
 )1)<)<T)B)B%B"K&P* 99$??
 /dJJJJJA 	K  	K 9 9r:   c                J    |                                  j        }|o|t          v S )zIReturns true if the node is located inside a special (aka dunder) method.)rl  rc   r   )rh  
frame_names     r8   r  z-ClassChecker._is_called_inside_special_methodw  s$     ZZ\\&
5jI55r:   r   c                   t          |t          j                  oft          |j        t          j                  oG|j        j        dk    o7t          |j                  dk    o|                     |j        d                   S )Nr   r   r   )	r`   r   r   r   ra   rc   r   rI   _is_mandatory_method_param)rl   r   s     r8   r  zClassChecker._is_type_self_call}  sr    tUZ(( >49ej11>	&(> DI!#> //	!==	
r:   r   r   c                b    t          | t          j                  o| j        dk    p
| j        dk    S )z1Check if the given *func* node is a class method.r   __class_getitem__)r`   r   r   r   rc   )r   s    r8   r  zClassChecker._is_classmethod  s5     $ 122 
I&J$)7J*J	
r:   r   c                j    t          |           }t          |t          j                  sdS |j        |u S )z[Check if the inferred value of the given *expr* is an instance of
        *klass*.
        F)r%   r`   r   r   r   )r   r   r   s      r8   r  z"ClassChecker._is_inferred_instance  s9    
 d##(G$455 	5 E))r:   rc   rW   c                    t          j        | |          rdS 	 |                    |            dS # t          j        $ r Y dS w xY w)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)r   r  r  r   r   )rc   r   s     r8   r  z,ClassChecker._is_class_or_instance_attribute  sa     tU++ 	4	%%%4$ 	 	 	55	s   0 AArp  rn  c                &  
 d}|                                 D ]v\  }
	 |                    |           # t          j        $ r Y nw xY w	 t	          |                    |                     V# t          $ r Y nw xY w	 |                    |          }
fd|D             }|s|d                                         fdt          |          D             }t          |          dk    r|d         }|                                }|j        }
D ]e}	|	                                |u rM|	j        |k     rBt          j        |	                                ||          s|                     d|	||f           fb# t          j        $ r Y tw xY wdS )	z(Check that accessed members are defined.)AttributeError	ExceptionBaseExceptionc                    g | ]}|v|	S rS   rS   )ro   r  r  s     r8   rp   z8ClassChecker._check_accessed_members.<locals>.<listcomp>  s#    OOOTY9N9ND9N9N9Nr:   r   c                R    g | ]#\  }}|d k    s|                                 u!|$S rQ  )r   )ro   r   r  r   s      r8   rp   z8ClassChecker._check_accessed_members.<locals>.<listcomp>  sB       4AvvU!:!: !:!:!:r:   r   r  r  N)rC   r  r   r   r   r
  r   r  r   r  r   rl  r"  are_exclusiver   r  )rl   rh  rp  excsr   defstmtsdefstmtrl  lno_noder  r   s             @@r8   r  z$ClassChecker._check_accessed_members  s    @'~~// 7	 7	OD)%%%(   T11$77888    '--d33
 POOOXOOO   !))++   #,X#6#6   x==A%%&qkG $MMOOE!,C!*  !KKMMU22 % 03 6 6$+$9 % 1 17D% % !7
 !,, A%*&*C[ -   C (   %7	 7	s3   6AA"A//
A<;A< E;;FFr  c                <   |j         j         dS |j         j        r|j         j        d         j        }n)|j         j         r|                                d         }nd}| j                            |           | j        d         }|j        dk    rR|dk    s&|| j        j        j	        v s|| j        j        j
        v r|                     d||           dS d| j        d<   dS d|                                v rdS |j         j         sC|j         j        s7|j         j        s+|j         j        s|                     d	||j        
           dS |ri|j        dk    r/|                     || j        j        j
        |d|j                   dS |                     || j        j        j	        |d|j                   dS |j        dk    s|j        dk    r/|                     || j        j        j	        |d|j                   dS |dk    r|                     d||j        
           dS dS )am  Check the name of first argument, expect:.

        * 'self' for a regular method
        * 'cls' for a class method or a metaclass regular method (actually
          valid-classmethod-first-arg value)
        * 'mcs' for a metaclass class method (actually
          valid-metaclass-classmethod-first-arg)
        * not one of the above for a static method
        Nr   r|  r  rl   r#  r  zbuiltins.staticmethodr  r  r   r!  r  r  r  r  )rI   rt   rc   r1  r  rb   r   r  r  valid_classmethod_first_arg%valid_metaclass_classmethod_first_argr  decoratornamesrs   rr   _check_first_arg_config)rl   rh  r  	first_argfirsts        r8   r  z&ClassChecker._check_first_arg_for_type  s    9>!F9  		-a05IIY^ 	*III  +++!"%9&&V## 2 NNN 2 XXX  !<5t TTT$(Db!!!$(;(;(=(=== F IN&	Ly$&	L y&	L y	&	L 149MMMMM 	LyM)),,K&L2I     ,,K&B-I     Y-''498K+K+K((">*	     f__/dKKKKK _r:   r  
str | Noner  r   messager  c                    ||vryt          |          dk    rt          |d                   }n4d                    d |d d         D                       }| d|d         }|                     |||f|           d S d S )Nr   r   r  c              3  4   K   | ]}t          |          V  d S r2   )reprr   s     r8   rz   z7ClassChecker._check_first_arg_config.<locals>.<genexpr>@  s(      !?!?a$q''!?!?!?!?!?!?r:   r|  z or r  )r   r  r  r  )rl   r  r  rh  r  r  valids          r8   r  z$ClassChecker._check_first_arg_config4  s     6{{aVAY		!?!?6#2#;!?!?!??? 44fRj44WK+?dKKKKK r:   c                J   dd}t          |          rdS t          t          ||                                          d           }|D ]X\  }}|j                                        }||u r#||j        v r-|                     d	|||j        |j        ft          
           YdS )z_Check that the given class node implements abstract methods from
        base classes.
        r   r   r\   r,   c                .    |                      d          S )NF)pass_is_abstract)is_abstract)r   s    r8   r  z6ClassChecker._check_bases_classes.<locals>.is_abstractI  s    %%u%===r:   Nc                    | d         S r  rS   )r  s    r8   r9   z3ClassChecker._check_bases_classes.<locals>.<lambda>R  s
    T!W r:   )keyr*  r  )r   r   r\   r,   )
r   r  r&   rC   r   rl  rR  r  rc   r)   )rl   rh  r  r   rc   r   owners          r8   r  z!ClassChecker._check_bases_classesD  s    
	> 	> 	> 	> T"" 	F*4==CCEE$$
 
 
 $ 	 	LD&M''))E}} t{""!EJ	2$	     	 	r:   
klass_nodec                   | j                             d          s| j                             d          sdS t          |          }t          |          }t	                      }|                    t          j                  D ]}|j        }t          |t          j
                  r|j        dk    r0t          |j        t          j                  r<t          |j        j        t          j                  r|j        j        j        dk    r dS 	 |j                                        D ]}t          |t           j                  rt          |t$          j                  rGt          |j        t          j                  r(t-          |j                  r|j        j        dk    r  dS t          |t$          j        j                  r  dS 	 |                    |          }	|                    t7          |	                     # t8          $ r9 ||                    d          vr|                     d||j                   Y w xY w# t$          j        $ r Y w xY w|                                 D ]e\  }}	t7          |	          |v r dS tC          j"        |          r dS tG          |d	g          rB|                     d|j        |tH          
           fdS )zCheck that the __init__ method call super or ancestors'__init__
        method (unless it is used for type hinting with `typing.overload`).
        r,  r.  Nrg  r  Frecursr  ztyping.overloadr  )%r  r  _ancestors_to_callrI  rE   r   r   r   r   r`   r   r   r   ra   rc   rF   r   r   r   r   r   r	  r   r   r   rm  r  r#   r  r   r  r   rC   r   is_protocol_classr   r)   )
rl   rh  r  to_callnot_called_yetparents_with_called_initsr  r   r   r   s
             r8   r  zClassChecker._check_inite  s    {--#
 
 	+001IJJ	 F$Z00g>Aee!''
33 *	 *	D9DdEO44 8S8S 49ej11ty~uz:: IN'722!Y__..  E!%)=>> !  #5'*:;;&u~u~FF .en== "N/7::!%)>?? !/!3!3E!:!:1556Fv6N6NOOOO#    
(<(<E(<(J(JJJ ,, 8t%* -   /8 )   +1133 	 	ME6  ''+DDD&u-- d%6$788 'Z$	     	 	s=   BI
& I

7HI
?II
II

IImethod1	refmethodr   c                H   t          |t          j                  rt          |t          j                  s|                     d||f|           dS |                                }t
          j                            ||          }t
          j                            ||          }|j        j        |j        j        dS t          |j
                  rdS t          |          rdS t          ||| j                  }d}t          |          dk    r|D ]}d|v r%t          |j        j                  }|j        j        r|dz  }|j        j        r|dz  }|j        j        r|t          |j        j                  z  }t          |j        j                  }	|j        j        r|	dz  }	|j        j        r|	dz  }	|j        j        r|	t          |j        j                  z  }	d	}
|d
|	 d|j                                        j
         d|j
         d| d	z   ||j                                        j
         d|j
         f}n_d|v r.d}
|||j                                        j
         d|j
         f}n-d	}
|||j                                        j
         d|j
         f}|                     |
||           dS t          |j        j                  t          |j        j                  k     r/|j        j        s%d}|                     d||j
        f|           dS dS dS )z8Check that the signature of the two given methods match.r  r  N)r   
overridingr   Numberr   r&  zwas z in 'r  z' and is now z inrenamedr6  r   r(  )r`   r   r   r  instantiate_classr   scoped_nodesfunction_to_methodrI   r   rc   r!   r   r  r   rs   rr   rV   r   rl  defaults)rl   r  r  r   instancearg_differ_output
class_typer  total_args_method1total_args_refmethod
error_typemsg_argss               r8   r  zClassChecker._check_signature  s    w 122	9e&788	 %Wi,@w     F((**&99'8LL(;;IxPP	 <$	(;(CF 7<(( 	F g&& 	F1wdo
 
 
 "
 !!A%%( &J &Js??),W\->)?)?&|* 0*a/*|) 0*a/*|. K*c',2I.J.JJ*+.y~/B+C+C( ~, 2,1, ~+ 2,1, ~0 O,IN4M0N0NN,!3J:!5 : :I<L<R<R<T<T<Y : :\e\j : :"4: : :: #">//116GGGG HH #%%!4J"">//116GGGG HH "4J"">//116GGGG H
   ( IIIIM&J &JP %&&Y^-D)E)EEEL' F &J#:w|*D7      	 FEEEr:   1nodes.Attribute | nodes.Assign | nodes.AssignAttrc                6    |                      |j                  S )zCheck that attribute lookup name use first attribute variable name.

        Name is `self` for method, `cls` for classmethod and `mcs` for metaclass.
        )r  r   r  s     r8   rq  z)ClassChecker._uses_mandatory_method_param	  s     ..ty999r:   c                2   | j         r| j         d         }n^t          j        |t          j                  }|dS |                                sdS |j        j        sdS |j        j        d         j        }t          |t          j	                  o
|j        |k    S )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.
        r|  NFr   )
r  r   get_node_first_ancestor_of_typer   r   r   rI   rc   r`   ra   )rl   rh  
first_attrclosest_funcs       r8   r  z'ClassChecker._is_mandatory_method_param	  s      	8*2.JJ !@e' L #u((** u$) u%*/27J$
++G	Z0GGr:   )r  r+   r\   rd  rq  )r\   r   )rh  r   r\   rd  )rh  r   r  r   r\   rd  )r  r   r\   rd  )rh  r   r\   rd  )r   r   r\   rd  )r:  r   r;  r   r\   rd  )r$  rD  r\   r,   )rh  r   r[  r\  r]  r^  r\   rd  )rZ  r   rh  r   r\   rd  )rh  rD  r\   rd  )rh  ru  r\   rd  )r  r  r\   rd  )rh  r  r\   rd  )rh  r  r\   rd  )rh  r\  r\   r,   )r   r\  r\   r,   )r   r   r\   r,   )r   r\  r   r   r\   r,   rc   rW   r   r   r\   r,   )rh  r   rp  rn  r\   rd  )rh  r   r  r,   r\   rd  )r  r  r  r   rh  r   r  rW   r  rW   r\   rd  )rh  r   r  r   r\   rd  )r  r   r  r   r   r   r\   rd  )rh  r  r\   r,   )9rO   rP   rQ   r   rc   r]  msgsoptionsrg  r  r   r  r$   r  r  r  r  r  r  r  r  r  r  r'  visit_asyncfunctiondefr  r  r  r  r  rX  rW  rn  leave_asyncfunctiondefrs  rp  rz  ry  rx  r  r  rr  r  r  r  r  r  r  r  r  r  r  r  r  rq  r  __classcell__)r  s   @r8   rs  rs    s         DD $ + 	
" *#-	 		
 4#-	 		
   :9 	
* 8 %V	 	
sBGH1 1 1 1 1 1
/ / / /
 6 6 6 _6  &'$%   ) ) ) )K K K K9 9 9 9v   :   *  () 
	9 	9 	9 
	96 6 6 6pW W W W.1W 1W 1W 1WfG G G GTa a a aF /V V V VpU U U U0 0 0 0d6 6 6 6$#= #= #= #=J       D" " " "H( ( ( ( /5 5 5 5&X X X X  46W / / / /
 
 
 
8I I I IV  68S 5 5 5 5%8 %8 %8 %8NiK iK iK iKV 6 6 6 \6

 
 
 
 
 
 
 \
 * * * \*    \ < < < <|LL LL LL LL\L L L L    BF F F FPU U U Un: : : :H H H H H H H Hr:   rs  rg  r  r  )dict[nodes.ClassDef, bases.UnboundMethod]c                   i }|                      d          D ]o}	 t          |                    |                    }t          |t          j                  s@|                                rU|||<   [# t          j        $ r Y lw xY w|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  )r   r   igetattrr`   r   r   r  r   )r  r  r  	base_node	init_nodes        r8   r  r  $	  s     :<G)))77 	 			Y//<<==Ii)>?? $$&& !*GI% 	 	 	H	Ns   <A4A4.A44BB)rZ   r[   r\   rH   )rg   rh   r\   rU   )rv   rU   rZ   rH   r\   r,   )r   r   r\   r,   )r   r   r\   r   )r   rh   r   rh   r\   r,   )r   r   r   r   r   r   r\   rK   )r   r   r   r   r\   rK   )r   r   r   r   r   r   r\   rK   )r   r   r\   r,   )r   r   r   rW   r\   r,   )r   r   r   r   r   r   r\   r,   r  )r  r  r  r  r\   r,   )r\   r^  )rg  )r  r   r  rW   r\   r   )^r   
__future__r   collectionsr   collections.abcr   r   rF  r   	itertoolsr   r	   rer
   typingr   r   r   r   r   r   r   r   astroid.nodesr   astroid.typingr   pylint.checkersr   r   pylint.checkers.utilsr   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   pylint.interfacesr(   r)   pylint.typingr*   pylint.lint.pylinterr+   r   r  ri  r   r  BUILTIN_DECORATORSrU  r	  r}  Listr  ra   r   rH   rU   rf   ru   r~   r   r   r   r   r   r   r   r   r   r   r   r   r  r]  rR   ra  rc  rs  r  rS   r:   r8   <module>r     s  
 ' & & " " " " " " # # # # # # . . . . . . . . % % % % % % ( ( ( ( ( ( ( (       8 8 8 8 8 8 8 8 8 8 8 8  & & & & & & & & & & * * * * * * 4 4 4 4 4 4 . . . . . . . .                                       ( . - - - - - - - 0 0 0 0 0 0 .------ U_e&667??? (*EF )+AB 	K00	N33	K..	J--	J//	J==     Z       *   @ @ @ @:	@ 	@ 	@ 	@R R R R.2 2 2 2p   H H H H H H H H #?$$ + + + +\   >   .J J J JZG G G G   &   B       F   k+ k+  k+  k+(  )k+2  3k+@  Ak+L  Mk+X  Yk+f  gk+v  wk+F  Gk+V  Wk+d  ek+r  sk+~  k+J  Kk+V  Wk+ k+b ;#	 
<=>ck+r  sk+@  Ak+L  Mk+V  Wk+`  ak+j  kk+t  uk+@  Ak+J  Kk+T  Uk+`  ak+j  kk+t  uk+~  k+H  Ik+T  Uk+ k+`


Kk+ k+ k+ k k k k\   
+ + + + + + + +*hH hH hH hH hH; hH hH hHX1 4>      r:   