3
tûœ]^ ã            "   @   s  d Z ddlZddlmZmZ ddlZddlmZmZ ddlm	Z	m
Z
 ddlmZmZ ddlmZ ddl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"m#Z#m$Z$m%Z% dd
l&m'Z' ddl(m)Z) dZ*ddddhZ+ddhZ,ej-ddƒZ.ej-ddƒZ/dd„ Z0dd„ Z1dd„ Z2dd„ Z3dd „ Z4d!d"„ Z5d#d$„ Z6d%d&„ Z7d'd(„ Z8d)d*„ Z9d+d,„ Z:d-d.„ Z;d/d0„ Z<d1d2„ Z=d£d3d4„Z>d5d6„ Z?d¤d¥d¦d§d¨d©dªd«d¬d­d®d¯d°d±d²d³d´dµd¶d·d¸d¹dºd»d¼d½d¾d¿dÀdÁdÂdÃd—œ Z@G d˜d™„ d™ƒZAG dšd›„ d›eƒZBG dœd�„ d�eƒZCdÄdŸd „ZDd¡d¢„ ZEdS )Åz classes checker for Python code
é    N)ÚchainÚzip_longest)Ú
decoratorsÚobjects)ÚBUILTINSÚ	Generator)ÚDuplicateBasesErrorÚInconsistentMroError)Úfunction_to_method)ÚBaseChecker)Ú	PYMETHODSÚSPECIAL_METHODS_PARAMSÚcheck_messagesÚclass_is_abstractÚdecorated_withÚdecorated_with_propertyÚhas_known_basesÚis_attr_privateÚis_attr_protectedÚis_builtin_objectÚis_comprehensionÚis_iterableÚis_property_setterÚis_property_setter_or_deleterÚis_protocol_classÚnode_frame_classÚoverrides_a_methodÚ
safe_inferÚunimplemented_abstract_methods)ÚIAstroidChecker)Úget_global_optionÚ__next__ÚboolÚrangeÚsliceÚ
memoryviewzbuiltins.propertyzbuiltins.classmethodÚ_CallSignaturez!args kws starred_args starred_kwsÚ_ParameterSignaturezargs kwonlyargs varargs kwargsc             C   sà   i }g }g }g }xb| j pg D ]T}|j|j }}|d krPt|tjƒrP|j|jƒ qt|tjƒrh|j||< qd ||< qW x\| jD ]R}t|tj	ƒrªt|jtjƒrª|j|jjƒ q|t|tjƒrÄ|j|jƒ q||jd ƒ q|W t
||||ƒS )N)ÚkeywordsÚargÚvalueÚ
isinstanceÚastroidÚNameÚappendÚnameÚargsÚStarredr&   )ÚcallÚkwsr0   Ústarred_kwsÚstarred_argsÚkeywordr)   r*   © r7   ú9/tmp/pip-build-fn42xldr/pylint/pylint/checkers/classes.pyÚ_signature_from_callQ   s$    r9   c             C   s:   | j }| j}dd„ | jD ƒ}dd„ | jD ƒ}t||||ƒS )Nc             S   s   g | ]}|j d kr|j ‘qS )Úself)r/   )Ú.0r)   r7   r7   r8   ú
<listcomp>q   s    z-_signature_from_arguments.<locals>.<listcomp>c             S   s   g | ]
}|j ‘qS r7   )r/   )r;   r)   r7   r7   r8   r<   r   s    )ÚkwargÚvarargr0   Ú
kwonlyargsr'   )Ú	argumentsr=   r>   r0   r?   r7   r7   r8   Ú_signature_from_argumentsn   s
    rA   c       
         s®   | j r| j ˆ jk}nˆ j }| jr0| jˆ jk}nˆ j }t‡ fdd„| jD ƒƒ}| jˆ jk}d}ˆ jrœx4ˆ jD ]*}|ˆ jk}|| jk}	| rn|	 rnd}P qnW t|||||fƒS )z8Check if a definition signature is equivalent to a call.c             3   s   | ]}|ˆ j kV  qd S )N)r3   )r;   Úkw)r2   r7   r8   ú	<genexpr>€   s    z1_definition_equivalent_to_call.<locals>.<genexpr>TF)Úkwargsr4   Úvarargsr5   Úallr?   r0   r3   )
Z
definitionr2   Zsame_kw_variadicsZsame_args_variadicsZsame_kwonlyargsZ	same_argsZno_additional_kwarg_argumentsr6   Zis_argZ	is_kwonlyr7   )r2   r8   Ú_definition_equivalent_to_callv   s,    

rG   c             C   s"   | j j }| jdkr|dd … }|S )NÚclassmethodÚmethodé   )rH   rI   )r0   Útype)rI   Ú
positionalr7   r7   r8   Ú_positional_parametersž   s    
rM   c             C   s    x|D ]}t | |ƒr|S qW dS )zû
    Return the type of the node if it exists in potential_types.

    Args:
        node (astroid.node): node to get the type of.
        potential_types (tuple): potential types of the node.

    Returns:
        type: type of the node or None.
    N)r+   )ÚnodeZpotential_typesZpotential_typer7   r7   r8   Ú_get_node_type¥   s    

rO   c             C   s   t | |ƒt ||ƒkS )a}  
    Check equality of nodes based on the comparison of their attributes named attr_name.

    Args:
        node_a (astroid.node): first node to compare.
        node_b (astroid.node): second node to compare.
        attr_name (str): name of the nodes attribute to use for comparison.

    Returns:
        bool: True if node_a.attr_name == node_b.attr_name, False otherwise.
    )Úgetattr)Znode_aZnode_bÚ	attr_namer7   r7   r8   Ú_check_arg_equality¶   s    rR   c                s0  | j dks|j dkrdS t| j | jƒ}dd„ |D ƒ}tƒ ‰ xð|D ]è}y| j|ƒ}W n tjjk
