o
    g]                     @   sj   d Z ddl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 ZG d	d
 d
ejZdd ZdS )z'Looks for  comparisons to empty string.    N)AnyIterable)nodes)checkers
interfaces)utilsc                 C   s   t | tjo
| jdkS )N )
isinstancer   Constvaluenode r   [/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pylint/extensions/emptystring.py_is_constant_empty_str   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 )CompareToEmptyStringCheckerzChecks 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-stringC1901)z!Avoid comparisons to empty stringr   z@Used when Pylint detects comparison to an empty string 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isr         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_compare1   s$   z)CompareToEmptyStringChecker.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   registerN   s   r:   )r/   r   typingr   r   astroidr   pylintr   r   pylint.checkersr   r   BaseCheckerr   r:   r   r   r   r   <module>   s   3