o
    gF                     @   sr   d Z ddlZddlmZmZ ddlZddlm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 zero.    N)AnyIterable)nodes)checkers
interfaces)utilsc                 C   s   t | tjo
| jdkS )Nr   )
isinstanceastroidConstvaluenode r   ]/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pylint/extensions/comparetozero.py_is_constant_zero   s   r   c                   @   sJ   e Zd ZdZejfZdZddiZdZ	dZ
eddejdd	f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!
    compare-to-zeroC2001)zAvoid comparisons to zeror   z4Used when Pylint detects comparison to a 0 constant.r   r   returnNc           
      C   s   g d}d|j fg}||j t|}ttj| }tt|d D ]2}|| }||d  }||d  }d}	t	|rB||v rBd}	n
||v rLt	|rLd}	|	rU| j
d|d q#d S )	N)z!=z==zis notis       FTr   r   )leftextendopsiterlist	itertoolschainrangelenr   add_message)
selfr   
_operatorsr   iter_opsops_idxop_1op_2op_3error_detectedr   r   r   visit_compare3   s$   z"CompareToZeroChecker.visit_compare)__name__
__module____qualname____doc__r   IAstroidChecker__implements__namemsgspriorityoptionsr   check_messagesr   Comparer,   r   r   r   r   r      s    r   c                 C   s   |  t|  dS )z.Required method to auto register this checker.N)register_checkerr   )linterr   r   r   registerP   s   r;   )r0   r   typingr   r   r	   r   pylintr   r   pylint.checkersr   r   BaseCheckerr   r;   r   r   r   r   <module>   s   3