rn   ˆ }Y nX y|j|ƒ}W n tjjk
rš   ˆ }Y nX ‡ fdd„||fD ƒ}t|ƒrÈt	|ƒ rÈdS tj
dtjdtjd	tjd	i}td
d„ |D ƒƒ}	t||	ƒ}
|
r@t||
ƒ�sdS t||||
 ƒs@dS q@W dS )a0  
    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
    NFc             S   s   g | ]
}|j ‘qS r7   )r/   )r;   Úparamr7   r7   r8   r<   Ò   s    z;_has_different_parameters_default_value.<locals>.<listcomp>c                s   g | ]}|ˆ k‘qS r7   r7   )r;   r)   )Údefault_missingr7   r8   r<   ß   s    Tr*   r/   Úeltsc             s   s   | ]
}|V  qd S )Nr7   )r;   Zastroid_typer7   r7   r8   rC   ì   s    z:_has_different_parameters_default_value.<locals>.<genexpr>)r0   r   r?   ÚobjectÚdefault_valuer,   Ú
exceptionsZ	NoDefaultÚanyrF   ÚConstÚClassDefÚTupleÚListÚtuplerO   r+   rR   )ÚoriginalÚ
overriddenÚall_argsZoriginal_param_namesÚ
param_nameZoriginal_defaultZoverridden_defaultZdefault_listZastroid_type_compared_attrZhandled_typesÚoriginal_typer7   )rT   r8   Ú'_has_different_parameters_default_valueÅ   sB    	





rd   c             C   sd   t | |ƒ}xT|D ]L\}}||f}t|ƒs,dS dd„ |D ƒ}tt|j|ƒƒrLq|j|jkrdS qW dS )NTc             S   s   g | ]
}|j ‘qS r7   )r/   )r;   rS   r7   r7   r8   r<     s    z-_has_different_parameters.<locals>.<listcomp>F)r   rF   rY   ÚmapÚmatchr/   )r_   r`   Údummy_parameter_regexZzippedZoriginal_paramZoverridden_paramÚparamsÚnamesr7   r7   r8   Ú_has_different_parametersþ   s    
rj   c       	      C   s–   t | ƒ}t |ƒ}t|||ƒ}t| jj|jj|ƒ}| jtkrBd }}tdd„ | jj|jjfD ƒƒdk}tdd„ | jj|jjfD ƒƒdk}t	||||fƒ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.

    Fc             s   s   | ]}|sd V  qdS )rJ   Nr7   )r;   rS   r7   r7   r8   rC   .  s    z(_different_parameters.<locals>.<genexpr>rJ   c             s   s   | ]}|sd V  qdS )rJ   Nr7   )r;   rS   r7   r7   r8   rC   2  s    )
rM   rj   r0   r?   r/   r   Úsumr=   r>   rY   )	r_   r`   rg   Zoriginal_parametersZoverridden_parametersZdifferent_positionalZdifferent_kwonlyZdifferent_kwargZdifferent_varargr7   r7   r8   Ú_different_parameters  s    

