관리-도구
편집 파일: comparison_checker.cpython-311.pyc
� �܋f(6 � �� � d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ej ej ej ej fZ ed� � Z ed� � Zd Zd ej defd�Z G d � de� � ZdS )z*Comparison checker from the basic checker.� N)�nodes)�utils)� _BasicChecker)�HIGH)�==�!=�<�>z<=z>=)�is�is notr r z builtins.type�call�returnc �v � t | t j � � ot | j � � dk o| j S )z3Is this a call with exactly 1 positional argument ?� )� isinstancer �Call�len�args�keywords)r s �x/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pylint/checkers/base/comparison_checker.py�_is_one_arg_pos_callr s0 � ��d�E�J�'�'�U�C�� �N�N�a�,?�U�� �DU�U� c �� � e Zd ZdZddddddgifdd d ddd �Z d)dej dej dej deddf d�Z d)dej dej dej deddf d�Z dej dej ddfd�Zdej ddfd�Zdej ddfd�Z dej ddfd�Z ej ddddd d!d"� � dej ddfd#�� � Zdej ddfd$�Zdej d%ej d&ed'ej ddf d(�ZdS )*�ComparisonCheckera Checks for comparisons. - singleton comparison: 'expr == True', 'expr == False' and 'expr == None' - yoda condition: 'const "comp" right' where comp can be '==', '!=', '<', '<=', '>' or '>=', and right can be a variable, an attribute, a method or a function )�Comparison %s should be %s�singleton-comparisonzQUsed when an expression is compared to singleton values like True, False or None.z4Use isinstance() rather than type() for a typecheck.�unidiomatic-typecheckz�The idiomatic way to perform an explicit typecheck in Python is to use isinstance(x, Y) rather than type(x) == Y, type(x) is Y. Though there are unusual situations where these give different results.� old_names)�W0154zold-unidiomatic-typecheck)zBIn '%s', use '%s' when comparing constant literals not '%s' ('%s')�literal-comparisonz�Used when comparing an object to a literal, which is usually what you do not want to do, since you can compare to a different literal than what was expected altogether.)zRedundant comparison - %s�comparison-with-itselfz/Used when something is compared against itself.)z=Comparison between constants: '%s %s %s' has a constant value�comparison-of-constantsz�When two literals are compared with each other the result is a constant. Using the constant directly is both easier to read and more performant. Initializing 'True' and 'False' this way is not required since Python 2.3.)z;Comparing against a callable, did you omit the parenthesis?�comparison-with-callablez�This message is emitted when pylint detects that a comparison with a callable was made, which might suggest that some parenthesis were omitted, resulting in potential unwanted behaviour.)r �nan-comparisonzRUsed when an expression is compared to NaN values like numpy.NaN and float('nan').)�C0121�C0123�R0123�R0124�R0133�W0143�W0177F� left_value�right_value� root_node�checking_for_absencer Nc � � t j |� � r |j |}}n t j |� � r |j |}}ndS ddd�}|dv r�d}ddd�} d d d�} ||u}|� || � |� � � |� � � � � |t j |� � s|rdnd � | | � |� � � � � � � | | � � }n@|| � |� � � |� � � � � }| � d|d|� � � � d�|f�� � dS )z=Check if == or != is being used to compare a singleton value.Nz '{} is {}'z'{} is not {}')FT> FTzB{} if checking for the singleton value {}, or {} if testing for {}znot {}z{}� truthiness� falsiness)TFz 'bool({})'z'{}'r �'��noder )r �is_singleton_const�value�format� as_string�is_test_condition�add_message) �selfr, r- r. r/ � singleton�other_value�singleton_comparison_example�suggestion_template�truthiness_example�truthiness_phrase�checking_truthiness� suggestions r �_check_singleton_comparisonz-ComparisonChecker._check_singleton_comparisonT s� � � �#�J�/�/� �%/�%5�{�{�I�I� � %�k� 2� 2� �%0�%6� �{�I�I��F�/;�CS�'T�'T�$� � �%�%�T� � *2��!>�!>��'3�K� H� H�� #,�3G�"G��,�3�3�,�-A�B�I�I��(�(�*�*�K�,A�,A�,C�,C�� � � !�2�9�=�=� �BU� �L�L���&�&�':�;�B�B�#�-�-�/�/�� �� � "�"5�6�� �J�J�"