
    e:	                        d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 erddl
mZ ddd	d
dZ ed      Z G d de      ZddZy)zjChecks for yoda comparisons (variable before constant)
See https://en.wikipedia.org/wiki/Yoda_conditions.
    )annotations)TYPE_CHECKING)nodes)BaseCheckerutils)PyLinter>>=<<=)r   r   r	   r
   )z==z!=r   r	   r   r
   c                  |    e Zd ZdZdZddddddgifiZd	Z	 	 	 	 	 	 	 	 	 	 dd
Z ej                  d      dd       Z
y)"MisplacedComparisonConstantCheckerz1Checks the placement of constants in comparisons.zcomparison-placementC2201zComparison should be %smisplaced-comparison-constantzUsed when the constant is placed on the left side of a comparison. It is usually clearer in intent to place it in the right hand side of the comparison.	old_names)C0122z!old-misplaced-comparison-constant c                    t        |t        j                        ry t        j	                  ||      }|j                          d| d|j                  }| j                  d||f       y )N r   )nodeargs)
isinstancer   ConstREVERSED_COMPSget	as_stringvalueadd_message)selfr   leftrightoperator
suggestions         H/usr/lib/python3/dist-packages/pylint/extensions/comparison_placement.py_check_misplaced_constantz<MisplacedComparisonConstantChecker._check_misplaced_constant*   sa     eU[[)!%%h9)*!H:QtzznE
8t:-X    c                    t        |j                        dk7  ry |j                  }|j                  d   \  }}|t        v r0t	        |t
        j                        r| j                  ||||       y y y )N   r   )lenopsr    COMPARISON_OPERATORSr   r   r   r%   )r   r   r    r"   r!   s        r$   visit_comparez0MisplacedComparisonConstantChecker.visit_compare7   sd     txx=Ayy((1+%++
40M**4uhG 1N+r&   N)
r   nodes.Comparer    nodes.NodeNGr!   r.   r"   strreturnNone)r   r-   r0   r1   )__name__
__module____qualname____doc__namemsgsoptionsr%   r   only_required_for_messagesr,   r   r&   r$   r   r      s    ; "D%+A IJK
	D GYY Y 	Y
 Y 
Y &U%%&EF	H G	Hr&   r   c                8    | j                  t        |              y )N)register_checkerr   )linters    r$   registerr=   D   s    
>vFGr&   N)r<   r   r0   r1   )r5   
__future__r   typingr   astroidr   pylint.checkersr   r   pylint.lintr   r   	frozensetr+   r   r=   r   r&   r$   <module>rD      sM   
 #    .$$S= !CD )H )HXHr&   