rl   c             C   s   | j tkot| ƒS )N)r/   ÚINVALID_BASE_CLASSESr   )Úclsr7   r7   r8   Ú_is_invalid_base_class;  s    ro   c             C   sŒ   | j |ƒ}x||D ]t}yXxR|jƒ D ]F}t|tjƒr y|j dƒ |j dƒ W n tjk
r`   w Y q X dS q W W q tjk
r‚   dS X qW dS )NÚ__get__Ú__set__TF)rP   Úinferr+   r,   ÚInstanceÚNotFoundErrorÚInferenceError)rn   ÚattrÚ
attributesÚ	attributeÚinferredr7   r7   r8   Ú_has_data_descriptor?  s    



rz   c       	      C   sÔ   t | tjƒsdS x¾|D ]¶}y|j|ƒ}W n tjk
r@   wY nX xˆ|D ]€}xz|jtjƒD ]j}yt|jj	ƒ ƒ}W n tj
tfk
rŒ   wZY nX t |tjƒsœqZ|j}t |tjƒr´|j}|j| jkrZdS qZW qHW qW dS )z‚ Check if the func was called in any of the given methods,
    belonging to the *klass*. Returns True if so, False otherwise.
    FT)r+   r,   ÚFunctionDefrP   rt   Únodes_of_classÚCallÚnextÚfuncrr   ru   ÚStopIterationZBoundMethodÚ_proxiedZUnboundMethodr/   )	r   ÚklassÚmethodsrI   ry   Zinfer_methodr2   ZboundZfunc_objr7   r7   r8   Ú_called_in_methodsR  s*    

r„   c             C   s    y|j | ƒ}W n tjk
r$   dS X djtƒ}xj|D ]b}|tjkrFq6yt|jƒ ƒ}W n tjk
rn   w6Y nX t	|tj
ƒrˆt|ƒrˆdS |jƒ |kr6dS q6W dS )a4   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.
    Fz{}.propertyT)rP   r,   rt   Úformatr   ÚUninferabler~   rr   ru   r+   r{   r   Zpytype)r/   r‚   rw   Zproperty_namerv   ry   r7   r7   r8   Ú_is_attribute_propertym  s$    


r‡   c             C   sB   x<| j tjƒD ],}|j}t|tjƒr|jdkr|j rdS qW dS )NÚsuperTF)r|   r,   r}   r   r+   r-   r/   r0   )Zfundef_noder2   r   r7   r7   r8   Ú_has_bare_super_call�  s
    r‰   c             C   s~   y| j ||d�}t|ƒ}W n( tjk
r0   dS  tk
rB   dS X yt|ƒ dS  tjk
rf   dS  tk
rx   |S X dS )zÈ
    Safely infer the return value of a function.

    Returns None if inference failed or if there is some ambiguity (more than
    one node has been inferred). Otherwise returns inferred value.
    )ÚcontextN)Úinfer_call_resultr~   r,   ru   r€   )rN   ÚcallerrŠ   Zinferitr*   r7   r7   r8   Ú_safe_infer_call_result•  s    r�   c             C   s@   t |jƒ ƒ}t|tjƒr<|jƒ }tdd„ t| |ƒD ƒƒr<dS dS )Nc             s   s&   | ]\}}|o|o|j |j kV  qd S )N)r*   )r;   Z
first_slotZsecond_slotr7   r7   r8   rC   ±  s   z)_has_same_layout_slots.<locals>.<genexpr>TF)r~   rr   r+   r,   r[   ÚslotsrF   r   )rŽ   Zassigned_valuery   Zother_slotsr7   r7   r8   Ú_has_same_layout_slots¬  s    r�   ú+Unable to check methods signature (%s / %s)úmethod-check-failedúšUsed 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.ú4An attribute defined in %s line %s hides this methodúmethod-hiddenú~Used when a class defines a method which is hidden by an instance attribute from an ancestor class or set by some client code.ú1Access to member %r before its definition line %súaccess-member-before-definitionúGUsed when an instance member is accessed before it's actually assigned.ú%Attribute %r defined outside __init__úattribute-defined-outside-initúGUsed when an instance attribute is defined outside the __init__ method.ú1Access to a protected member %s of a client classúprotected-accessú¦Used 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.úMethod has no argumentúno-method-argumentúbUsed when a method which should have the bound instance as first argument has no argument defined.ú+Method should have "self" as first argumentúno-self-argumentú¬Used 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!ú0Class method %s should have %s as first argumentúbad-classmethod-argumentúÚUsed 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.ú4Metaclass method %s should have %s as first argumentúbad-mcs-method-argumentúÞUsed 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.ú:Metaclass class method %s should have %s as first argumentúbad-mcs-classmethod-argumentúîUsed 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.ú'Static method with %r as first argumentúbad-staticmethod-argumentú¢Used 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.úMethod could be a functionúno-self-useúYUsed when a method doesn't use its bound instance, and so could be written as a function.ú#Parameters differ from %s %r methodúarguments-differútUsed when a method has a different number of arguments than in the implemented interface or in an overridden method.ú#Signature differs from %s %r methodúsignature-differsúgUsed when a method signature is different than in the implemented interface or in an overridden method.ú7Method %r is abstract in class %r but is not overriddenúabstract-methodúbUsed when an abstract method (i.e. raise NotImplementedError) is not overridden in concrete class.ú0__init__ method from base class %r is not calledúsuper-init-not-calledúaUsed when an ancestor class method has an __init__ method which is not called by a derived class.úClass has no __init__ methodúno-initúEUsed when a class has no __init__ method, neither its parent classes.ú9__init__ method from a non direct base class %r is calledúnon-parent-init-calledúnUsed when an __init__ method is called on a class which is not in the direct ancestors for the analysed class.ú%Useless super delegation in method %rúuseless-super-delegationú”Used whenever we can detect that an overridden method is useless, relying on super() delegation to do the same thing as another method from the MRO.ú7Method %r was expected to be %r, found it instead as %rúinvalid-overridden-methodúˆUsed when we detect that a method was overridden as a property or the other way around, which could result in potential bugs at runtime.úCInvalid object %r in __slots__, must contain only non empty stringsúinvalid-slots-objectú=Used when an invalid (non-string) object occurs in __slots__.ú4Assigning to attribute %r not defined in class slotsúassigning-non-slotúCUsed when assigning to an attribute not defined in the class slots.úInvalid __slots__ objectúinvalid-slotsúhUsed when an invalid __slots__ is found in class. Only a string, an iterable or a sequence is permitted.ú$Inheriting %r, which is not a class.úinherit-non-classú?Used when a class inherits from something which is not a class.ú1Inconsistent method resolution order for class %rúinconsistent-mroú>Used when a class has an inconsistent method resolution order.úDuplicate bases for class %rúduplicate-basesú&Used when a class has duplicate bases.ú/Value %r in slots conflicts with class variableúclass-variable-slots-conflictúSUsed when a value in __slots__ conflicts with a class variable, property or method.ú9Consider using a decorator instead of calling classmethodúno-classmethod-decoratorúGUsed when a class method is defined without using the decorator syntax.ú:Consider using a decorator instead of calling staticmethodúno-staticmethod-decoratorúHUsed when a static method is defined without using the decorator syntax.ú/Class __slots__ should be a non-string iterableúsingle-string-used-for-slotsúHUsed when a class __slots__ is a simple string, rather than an iterable.úJClass %r inherits from object, can be safely removed from bases in python3úuseless-object-inheritanceúoUsed when a class inherit from object, which under python3 is implicit, hence can be safely removed from bases.ú-Cannot have defined parameters for propertiesúproperty-with-parametersú�Used when we detect that a property also has parameters, which are useless, given that properties cannot be called with additional arguments.) ZF0202ZE0202ZE0203ZW0201ZW0212ZE0211ZE0213ZC0202ZC0203ZC0204ZW0211ZR0201ZW0221ZW0222ZW0223ZW0231ZW0232ZW0233ZW0235ZW0236ZE0236ZE0237ZE0238ZE0239ZE0240ZE0241ZE0242ZR0202ZR0203ZC0205ZR0205ZR0206c               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚScopeAccessMapz'Store the accessed variables per scope.c             C   s   t jdd„ ƒ| _d S )Nc               S   s
   t jtƒS )N)ÚcollectionsÚdefaultdictÚlistr7   r7   r7   r8   Ú<lambda>�  s    z)ScopeAccessMap.__init__.<locals>.<lambda>)rñ   rò   Ú_scopes)r:   r7   r7   r8   Ú__init__€  s    zScopeAccessMap.__init__c             C   s.   t |ƒ}|dkrdS | j| |j j|ƒ dS )zSet the given node as accessed.N)r   rõ   Úattrnamer.   )r:   rN   Úframer7   r7   r8   Úset_accessedƒ  s    zScopeAccessMap.set_accessedc             C   s   | j j|i ƒS )z/Get the accessed variables for the given scope.)rõ   Úget)r:   Úscoper7   r7   r8   ÚaccessedŒ  s    zScopeAccessMap.accessedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rö   rù   rü   r7   r7   r7   r8   rð   }  s   	rð   c               @   s¨  e Zd ZdZefZdZeZdiZ	ddjd	d
ddœfddkd	dddœfddld	dddœfddmd	dddœffZ
dndd„Zejdd„ ƒZejd d!„ ƒZed"d#d$d%d&d'd(d)d*d+ƒ
d,d-„ ƒZd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ ZeZd6d7„ Zd8d9„ Zd:d;„ Zd<d=„ Zd>d?„ Zd@dA„ ZdBdC„ ZdDdE„ ZdFdG„ ZedHdIdJƒdKdL„ ƒZ dMdN„ Z!dOdP„ Z"e#e$j%j&e'dQœdRdS„ƒZ(dTdU„ Z)dVdW„ Z*dXdY„ Z+dod[d\„Z,d]d^„ Z-d_d`„ Z.dadb„ Z/dcdd„ Z0dedf„ Z1dgdh„ Z2dS )pÚClassCheckerzÛ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
    Úclassesé   zdefining-attr-methodsrö   Ú__new__ÚsetUpÚ__post_init__Úcsvz<method names>zGList of method names used to declare (i.e. assign) instance attributes.)ÚdefaultrK   ÚmetavarÚhelpzvalid-classmethod-first-argrn   z<argument names>z=List of valid names for the first argument in a class method.z%valid-metaclass-classmethod-first-argzGList of valid names for the first argument in a metaclass class method.zexclude-protectedÚ_asdictÚ_fieldsÚ_replaceÚ_sourceÚ_makez<protected access exclusions>zQList of member names, which should be excluded from the protected access warning.Nc             C   s$   t j| |ƒ tƒ | _g | _d | _d S )N)r   rö   rð   Ú	_accessedÚ_first_attrsÚ_meth_could_be_func)r:   Úlinterr7   r7   r8   rö   Ö  s    zClassChecker.__init__c             C   s   t | dd d�S )Nzdummy-variables-rgx)r  )r    )r:   r7   r7   r8   Ú
