3
tûœ]˜	  ã               @   sV   d Z ddlZddlZddlmZmZ ddlmZ dd„ ZG dd„ dej	ƒZ
d	d
„ ZdS )z'Looks for  comparisons to empty string.é    N)ÚcheckersÚ
interfaces)Úutilsc             C   s   t | tjƒo| jdkS )NÚ )Ú
isinstanceÚastroidZConstÚvalue)Únode© r
   ú?/tmp/pip-build-fn42xldr/pylint/pylint/extensions/emptystring.pyÚ_is_constant_empty_str   s    r   c               @   s>   e Zd ZdZejfZdZdd
iZdZ	f Z
ejdƒdd„ ƒZd	S )ÚCompareToEmptyStringCheckerzùChecks for comparisons to empty string.
    Most of the times you should use the fact that empty strings are false.
    An exception to this rule is when an empty string value is allowed in the program
    and has a different meaning than None!
    úcompare-to-empty-stringZC1901ú!Avoid comparisons to empty stringú@Used when Pylint detects comparison to an empty string constant.é   c       	      C   s°   ddddg}d|j fg}|j|jƒ ttj|Ž ƒ}xxtt|ƒd ƒD ]d}|| }||d  }||d  }d}t|ƒr‚||kr‚d	}n||kr–t|ƒr–d	}|rD| j	d
|d� qDW d S )Nz!=z==zis notÚisr   r   é   FTzcompare-to-empty-string)r	   )
ÚleftÚextendÚopsÚlistÚ	itertoolsÚchainÚrangeÚlenr   Zadd_message)	Úselfr	   Ú
_operatorsr   Zops_idxZop_1Zop_2Zop_3Zerror_detectedr
   r
   r   Úvisit_compare,   s    z)CompareToEmptyStringChecker.visit_compareN)r   r   r   éþÿÿÿ)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ZIAstroidCheckerZ__implements__ÚnameZmsgsÚpriorityÚoptionsr   Zcheck_messagesr   r
   r
   r
   r   r      s     r   c             C   s   | j t| ƒƒ dS )z.Required method to auto register this checker.N)Zregister_checkerr   )Zlinterr
   r
   r   ÚregisterH   s    r'   )r#   r   r   Zpylintr   r   Zpylint.checkersr   r   ZBaseCheckerr   r'   r
   r
   r
   r   Ú<module>   s   2