B
    A!p\G	                 @   s^   d Z ddlZddlZddlmZ ddl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)
interfaces)checkers)utilsc             C   s   t | tjo| jdkS )Nr   )
isinstanceastroidZConstvalue)node r	   >lib/python3.7/site-packages/pylint/extensions/comparetozero.py_is_constant_zero   s    r   c               @   s>   e Zd ZdZejfZdZddiZdZ	dZ
eddd Zd	S )
CompareToZeroCheckerzChecks for comparisons to zero.
    Most of the times you should use the fact that integers with a value of 0 are false.
    An exception to this rule is when 0 is allowed in the program and has a
    different meaning than None!
    zcompare-to-zeroZC2001)zAvoid comparisons to zerozcompare-to-zeroz4Used when Pylint detects comparison to a 0 constant.r	   c       	      C   s   ddddg}d|j fg}||j ttj| }xxtt|d D ]d}|| }||d  }||d  }d}t|r||krd	}n||krt|rd	}|rD| j	d
|d qDW d S )Nz!=z==zis notis       FTzcompare-to-zero)r   )
leftextendopslist	itertoolschainrangelenr   Zadd_message)	selfr   Z
_operatorsr   Zops_idxZop_1Zop_2Zop_3Zerror_detectedr	   r	   r
   visit_compare-   s    z"CompareToZeroChecker.visit_compareN)__name__
__module____qualname____doc__r   ZIAstroidCheckerZ__implements__nameZmsgsZpriorityZoptionsr   Zcheck_messagesr   r	   r	   r	   r
   r      s   r   c             C   s   |  t|  dS )z.Required method to auto register this checker.N)Zregister_checkerr   )Zlinterr	   r	   r
   registerI   s    r!   )r   r   r   Zpylintr   r   Zpylint.checkersr   r   ZBaseCheckerr   r!   r	   r	   r	   r
   <module>   s   2