_dummy_rgxÜ  s    zClassChecker._dummy_rgxc             C   s   t | ddd�S )Nzignore-mixin-membersT)r  )r    )r:   r7   r7   r8   Ú_ignore_mixinà  s    zClassChecker._ignore_mixinzabstract-methodzno-initzinvalid-slotszsingle-string-used-for-slotszinvalid-slots-objectzclass-variable-slots-conflictzinherit-non-classzuseless-object-inheritancezinconsistent-mrozduplicate-basesc             C   st   | j |ƒ |jdkrRt|ƒrRy|jdƒ W n& tjk
rP   | jd||d� Y nX | j|ƒ | j|ƒ | j	|ƒ dS )z&init visit variable _accessed
        Úclassrö   zno-init)r0   rN   N)
Ú_check_bases_classesrK   r   Ú
local_attrr,   rt   Úadd_messageÚ_check_slotsÚ_check_proper_basesÚ_check_consistent_mro)r:   rN   r7   r7   r8   Úvisit_classdefä  s    


zClassChecker.visit_classdefc             C   sn   y|j ƒ  W n\ tk
r2   | jd|j|d� Y n8 tk
rV   | jd|j|d� Y n tk
rh   Y nX dS )z<Detect that a class has a consistent mro or duplicate bases.zinconsistent-mro)r0   rN   zduplicate-basesN)Úmror	   r  r/   r   ÚNotImplementedError)r:   rN   r7   r7   r8   r  þ  s    z"ClassChecker._check_consistent_mroc             C   s’   xŒ|j D ]‚}t|ƒ}|tjdfkr$qt|tjƒrB|jdtf ƒrBqt|tjƒ sXt	|ƒrl| j
d|jƒ |d� |jtjkr| j
d|j|d� qW dS )z`
        Detect that a class inherits something which is not
        a class or a type.
        Nz%s.typezinherit-non-class)r0   rN   zuseless-object-inheritance)Úbasesr   r,   r†   r+   rs   Úis_subtype_ofr   r[   ro   r  Ú	as_stringr/   rV   rý   )r:   rN   ÚbaseÚancestorr7   r7   r8   r  
  s    z ClassChecker._check_proper_basesc       	         s|  | j r |jdd… jƒ dkr dS | jj|ƒ}|jdkrB| j||ƒ | jjdƒsRdS | j	j
‰|jƒ ‰ �x|jjƒ D �]\}}|dkr„qp‡ fdd„|D ƒ}|sœqpd	d
„ |D ƒ}t‡fdd
„|D ƒƒrÂqpx°|j|ƒD ]4}d}x$|j| D ]}|jƒ jˆkrâd}qâW |rÎP qÎW y|j|ƒ W qp tjk
�rr   xD|D ]<}|jƒ jˆk�r.t|jƒ |ˆƒ�rX�q.| jd||d� �q.W Y qpX qpW dS )zˆclose a class node:
        check that instance attributes are defined in __init__ and check
        access to existent members
        é   NZmixinÚ	metaclasszattribute-defined-outside-initÚ__dict__c                s4   g | ],}t |jƒ tjtjfƒ r|jƒ ˆ kr|‘qS r7   )r+   Ú	statementr,   ÚDeleteÚ	AugAssignÚroot)r;   Ún)Úcurrent_moduler7   r8   r<   >  s   z/ClassChecker.leave_classdef.<locals>.<listcomp>c             s   s   | ]}|j ƒ V  qd S )N)rø   )r;   rN   r7   r7   r8   rC   H  s    z.ClassChecker.leave_classdef.<locals>.<genexpr>c             3   s    | ]}|j ˆ kpt|ƒV  qd S )N)r/   r   )r;   rø   )Údefining_methodsr7   r8   rC   J  s   FT)r0   rN   éûÿÿÿ)r  r/   Úlowerr  rü   rK   Ú_check_accessed_membersr  Úis_message_enabledÚconfigZdefining_attr_methodsr+  Zinstance_attrsÚitemsrY   Úinstance_attr_ancestorsrø   r  r,   rt   r„   r  )	r:   Zcnoderü   rv   ÚnodesÚframesÚparentZattr_definedrN   r7   )r-  r.  r8   Úleave_classdef"  sL    




zClassChecker.leave_classdefc       	      C   sJ  |j ƒ sdS | j|ƒ | j|ƒ |jjƒ }d| _| j||jdkƒ |jdkrZ| j	|ƒ dS xf|j
|jƒD ]V}y||j }W n tk
r�   whY nX t|tjƒs qh| j||d|ƒ | j||ƒ P qhW |j�r®xâ|jjD ]Ö}t|tjƒrò|jdkròdS t|tjƒ�r|jd	k�rdS t|ƒ}|�s"dS t|tjƒ�r\yt|j|ƒƒ}W n tjk
�rZ   dS X y4t|tjtjfƒ�rŽ|jd
ƒ�rŽ|jdƒ�rŽdS W qÔ tjk
�r¨   Y qÔX qÔW y~|j|jƒd }|jƒ }t|tjƒ�rì|jdk�rì|jjƒ }t|tjƒ�r*|j|j ƒ ƒ�r*|j!ƒ j|j"f}| j#d||d� W n tj$k
�rD   Y nX dS )z"check method arguments, overridingNTr&  rö   r`   ÚgetterÚsetterÚdeleterÚpropertyrp   rq   r   rI   zmethod-hidden)r0   rN   )r:  r;  r<  )%Ú	is_methodÚ_check_useless_super_delegationÚ_check_property_with_parametersr8  rø   r  Ú_check_first_arg_for_typerK   r/   Ú_check_initÚlocal_attr_ancestorsÚKeyErrorr+   r,   r{   Ú_check_signatureÚ _check_invalid_overridden_methodr   r6  Ú	Attributer÷   r-   r   r~   r‹   ru   rs   r[   rP   ZAttributeInferenceErrorÚinstance_attrr!  Úqnamer+  Ú
fromlinenor  rt   )	r:   rN   r‚   r`   Zparent_functionZ	decoratorry   Zoverridden_framer0   r7   r7   r8   Úvisit_functiondefk  sr    




  

zClassChecker.visit_functiondefc             C   sä  |j ƒ  s|jrdS |j}t|ƒdkr*dS |d }t|tjtjfƒsHdS |j}t|tj	ƒ slt|j
tjƒ rpdS yt|j
jjƒ ƒ}W n tjk
rš   dS X t|tjƒs¬dS |j
j|jkr¾dS |jjƒ }|j|ksðt|jtjƒ sð|jj|jkrôdS |jjƒ }d}xf|j|jƒD ]V}	y|	|j }W n tk
�r<   �wY nX t|tjƒ �s^t|j|jƒ�rbdS P �qW t|jƒ}
t |ƒ}|dk	�rÀdd„ }||jj!ƒ}||jj!ƒ}|�rÀ|�rÀ||k�rÀdS t"|
|ƒ�rà| j#d||jfd� dS )aQ  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.
        NrJ   r   c             S   s   dd„ t d | ƒD ƒS )Nc             S   s   g | ]}|j ƒ ‘qS r7   )r"  )r;   Ú
annotationr7   r7   r8   r<     s    zZClassChecker._check_useless_super_delegation.<locals>.form_annotations.<locals>.<listcomp>)Úfilter)Úannotationsr7   r7   r8   Úform_annotations  s    zFClassChecker._check_useless_super_delegation.<locals>.form_annotationszuseless-super-delegation)rN   r0   )$r>  r   ÚbodyÚlenr+   r,   ÚExprÚReturnr*   r}   r   rG  r~   Úexprrr   ru   r   ÚSuperr÷   r/   r8  rû   Zmro_pointerrK   rs   rø   rC  rD  r{   rd   r0   rA   r9   rN  rG   r  )r:   ÚfunctionrP  r(  r2   Z
super_callZcurrent_scoper‚   Z	meth_noder`   rh   r0   rO  Zcalled_annotationsZoverridden_annotationsr7   r7   r8   r?  Á  sd    







z,ClassChecker._check_useless_super_delegationc             C   s2   |j j r.t|j j ƒdkr.t|ƒr.| jd|d� d S )NrJ   zproperty-with-parameters)rN   )r0   rQ  r   r  )r:   rN   r7   r7   r8   r@  +  s     z,ClassChecker._check_property_with_parametersc             C   sl   t |ƒpt|ƒ}t |ƒpt|ƒ}|rF| rF| jd|jd|jf|d� n"| rh|rh| jd|jddf|d� d S )Nzinvalid-overridden-methodr=  )r0   rN   rI   )r   r   r  r/   rK   )r:   Zfunction_nodeZparent_function_nodeZparent_is_propertyZcurrent_is_propertyr7   r7   r8   rF  /  s     



