Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/pylint/checkers/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/pylint/checkers/__pycache__/format.cpython-311.pyc

�

�܋f�k���UdZddlmZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZmZdd	lmZdd
lmZddlmZddlmZdd
lmZmZmZe
rddlmZejdkrddl	mZnddl mZhd�Z!ej"ej#hZ$dddddddddddej%ifdddd �Z&d!e'd"<d3d+�Z(Gd,�d$��Z)Gd-�d.ee��Z*d4d2�Z+dS)5z�Python code format's checker.

By default, try to follow Guido's style guide :

https://www.python.org/doc/essays/styleguide/

Some parts of the process_token method is based from The Tab Nanny std module.
�)�annotationsN)�reduce)�Match)�
TYPE_CHECKING)�nodes)�BaseRawFileChecker�BaseTokenChecker)�only_required_for_messages)�WarningScope)�HIGH)�MessageDefinitionTuple)�	OPTION_PO�PragmaParserError�parse_pragma)�PyLinter)��)�Literal>�if�in�del�for�not�elif�with�raise�while�yield�assert�except�return�=�:=)zLine too long (%s/%s)�
line-too-longz=Used when a line is longer than a given number of characters.)z Too many lines in module (%s/%s)�too-many-linesz@Used when a module has too many lines, reducing its readability.)zTrailing whitespace�trailing-whitespacezHUsed when there is whitespace between the end of a line and the newline.)zFinal newline missing�missing-final-newlinez7Used when the last line in a file is missing a newline.)zTrailing newlines�trailing-newlinesz3Used when there are trailing blank lines in a file.)z)Bad indentation. Found %s %s, expected %s�bad-indentationzUUsed when an unexpected number of indentation's tabulations or spaces has been found.)zUnnecessary semicolon�unnecessary-semicolonzeUsed when a statement is ended by a semi-colon (";"), which isn't necessary (that's python, not C ;).z(More than one statement on a single line�multiple-statementsz<Used when more than on statement are found on the same line.�scope)z#Unnecessary parens after %r keyword�superfluous-parenszLUsed when a single item in parentheses follows an if, for, or other keyword.)zMixed line endings LF and CRLF�mixed-line-endingsz@Used when there are mixed (LF and CRLF) newline signs in a file.)zEUnexpected line ending format. There is '%s' while it should be '%s'.�unexpected-line-ending-formatz3Used when there is different newline than expected.)�C0301�C0302�C0303�C0304�C0305�W0311�W0301�C0321�C0325�C0327�C0328z!dict[str, MessageDefinitionTuple]�MSGS�tokens�TokenWrapper�line_end�int�token�strr!�boolc���|dkr|�|dz
��|kpG|dkoA|�|dz
��|ko%|�|dz
��tjkS)Nr��)r@�type�tokenize�COMMENT)r<r>r@s   �g/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pylint/checkers/format.py�_last_token_on_line_isrJzst���1��	0��L�L��A��&�&�%�/�	:��a�<�:��L�L��A��&�&�%�/�:��K�K��1��%�%��)9�9��c�B�eZdZdZdd�Zdd
�Zdd�Zdd�Zdd
�Zdd�Z	dS)r=z3A wrapper for readable access to token information.r<�list[tokenize.TokenInfo]r!�Nonec��||_dS�N��_tokens)�selfr<s  rI�__init__zTokenWrapper.__init__�s
������rK�idxr?rAc�(�|j|dS)NrDrQ�rSrUs  rIr@zTokenWrapper.token�����|�C� ��#�#rKc�(�|j|dS)NrrQrWs  rIrFzTokenWrapper.type�rXrKc�4�|j|ddS)NrErrQrWs  rI�
start_linezTokenWrapper.start_line�����|�C� ��#�A�&�&rKc�4�|j|ddS)NrErDrQrWs  rI�	start_colzTokenWrapper.start_col�r\rKc�(�|j|dS)N�rQrWs  rI�linezTokenWrapper.line�rXrKN�r<rMr!rN)rUr?r!rA)rUr?r!r?)
�__name__�
__module__�__qualname__�__doc__rTr@rFr[r^ra�rKrIr=r=�s�������=�=�����$�$�$�$�$�$�$�$�'�'�'�'�'�'�'�'�$�$�$�$�$�$rKc�x��eZdZdZdZeZdddddd�fd	d
ddd
d�fdddddd�fdddddd�fdddddd�fdddddd�fddddd d�fd!d"d#d$gd%�d&d'�ffZdT�fd,�ZdUd1�Z	dVd4�Z
dWd7�ZdXd8�ZdYd<�Z
ed=��dZd?���Zd[dA�Zd\dC�Zd]dF�Zed^dI���Zed_dK���Zed`dN���ZdadP�ZdbdS�Z�xZS)c�
FormatCheckerzvFormatting checker.

    Checks for :
    * unauthorized constructions
    * strict indentation
    * line length
    �formatzmax-line-length�dr?z<int>z.Maximum number of characters on a single line.)�defaultrF�metavar�helpzignore-long-lines�regexpz<regexp>z^\s*(# )?<?https?://\S+>?$z>Regexp for a line that is allowed to be longer than the limit.)rFrmrlrnzsingle-line-if-stmtF�ynz<y or n>zOAllow the body of an if to be on the same line as the test if there is no else.zsingle-line-class-stmtzfAllow the body of a class to be on the same line as the declaration if body contains single statement.zmax-module-linesi�z$Maximum number of lines in a module.z
indent-stringz    �non_empty_stringz<string>zSString used as indentation unit. This is usually "    " (4 spaces) or "\t" (1 tab).zindent-after-parenr`zGNumber of spaces of indent required inside a hanging or continued line.zexpected-line-ending-format�choicez<empty or LF or CRLF>�)rs�LF�CRLFzIExpected format of line ending, e.g. empty (any line ending), LF or CRLF.)rFrmrl�choicesrn�linterrr!rNc�f��t���|��i|_i|_dSrP)�superrT�_lines�_visited_lines)rSrw�	__class__s  �rIrTzFormatChecker.__init__s0���
������ � � �&(���8:����rKr<r=r>�
line_startc�~�t||d��r*|�d|�|�����|�|��}|�|��}|�|��t
vr#|�d��d|j|<|�||||��dS)z9A new line has been encountered, process it if necessary.�;r*�ra�
rN)	rJ�add_messager[rarF�_JUNK_TOKENS�splitrz�check_lines)rSr<r>r}�line_numras      rI�new_linezFormatChecker.new_lines���!�&�(�C�8�8�	X����4�6�;L�;L�X�;V�;V��W�W�W��$�$�Z�0�0���{�{�:�&�&���;�;�z�"�"�,�6�6�$(�J�J�t�$4�$4�Q�$7�D�K��!������T�8�<�<�<�<�<rK�node�nodes.Modulec��dSrPrg)rSr�s  rI�process_modulezFormatChecker.process_modules���rKrM�startc��||dzjdkrdS||jdkr|dkr||dz
jdkrdSd}d}d}d}d}t||j��}||jd}	t|t	|��dz
��D�]�}
||
}|jtjkrdS|jdks|j||
dzjzdkrd	}|}|jdkr|dz
}||
dzjdkrd}�u|jd
kr�|dz}|r$|r||
dzjd
kr|dvr��dS|dz}��||
dzjdvs3||
dzjtjtj	tj
hvr@|r|dz
|krdS|
|d
zkrdS|rdS|dkrdS|�d|	|���dS|dkr~|ddkrdS|ddvrd	}��V|ddkrdS|ddkrdS|ddkr7dd�||
d�D��vr|�||
d�d��dS���dS)aNCheck that there are not unnecessary parentheses after a keyword.

        Parens are unnecessary if there is exactly one balanced outer pair on a
        line and contains no commas (i.e. is not a tuple).

        Args:
        tokens: The entire list of Tokens.
        start: The position of the keyword in the token list.
        rD�(Nrr�isFr#T�)>rrr>�}rr��:�]rErr-�ra�args�,>�or�andrr�elsec3�$K�|]}|jV��dSrP)�string)�.0�is  rI�	<genexpr>z;FormatChecker._check_keyword_parentheses.<locals>.<genexpr>zs$����<�<�A�q�x�<�<�<�<�<�<rK)
r�rAr��range�lenrFrG�NL�NEWLINE�	ENDMARKERrHr��_check_keyword_parentheses)rSr<r��found_and_or�contains_walrus_operator�walrus_operator_depth�contains_double_parens�depth�
keyword_tokenr�r�r@s            rIr�z(FormatChecker._check_keyword_parenthesessD���%�!�)��#�s�*�*��F��5�M� �E�)�)���	�	��u�q�y�!�(�D�0�0�
�F���#(� � !��!"�����F�5�M�0�1�1�
��%�=�&�q�)���u�c�&�k�k�A�o�.�.�G	�G	�A��1�I�E��z�X�[�(�(�������$�$��<�&��Q��-�"6�6�$�>�>�+/�(�(-�%��|�s�"�"���
���!�a�%�=�'�3�.�.�-.�*�����$�$���
����-��&��Q��-�2F�#�2M�2M�(�,?�?�?�$����*�a�/�*���!�a�%�=�'�+E�E�E����E�J��8�+�X�-?��AQ�R�JS�JS�0��4I�A�4M�QV�4V�4V�����E�A�I�~�~����#�����$��,�,�����$�$�,�8�-�%��������!�����8�s�?�?��F�F���8�}�,�,�#'�L�L��1�X��(�(��F�F�
�1�X��&�&��F�F��1�X��'�'��<�<������<�<�<�<�<��7�7��q�r�r�
�A�F�F�F��F�F��OG	�G	rKc���dg}d}d}i�_i�_d�_d}t|��D�]�\}\}}}	}
}|	d|krj|	d}|tjkr+��t|��|dz
|dz��n'��t|��|dz
|��|tjkrd}��	||��n�|tjkrAd}��
||ddz|��|�|ddz��n�|tjkrd}t|��dkr|d=nc|tjkr|�d��s|}n;|tjtjfvr!|rd}��
||d|��|tjkr,|�d��r��d	|�
��|t*vr��||�����|dz}|�jjjkr��jj�d��d}|jdf}
t;t=d�fd�|
D����d��}��d|�jjjf|�
��||kr|dkr��d|�
��dSdSdS)z�Process tokens and search for:

        - too long lines (i.e. longer than <max_chars>)
        - optionally bad construct (if given, bad_construct must be a compiled
          regular expression).
        rFNrDT����
