
    yIf                        d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 erd dl
mZ  ed          Z ed          Z ed	          Z G d
 de          ZddZdS )    )annotations)TYPE_CHECKING)nodes)BaseChecker)HIGH)PyLinter)<z<=>z>=z!=z==)iszis not)inznot inc                  .    e Zd ZdZdZddiZdd	ZddZdS )BadChainedComparisonCheckerz5Checks for unintentional usage of chained comparison.bad-chained-comparisonW3601)zTSuspicious %s-part chained comparison using semantically incompatible operators (%s)r   zUsed when there is a chained comparison where one expression is part of two comparisons that belong to different semantic groups ("<" does not mean the same thing as "is", chaining them in "0 < x is None" is probably a mistake).	operators	list[str]returnboolc                    t           t          t          fD ]}|d         |v r|t          fd|D                        S )Nr   c              3      K   | ]}|v V  	d S N ).0ogroups     Z/var/www/piapp/venv/lib/python3.11/site-packages/pylint/checkers/bad_chained_comparison.py	<genexpr>zHBadChainedComparisonChecker._has_diff_semantic_groups.<locals>.<genexpr>*   s'      55aqEz555555    )COMPARISON_OPIDENTITY_OPMEMBERSHIP_OPall)selfr   semantic_groupr   s      @r   _has_diff_semantic_groupsz5BadChainedComparisonChecker._has_diff_semantic_groups%   sT    ,k=I 	' 	'N|~--&555595555555r   nodenodes.CompareNonec                B   t          d |j        D                       }|                     |          rkt          |j                   }d                    d |d d         D                       d|d          dz   }|                     d|||ft                     d S d S )	Nc                    h | ]
}|d          S )r   r   )r   ops     r   	<setcomp>z<BadChainedComparisonChecker.visit_compare.<locals>.<setcomp>-   s    555bBqE555r   z, c              3  "   K   | ]
}d | d V  dS )'Nr   )r   r   s     r   r   z<BadChainedComparisonChecker.visit_compare.<locals>.<genexpr>1   s*      ;;q(a(((;;;;;;r   z and 'r.   r   )r&   args
confidence)sortedopsr%   lenjoinadd_messager   )r#   r&   r   	num_partsincompatibless        r   visit_comparez)BadChainedComparisonChecker.visit_compare,   s    55DH55566	)))44 
	tx==*I		;;IcrcN;;;;;>WyQS}>W>W>WW  (/	      
	 
	r   N)r   r   r   r   )r&   r'   r   r(   )__name__
__module____qualname____doc__namemsgsr%   r9   r   r   r   r   r      sV        ??#D 
	D6 6 6 6     r   r   linterr   r   r(   c                J    |                      t          |                      d S r   )register_checkerr   )r@   s    r   registerrC   ;   s%    
7??@@@@@r   N)r@   r   r   r(   )
__future__r   typingr   astroidr   pylint.checkersr   pylint.interfacesr   pylint.lintr   	frozensetr   r    r!   r   rC   r   r   r   <module>rK      s   
 # " " " " "                   ' ' ' ' ' ' " " " " " " %$$$$$$	<==i())	*++" " " " "+ " " "JA A A A A Ar   