z-ClassChecker._check_invalid_overridden_methodc             C   sê   d|j krd S xÖ|jdƒD ]È}|tjkr*qt|ƒ rNt|ƒ rN| jd|d� qt|tjƒrj| jd|d� qt	|dƒsvqt|tj
ƒr”dd„ |jD ƒ}n|jƒ }|tjkrªd S x6|D ].}y| j||ƒ W q° tjk
rÜ   w°Y q°X q°W qW d S )NÚ	__slots__zinvalid-slots)rN   zsingle-string-used-for-slotsÚiteredc             S   s   g | ]}|d  ‘qS )r   r7   )r;   Úitemr7   r7   r8   r<   W  s    z-ClassChecker._check_slots.<locals>.<listcomp>)ÚlocalsÚigetattrr,   r†   r   r   r  r+   rZ   ÚhasattrÚDictr4  rX  Ú_check_slots_eltru   )r:   rN   rŽ   ÚvaluesÚeltr7   r7   r8   r  C  s.    




zClassChecker._check_slotsc             C   sÄ   x¾|j ƒ D ]²}|tjkrq
t|tjƒ s6t|jtƒ rL| jd|jƒ |d� q
|jsf| jd|jƒ |d� |j	j
|jƒ}|r
t|ƒdkr¨|d j}t|tjƒr¨|jd kr¨d S | jd|jf|d� q
W d S )Nzinvalid-slots-object)r0   rN   rJ   r   zclass-variable-slots-conflict)rr   r,   r†   r+   rZ   r*   Ústrr  r"  rZ  rú   rQ  r8  Ú	AnnAssign)r:   r`  rN   ry   Zclass_variabler8  r7   r7   r8   r^  b  s&    

zClassChecker._check_slots_eltc             C   s’   |j ƒ rŽ|jjdk	r| jjƒ  | jjdƒs.dS |jjƒ }| jrŽ|j	dkrŽ|j
tkrŽ|jƒ p|t||j
ƒp|t|ƒp|t|ƒp|t|ƒ rŽ| jd|d� dS )zµon method node, check if this method couldn't be a function

        ignore class, static and abstract methods, initializer,
        methods overridden from a parent class.
        Nzno-self-userI   )rN   )r>  r0   r  Úpopr  r2  r8  rø   r  rK   r/   r   Úis_abstractr   r   r‰   r   r  )r:   rN   Z
class_noder7   r7   r8   Úleave_functiondef~  s    




zClassChecker.leave_functiondefc             C   s8   | j |ƒr| jj|ƒ dS | jjdƒs*dS | j|ƒ dS )zÐcheck 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)
        Nzprotected-access)Ú_uses_mandatory_method_paramr  rù   r  r2  Ú!_check_protected_attribute_access)r:   rN   r7   r7   r8   Úvisit_attribute˜  s    