�lzlowercase-l-suffixr�r%c3�V�K�|]#}�jj�|��V��$dSrP)rw�_pragma_lineno�get)r��namerSs  �rIr�z/FormatChecker.process_tokens.<locals>.<genexpr>�s6�����U�U�t�d�k�8�<�<�T�B�B�U�U�U�U�U�UrK�r�rar()rzr{�_last_line_ending�	enumeraterG�INDENTr�r=r��_check_line_ending�check_indent_level�append�DEDENTr�r��striprH�ENCODING�NUMBER�endswithr��_KEYWORD_TOKENSr�rw�config�max_module_lines�
msgs_store�get_message_definitions�msgid�next�filter)rSr<�indents�check_equalr��last_blank_line_numrU�tok_typer�r��_ra�message_definition�names�linenos`              rI�process_tokenszFormatChecker.process_tokens~s9����#��������� ���-1�����7@��7H�7H�1	=�1	=�3�C�3�(�F�E�1�d��Q�x�8�#�#� ��8���x��.�.��M�M�,�v�"6�"6��a���q��I�I�I�I��M�M�,�v�"6�"6��a���E�E�E��8�+�+�+�#���'�'���9�9�9�9��X�_�,�,�#���'�'�����a���J�J�J����w�r�{�Q��/�/�/�/��X�_�,�,�
#���w�<�<�!�#�#������X�[�(�(��z�z�&�)�)�3�*2�'���(�"2�H�4E�!F�F�F��I�"'�K��+�+�D�'�"�+�x�H�H�H��8�?�*�*�v���s�/C�/C�*�� � �!5�H� �E�E�E���(�(��/�/���<�<�<���A�
���d�k�(�9�9�9�"&��!7�!O�!O� �"�"��"��(�-�/?�@�E���t�U�U�U�U�u�U�U�U�V�V����F�
��� ���� 2� C�D��
�
�
�
��*�*�*�x�!�|�|����0�x��@�@�@�@�@�+�*�|�|rK�line_endingrAr�c��|j�$|r"||jkr|�d|���||_|jjj}|r>td�|d��}|dkrdnd}||kr|�d||f|�	��dSdSdS)
Nr.r�c��||kr||zn|SrPrg)�x�ys  rI�<lambda>z2FormatChecker._check_line_ending.<locals>.<lambda>�s��q�A�v�v�a�!�e�e�1�rKrsr�rtrur/r�)r�r�rwr��expected_line_ending_formatr)rSr�r��expecteds    rIr�z FormatChecker._check_line_ending�s����!�-��
F�{�d�.D�D�D�� � �!5�H� �E�E�E�!,����;�%�A���		� �!D�!D�k�SU�V�V�K�"-��"5�"5�$�$�6�K��h�&�&�� � �3�%�x�0�!�!������		�		�'�&rKr+�nodes.NodeNGc��|jsdS|���jsdS|���}|�|j}n�t|jtj��r)||jj	vr|jj
djdz}nBt|jtj��rd}n |j�
d���j}|j}|s
J|���||kr6|j�|��dkr|�||��dS||jvrdS	|j}n#t$$r
|j}YnwxYw|s
J|���g}t'||dz��D]d}d|j|<	|�|j|������@#t.$r|�d��Y�awxYwdS)z8Check the node line number and check it if not yet done.NrrDT)�futurerErs)�is_statement�root�pure_python�previous_sibling�
fromlineno�
isinstance�parentr�
TryFinally�	finalbody�body�tolineno�Module�	statementr{r��_check_multi_statement_line�blockstart_tolineno�AttributeErrorr�r�rz�rstrip�KeyError)rSr��	prev_sibl�	prev_linerar��liness       rI�
visit_defaultzFormatChecker.visit_default�s��� �	��F��y�y�{�{�&�	��F��)�)�+�+�	�� �!�,�I�I�
�t�{�E�$4�5�5�	F�:>�$�+�BW�:W�:W���(��+�4�q�8�I�I�
���U�\�
2�
2�	F��I�I���-�-�T�-�:�:�E�I�������T���t������!4�!8�!8��!>�!>�!�!C�!C��,�,�T�4�8�8�8��F��4�&�&�&��F�	%��/�H�H���	%�	%�	%��}�H�H�H�	%����������x����$��1��-�-�	!�	!�D�()�D���%�
!����T�[��.�5�5�7�7�8�8�8�8���
!�
!�
!����R� � � � � �
!����		!�	!s$�(D0�0E�E�52F(�(G
�	G
rac���t|tj��rdSt|tj��r!t|jtj��rdSt|jtj��r|jjs|jj	j
rdSt|jtj��r0t|jj
��dkr|jj	jrdSt|jtj��rNt|tj��r4t|jtj��r|jjt&urdS|�d|���d|j|<dS)z/Check for lines containing multiple statements.NrDr+)r�rE)r�r�With�	TryExceptr�r��If�orelserwr��single_line_if_stmt�ClassDefr�r��single_line_class_stmt�FunctionDef�Expr�value�Const�Ellipsisr�r{)rSr�ras   rIr�z)FormatChecker._check_multi_statement_lines_���d�E�J�'�'�	��F��d�E�O�,�,�	���K��)�2
�2
�	�
�F��t�{�E�H�-�-�	��K�&�	���"�6�	�

�F��t�{�E�N�3�3�	��D�K�$�%�%��*�*���"�9�+�
�F�
�t�{�E�$5�6�6�	��4���,�,�	��4�:�u�{�3�3�	��
� �H�,�,��F����.�T��:�:�:�$%���D�!�!�!rKr�c��|�d��}|t|��d�dvr-|�d|t|��t���dSdS)z,Check that there is no trailing white-space.z	

 N)r�r�r&)ra�
col_offset�
confidence)r�r�r�r)rSrar��
stripped_lines    rI� check_trailing_whitespace_endingz.FormatChecker.check_trailing_whitespace_ending=sv�����K�0�0�
���M�"�"�$�$�%�^�;�;����%���}�-�-��	
�
�
�
�
�
�<�;rK�checker_offrBc�V�|jjj}|jjj}|���}t|��|kr]|�|��sJ|r|j�d|��dS|�d|t|��|f���dSdSdS)z=Check that the line length is less than the authorized value.r$r�N)	rwr��max_line_length�ignore_long_linesr�r��search�add_ignored_messager�)rSrar�r�	max_chars�ignore_long_lines      rI�check_line_lengthzFormatChecker.check_line_lengthIs����K�&�6�	��;�-�?���{�{�}�}���t�9�9�y� � �)9�)@�)@��)F�)F� ��
W���/�/���C�C�C�C�C�� � ��q��D�	�	�9�?U� �V�V�V�V�V�	!� � � rK�options_pattern_obj�
Match[str]c��|j}|d|�d������||�d��d�z}|S)z-Remove the `# pylint ...` pattern from lines.NrD)r�r�r��end)rr��purged_liness   rI�remove_pylint_option_from_linesz-FormatChecker.remove_pylint_option_from_linesTsd��$�*���0�'�-�-�a�0�0�0�1�8�8�:�:��'�+�+�A�.�.�0�0�1�
2�	��rK�pylint_pattern_match_objectc��	t|�d����D]}|jdkrd|jvrdS�n#t$rYnwxYwdS)z2Return True if the line length check is activated.rE�disabler$FT)r�group�action�messagesr)r�pragmas  rI�is_line_length_check_activatedz,FormatChecker.is_line_length_check_activated^s|��	�&�'B�'H�'H��'K�'K�L�L�
!�
!���=�I�-�-�/�V�_�2T�2T� �5�5��
!��!�	�	�	��D�	�����ts�9?�?�
A�Ar��	list[str]c��hd�}g}d}|�d��D],}|d|vr|�||z��d}�'||z
}�-|S)z]Split lines according to universal newlines except those in a specific
        sets.
        >�
�
�…�����rsTr�)�
splitlinesr�)r��unsplit_ends�res�buffer�atomic_lines     rI�specific_splitlinesz!FormatChecker.specific_splitlinesjsz��
	
�	
�	
������ �+�+�D�1�1�	&�	&�K��2��l�2�2��
�
�6�K�/�0�0�0�����+�%����
rKr�c���|jjj�|�|��}t	|��D]q\}}|�d��s|�d||z����5|�|��tj	kr|�
|||z���rt�fd�|D����}|sdStj
|��}	d}
|	r,|�|	��sd}
|�|	��}t	|�|����D]\}}|�|||z|
��� dS)z�Check given lines for potential messages.

        Check if lines have:
        - a final newline
        - no trailing white-space
        - less than a maximum number of characters
        r�r'r�c3�>�K�|]}t|���kV��dSrP)r�)r�rar	s  �rIr�z,FormatChecker.check_lines.<locals>.<genexpr>�s?�����,
�,
�&*�C��I�I�	�!�,
�,
�,
�,
�,
�,
rKNFT)rwr�rr)r�r�r�rFrG�STRINGr�anyrrrrr)rSr<r}r�r��split_lines�offsetra�potential_line_length_warning�mobjrr	s           @rIr�zFormatChecker.check_lines�s����$�K�&�6�	��.�.�u�5�5��%�k�2�2�	M�	M�L�F�D��=�=��&�&�
�� � �!8�v��� �O�O�O���{�{�:�&�&�(�/�9�9��5�5�d�F�V�O�L�L�L��),�,
�,
�,
�,
�.9�,
�,
�,
�)
�)
�%�-�	��F����&�&�����	?��6�6�t�<�<�
#�"���8�8��>�>�E�&�d�&>�&>�u�&E�&E�F�F�	G�	G�L�F�D��"�"�4��&��+�F�F�F�F�	G�	GrKr�r�c��|jjj}|dkrd}d}t|��}|d|�|kr||d�}|dz
}|d|�|k�d}|r+|ddvr!||dz
}|dd�}|r
|ddv�!||ks|rCd}|ddkrd	}|�d
|||zt|��z|||zf���dSdS)z&Return the indent level of the string.z\t�	rNrDrsz 	�spaces�tabsr)r�)rwr��
indent_stringr�r�)	rSr�r�r��indent�level�	unit_size�suppl�i_types	         rIr�z FormatChecker.check_indent_level�s=����#�1���U�?�?��F�����K�K�	��Z�i�Z� �F�*�*��I�J�J�'�F��Q�J�E��Z�i�Z� �F�*�*����	 ����e�+�+��V�A�Y��E��A�B�B�Z�F��	 ����e�+�+��H������F��a�y�D� � ������!���i�'�#�e�*�*�4�f�h��>R�S�
�
�
�
�
�
�	�rK�rwrr!rN)r<r=r>r?r}r?r!rN)r�r�r!rN)r<rMr�r?r!rNrb)r�rAr�r?r!rN)r�r�r!rN)r�r�rar?r!rN)rarAr�r?r!rN)rarAr�r?rrBr!rN)rr
r!rA)rr
r!rB)r�rAr!r)
r<r=r}r?r�rAr�r?r!rN)r�rAr�r?r�r?r!rN)rcrdrerfr�r;�msgs�optionsrTr�r�r�r�r�r
r�r�rr�staticmethodrrr)r�r��
__classcell__)r|s@rIriri�s�����������D��D�

���"�H�	
�
�	
�
 � �%�8�T�
�
�
	
�
"� ��%�<�
�
�	
�
%� ��%�(�	
�	
�	
�
���"�>�	
�
�	
�
�!�*�%�6�	
�
�		
�
!��"��%�	
�
�		
�
*� �2��-�-�-�@�
	
�	
�	
�WX�G�t;�;�;�;�;�;�
	=�	=�	=�	=�
�
�
�
�e�e�e�e�NVA�VA�VA�VA�p����0 �� 5�6�6�'!�'!�'!�7�6�'!�R#&�#&�#&�#&�J
�
�
�
�	W�	W�	W�	W������\���	�	�	��\�	������\��06G�6G�6G�6G�p�������rKrirwrrNc�J�|�t|����dSrP)�register_checkerri)rws rI�registerrC�s$��
���M�&�1�1�2�2�2�2�2rK)r<r=r>r?r@rAr!rBr<),rf�
__future__r�sysrG�	functoolsr�rer�typingr�astroidr�pylint.checkersrr	�pylint.checkers.utilsr
�pylint.constantsr�pylint.interfacesr�
pylint.typingr
�pylint.utils.pragma_parserrrr�pylint.lintr�version_infor�typing_extensionsr�rHr�r��NODEr;�__annotations__rJr=rirCrgrKrI�<module>rUsq��
���#�"�"�"�"�"�
�
�
�
����������������� � � � � � �������@�@�@�@�@�@�@�@�<�<�<�<�<�<�)�)�)�)�)�)�"�"�"�"�"�"�0�0�0�0�0�0�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q��%�$�$�$�$�$�$���v����������)�)�)�)�)�)�����"� �(�+�.���
�
�
�
�
��	3��F�	�,�#�$�	���
�o<+�<+��<�<�<�<�~����$�$�$�$�$�$�$�$�,w�w�w�w�w�$�&8�w�w�w�t3�3�3�3�3�3rK

Hacked By AnonymousFox1.0, Coded By AnonymousFox