zClassChecker.visit_attributec             C   s4   t |jƒ tjƒr&| j|ƒr&| jj|ƒ | j|ƒ d S )N)r+   Zassign_typer,   r*  rf  r  rù   Ú_check_in_slots)r:   rN   r7   r7   r8   Úvisit_assignattr§  s
    
zClassChecker.visit_assignattrc                sø   t ˆ jƒ}t|tjƒsdS |j}t|ƒs,dS d|jks>|j rBdS |j	ƒ }|dkrVdS t
dd„ |jƒ D ƒƒrpdS t
‡ fdd„|D ƒƒsôt
dd„ |D ƒƒsôtˆ j|ƒr¨dS ˆ j|jkrÄt|ˆ jƒrÄdS ˆ jdkràt|ˆ jjƒràdS | jdˆ jfˆ d	� dS )
zU Check that the given AssignAttr node
        is defined in the class slots.
        NrW  c             s   s"   | ]}d |j ko|jdkV  qdS )rW  rV   N)rZ  r/   )r;   r$  r7   r7   r8   rC   Â  s   z/ClassChecker._check_in_slots.<locals>.<genexpr>c             3   s   | ]}|j ˆ jkV  qd S )N)r*   r÷   )r;   Úslot)rN   r7   r8   rC   Ç  s    c             s   s   | ]}|j d kV  qdS )r'  N)r*   )r;   rk  r7   r7   r8   rC   Ê  s    Ú	__class__zassigning-non-slot)r0   rN   )r   rT  r+   r,   rs   r�   r   rZ  ZnewstylerŽ   rY   Ú	ancestorsr‡   r÷   rz   r�   r8  r*   r  )r:   rN   ry   r‚   rŽ   r7   )rN   r8   ri  ®  s4    

zClassChecker._check_in_slotszprotected-accesszno-classmethod-decoratorzno-staticmethod-decoratorc             C   s@   | j |ƒ |jd }t|tjƒs$d S | j|ƒr2d S | j|ƒ d S )Nr   )Ú_check_classmethod_declarationÚtargetsr+   r,   Z
AssignAttrrf  rg  )r:   Zassign_noderN   r7   r7   r8   Úvisit_assignÚ  s    


zClassChecker.visit_assignc                s´   t |jtjƒsdS |jj}t |tjƒ s2|jd
kr6dS |jdkrDdnd}|jƒ }t |tjƒs`dS |jj	d }t |tjƒs|dS |j‰ t
‡ fdd„|jƒ D ƒƒr°| j||jd d	� 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.
        NrH   Ústaticmethodzno-classmethod-decoratorzno-staticmethod-decoratorr   c             3   s   | ]}ˆ |j kV  qd S )N)r/   )r;   Úmember)Úmethod_namer7   r8   rC     s    z>ClassChecker._check_classmethod_declaration.<locals>.<genexpr>)rN   )rH   rq  )r+   r*   r,   r}   r   r-   r/   rû   r[   r0   rY   Z	mymethodsr  ro  )r:   rN   r   ÚmsgZparent_classZclassmeth_argr7   )rs  r8   rn  ç  s$    	 z+ClassChecker._check_classmethod_declarationc             C   s"  |j }t|ƒo|| jjk�rt|ƒ}|jjƒ }|dkrJ| jd||d� dS t|jt	j
ƒrzt|jjt	jƒrz|jjjdkrzdS | j|jƒrŠdS ||jkpœ||jk�s|jjƒ }t|t	jƒrðt|jƒdkrðt|jd t	jƒrð|jd j}t||ƒrðdS |jdƒ �r| j|ƒ�rdS | jd||d� 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.
        Nzprotected-access)rN   r0   rˆ   rJ   r   Ú__)r÷   r   r3  Zexclude_protectedr   rT  r"  r  r+   r,   r}   r   r-   r/   Ú_is_type_self_callÚ	basenamesr8  r(  ÚAssignrQ  ro  Z
AssignNamer‡   Ú
startswithÚ _is_called_inside_special_method)r:   rN   r÷   r‚   ZcalleeÚstmtr/   r7   r7   r8   rg    s6    




z.ClassChecker._check_protected_attribute_access)rN   Úreturnc             C   s0   y| j ƒ j}W n tk
r"   dS X |o.|tkS )zZ
        Returns true if the node is located inside a special (aka dunder) method
        F)rø   r/   ÚAttributeErrorr   )rN   Z
frame_namer7   r7   r8   rz  Q  s
    z-ClassChecker._is_called_inside_special_methodc             C   sD   t |tjƒoBt |jtjƒoB|jjdkoBt|jƒdkoB| j|jd ƒS )NrK   rJ   r   )	r+   r,   r}   r   r-   r/   rQ  r0   Ú_is_mandatory_method_param)r:   rT  r7   r7   r8   rv  \  s
    zClassChecker._is_type_self_callc             C   s,   | j r(|j| j d ks"| j d  r(d| _dS )zXcheck if the name handle an access to a class member
        if so, register it
        rJ   FNéÿÿÿÿr  )r  r/   r  )r:   rN   r7   r7   r8   Ú
visit_namee  s    zClassChecker.visit_namec       
         sB  d}�x6|j ƒ D �](\}‰ y|j|ƒ wW n tjk
r@   Y nX yt|j|ƒƒ wW n tk
rj   Y nX y|j|ƒ}W n tjk
r�   Y qX ‡ fdd„|D ƒ}|sªq|d jƒ ‰‡fdd„t	|ƒD ƒ}t
|ƒdkr|d }|jƒ }|j}xJˆ D ]B}	|	jƒ |krô|	j|k rôtj|	jƒ ||ƒ rô| jd	|	||fd
� qôW qW dS )z'check that accessed members are definedr}  Ú	ExceptionÚBaseExceptionc                s   g | ]}|ˆ kr|‘qS r7   r7   )r;   r{  )r6  r7   r8   r<   ‡  s    z8ClassChecker._check_accessed_members.<locals>.<listcomp>r   c                s(   g | ] \}}|d ks |j ƒ ˆ k	r|‘qS )r   )rû   )r;   Úir{  )rû   r7   r8   r<   �  s   rJ   zaccess-member-before-definition)rN   r0   N)r}  r�  r‚  )r4  r  r,   rt   r~   r5  r€   rH  rû   Ú	enumeraterQ  rø   rJ  Zare_exclusiver(  r  )
r:   rN   rü   Zexcsrv   ZdefstmtsZdefstmtrø   ÚlnoÚ_noder7   )r6  rû   r8   r1  n  sF    



z$ClassChecker._check_accessed_membersr   c             C   s*  |j j dkrdS |j j o"|jƒ d }| jj|ƒ | jd }|jdkr„|dksd|| jjksd|| jjkrx| jd||d� dS d| jd< n¢|j j sœ| jd|d	� nŠ|rÞ|jd
krÄ| j	|| jj|d|j
ƒ n| j	|| jj|d|j
ƒ nH|jd
ksô|j
dk�r| j	|| jj|d|j
ƒ n|dk�r&| jd|d	� dS )al  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   rJ   rq  r:   zbad-staticmethod-argument)r0   rN   zno-method-argument)rN   rH   zbad-mcs-classmethod-argumentzbad-mcs-method-argumentZ__class_getitem__zbad-classmethod-argumentzno-self-argumentr  r  )r0   Úargnamesr  r.   rK   r3  Zvalid_classmethod_first_argZ%valid_metaclass_classmethod_first_argr  Ú_check_first_arg_configr/   )r:   rN   r&  Z	first_argÚfirstr7   r7   r8   rA  ª  sJ    






z&ClassChecker._check_first_arg_for_typec             C   sf   ||krbt |ƒdkr"t|d ƒ}n,djdd„ |d d… D ƒƒ}d||d	 f }| j|||f|d� d S )
NrJ   r   z, c             s   s   | ]}t |ƒV  qd S )N)Úrepr)r;   Úvr7   r7   r8   rC   ï  s    z7ClassChecker._check_first_arg_config.<locals>.<genexpr>z%s or %r)r0   rN   r  r  )rQ  rŠ  Újoinr  )r:   r‰  r3  rN   Úmessagers  Zvalidr7   r7   r8   rˆ  ê  s    z$ClassChecker._check_first_arg_configc             C   sz   dd„ }t |ƒrdS tt||ƒjƒ dd„ d�}xF|D ]>\}}|jjƒ }||krPq4||jkr\q4| jd|||jfd� q4W dS )	z^check that the given class node implements abstract methods from
        base classes
        c             S   s   | j dd�S )NF)Zpass_is_abstract)rd  )rI   r7   r7   r8   rd  ø  s    z6ClassChecker._check_bases_classes.<locals>.is_abstractNc             S   s   | d S )Nr   r7   )rY  r7   r7   r8   rô     s    z3ClassChecker._check_bases_classes.<locals>.<lambda>)Úkeyzabstract-method)rN   r0   )	r   Úsortedr   r4  r8  rø   rZ  r  r/   )r:   rN   rd  rƒ   r/   rI   Úownerr7   r7   r8   r  ó  s    

z!ClassChecker._check_bases_classesc       
      C   sÒ  | j jdƒ r | j jdƒ r dS |jjƒ }t|ƒ}t|ƒ}�x*|jtjƒD �]}|j	}t
|tjƒ sJ|jdkrpqJt
|jtjƒr t
|jj	tjƒr |jj	jdkr dS y¨x¢|jjƒ D ]”}|tjkr¾q®t
|tjƒròt
|jtjƒròt|jƒrò|jjdkròdS t
|tjƒ�rdS y
||= W q® tk
�r@   ||k�r<| jd||jd� Y q®X q®W W qJ tjk
�rb   wJY qJX qJW xd|jƒ D ]X\}}t|dgƒ�rŒ�qrt|ƒ}	|jdk�sr|	�r¶|	jdk�r¶�qr| jd|j|d	� �qrW dS )
z“check that the __init__ method call super or ancestors'__init__
        method (unless it is used for type hinting with `typing.overload`)
        zsuper-init-not-calledznon-parent-init-calledNrö   rˆ   )rN   r0   ztyping.overloadrV   )r0   rN   )r  r2  r8  rø   Ú_ancestors_to_callÚdictr|   r,   r}   r   r+   rG  r÷   rT  r-   r/   rr   r†   rs   r�   r[   r   r   rU  rD  r  ru   r4  r   r   )
r:   rN   Ú
klass_nodeÚto_callZnot_called_yetr{  rT  r‚   rI   rn   r7   r7   r8   rB    sR    

	


zClassChecker._check_initc             C   sÜ   t |tjƒot |tjƒs0| jd||f|d� dS |jƒ }t||ƒ}t||ƒ}|jjdksd|jjdkrhdS t|jƒrvdS t	|ƒr‚dS t
||| jd�rª| jd||jf|d� n.t|jjƒt|jjƒk rØ| jd||jf|d� dS )z@check that the signature of the two given methods match
        zmethod-check-failed)r0   rN   N)rg   zarguments-differzsignature-differs)r+   r,   r{   r  Zinstantiate_classr
   r0   r   r/   r   rl   r  rQ  Údefaults)r:   Zmethod1Z	refmethodZ
class_typern   Úinstancer7   r7   r8   rE  I  s*    


zClassChecker._check_signaturec             C   s   | j |jƒS )zžCheck that attribute lookup name use first attribute variable name

        Name is `self` for method, `cls` for classmethod and `mcs` for metaclass.
        )r~  rT  )r:   rN   r7   r7   r8   rf  p  s    z)ClassChecker._uses_mandatory_method_paramc             C   s"   | j o t|tjƒo |j| j d kS )zžCheck if astroid.Name corresponds to first attribute variable name

        Name is `self` for method, `cls` for classmethod and `mcs` for metaclass.
        rJ   r  )r  r+   r,   r-   r/   )r:   rN   r7   r7   r8   r~  w  s    z'ClassChecker._is_mandatory_method_paraméþÿÿÿ)rö   r  r  r  )rn   )rn   )r  r  r  r  r  )N)r   )3rý   rþ   rÿ   r   r   Ú__implements__r/   ÚMSGSÚmsgsÚpriorityÚoptionsrö   r   Zcachedpropertyr  r  r   r  r  r  r9  rK  Úvisit_asyncfunctiondefr?  r@  rF  r  r^  re  rh  rj  ri  rp  rn  rg  rq  r,   Znode_classesZNodeNGr"   rz  rv  r€  r1  rA  rˆ  r  rB  rE  rf  r~  r7   r7   r7   r8   r  ‘  s’       
ITj,'C
		<
@	;'r  c               @   s�   e Zd ZdZefZdZddde dd d!gifddddd"gifdddi fdœZd#Z	e
dddƒdd„ ƒZeZdd„ Zedd„ ƒZdd„ Zdd„ ZdS )$ÚSpecialMethodsCheckerzOChecker which verifies that special methods
    are implemented correctly.
    r  z__iter__ returns non-iteratorznon-iterator-returnedzaUsed when an __iter__ method returns something which is not an iterable (i.e. has no `%s` method)Z	old_namesÚW0234úold-non-iterator-returned-1ÚE0234úold-non-iterator-returned-2z6The special method %r expects %s param(s), %d %s givenz#unexpected-special-method-signaturezˆEmitted when a special method was defined with an invalid number of parameters. If it has too few or too many, it might not work at all.ÚE0235úbad-context-managerz,__len__ does not return non-negative integerzinvalid-length-returnedzPUsed when a __len__ method returns something which is not a non-negative integer)ZE0301ZE0302ZE0303r  c             C   sL   |j ƒ sd S |jdkr | j|ƒ |jdkr4| j|ƒ |jtkrH| j|ƒ d S )NÚ__iter__Ú__len__)r>  r/   Ú_check_iterÚ
_check_lenr   Ú"_check_unexpected_method_signature)r:   rN   r7   r7   r8   rK  ©  s    




z'SpecialMethodsChecker.visit_functiondefc       
      C   s  t |j }|d krd S |jj r.|jj r.d S t|td gƒrH|jj}n|jjdd … }t|ƒt|jjƒ }t|jjƒ}|| }t|t	ƒrœ||k}d| }nB|| }|dkr²d}n,|dk rÀd}n|dkrÞ|| dkpÚ|jj }|�r|dkrðdnd}	| j
d	|j|||	f|d
� d S )Nz.staticmethodrJ   zbetween %d or %dr   FTÚwasÚwerez#unexpected-special-method-signature)r0   rN   )r   r/   r0   r>   r   r   rQ  r•  r+   r^   r  )
r:   rN   Zexpected_paramsra   Ú	mandatoryÚoptionalZcurrent_paramsÚemitÚrestZverbr7   r7   r8   r©  º  s6    



z8SpecialMethodsChecker._check_unexpected_method_signaturec             C   sž   | t jkrdS t| tƒrdS t| t jƒrPy| jtƒ dS  t jk
rL   Y qšX nJt| t jƒrš| j	ƒ }|ršt|t jƒršy|jtƒ dS  t jk
r˜   Y nX dS )NTF)
r,   r†   r+   r   rs   r  ÚNEXT_METHODrt   r[   r&  )rN   r&  r7   r7   r8   Ú_is_iteratoré  s&    



z"SpecialMethodsChecker._is_iteratorc             C   s.   t ||ƒ}|d k	r*| j|ƒs*| jd|d� d S )Nznon-iterator-returned)rN   )r�   r±  r  )r:   rN   ry   r7   r7   r8   r§    s    

z!SpecialMethodsChecker._check_iterc             C   s�   t ||ƒ}| s|tjkrd S t|tjƒrF|jdkrFt|tjƒ rFd S t|tjƒsd| jd|d� d S |j}t|t	ƒ s~|dk rŒ| jd|d� d S )NÚintzinvalid-length-returned)rN   r   )
r�   r,   r†   r+   rs   r/   rZ   r  r*   r²  )r:   rN   ry   r*   r7   r7   r8   r¨    s    

z SpecialMethodsChecker._check_lenN)rŸ  r   )r¡  r¢  )r£  r¤  r—  )rý   rþ   rÿ   r   r   r˜  r/   r°  rš  r›  r   rK  r�  r©  rq  r±  r§  r¨  r7   r7   r7   r8   rž  ƒ  s8   

/rž  rö   c             C   sN   i }xD| j dd�D ]4}yt|j|ƒƒ||< W q tjk
rD   wY qX qW |S )z˜return 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
    F)Zrecurs)rm  r~   r[  r,   ru   )r“  rI   r”  Z	base_noder7   r7   r8   r‘    s    r‘  c             C   s    | j t| ƒƒ | j t| ƒƒ dS )z.required method to auto register this checker N)Zregister_checkerr  rž  )r  r7   r7   r8   Úregister,  s    r³  )N)r�   r‘   r’   )r“   r”   r•   )r–   r—   r˜   )r™   rš   r›   )rœ   r�   rž   )rŸ   r    r¡   )r¢   r£   r¤   )r¥   r¦   r§   )r¨   r©   rª   )r«   r¬   r­   )r®   r¯   r°   )r±   r²   r³   )r´   rµ   r¶   )r·   r¸   r¹   )rº   r»   r¼   )r½   r¾   r¿   )rÀ   rÁ   rÂ   )rÃ   rÄ   rÅ   )rÆ   rÇ   rÈ   )rÉ   rÊ   rË   )rÌ   rÍ   rÎ   )rÏ   rÐ   rÑ   )rÒ   rÓ   rÔ   )rÕ   rÖ   r×   )rØ   rÙ   rÚ   )rÛ   rÜ   rÝ   )rÞ   rß   rà   )rá   râ   rã   )rä   rå   ræ   )rç   rè   ré   )rê   rë   rì   )rí   rî   rï   )rö   )Fr   rñ   Ú	itertoolsr   r   r,   r   r   Zastroid.basesr   r   Zastroid.exceptionsr   r	   Zastroid.scoped_nodesr
   Zpylint.checkersr   Zpylint.checkers.utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Zpylint.interfacesr   Zpylint.utilsr    r°  rm   ZBUILTIN_DECORATORSÚ
namedtupler&   r'   r9   rA   rG   rM   rO   rR   rd   rj   rl   ro   rz   r„   r‡   r‰   r�   r�   r™  rð   r  rž  r‘  r³  r7   r7   r7   r8   Ú<module>   s  T(9. 
                                                                       y 
