Your IP : 3.12.165.68


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/flake8/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/flake8/__pycache__/style_guide.cpython-311.pyc

�

��bgi=���dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
ddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZdZeje��ZGd�dej��ZGd�dej��Z Gd�dej��Z!deee"deee"dee"dffd�Z#deee"dee"dfdee"deee"dee"dff
d�Z$Gd�d ��Z%Gd!�d"��Z&Gd#�d$��Z'dS)%z0Implementation of the StyleGuide used by Flake8.�N)�Dict)�	Generator)�List)�Optional)�Sequence)�Set)�Tuple)�Union)�defaults)�
statistics)�utils)�base)�	Violation)�
StyleGuidec��eZdZdZdZdZdS)�Selectedz<Enum representing an explicitly or implicitly selected code.zexplicitly selectedzimplicitly selectedN��__name__�
__module__�__qualname__�__doc__�
Explicitly�
Implicitly���c/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/flake8/style_guide.pyrrs������F�F�&�J�&�J�J�Jrrc��eZdZdZdZdZdS)�Ignoredz;Enum representing an explicitly or implicitly ignored code.zexplicitly ignoredzimplicitly ignoredNrrrrrr$s������E�E�%�J�%�J�J�Jrrc��eZdZdZdZdZdS)�Decisionz?Enum representing whether a code should be ignored or selected.z
ignored errorzselected errorN)rrrrrrrrrr r +s������I�I��G��H�H�Hrr �option�extend�return.c�R�g|pg�|pg�}tt|d�����S�NT)�reverse��tuple�sorted)r!r"�rets   r�_explicitly_chosenr+2s6��
-�V�\�r�
,�f�l��
,�C����T�*�*�*�+�+�+r�default�extended_defaultc�h�|�	g|�|pg�}n
g|�|�|pg�}tt|d�����Sr%r')r!r,r-r"r*s     r�_select_ignorer/;sS����(��(�&�,�B�(���<��<�*�<�f�l��<�����T�*�*�*�+�+�+rc��eZdZdZdejddfd�Zdedee	e
ffd�Zdedee	e
ffd�Zdede
fd	�Zdede
fd
�ZdS)�DecisionEnginez�A class for managing the decision process around violations.

    This contains the logic for whether a violation should be reported or
    ignored.
    �optionsr#Nc�X�i|_t|j|j���|_t|j|j���|_t|jtj
|j|j���|_t|jtj
|j|j���|_dS)zInitialize the engine.)r!r")r!r,r-r"N)�cacher+�select�
extend_select�selected_explicitly�ignore�
extend_ignore�ignored_explicitlyr/r�SELECT�extended_default_select�selected�IGNORE�extended_default_ignore�ignored)�selfr2s  r�__init__zDecisionEngine.__init__Qs���*,��
�#5��>��(�$
�$
�$
�� �#5��>��(�#
�#
�#
���
'��>��O�$�<��(�	
�
�
��
�&��>��O�$�<��(�	
�
�
����r�codec��|�|j��rtjS|�|j��rtjStjS)a�Determine if the code has been selected by the user.

        :param code: The code for the check that has been run.
        :returns:
            Selected.Implicitly if the selected list is empty,
            Selected.Explicitly if the selected list is not empty and a match
            was found,
            Ignored.Implicitly if the selected list is not empty but no match
            was found.
        )�
startswithr7rrr=rr�rArCs  r�was_selectedzDecisionEngine.was_selectedksL���?�?�4�3�4�4�	&��&�&�
�_�_�T�]�
+�
+�	&��&�&��%�%rc��|�|j��rtjS|�|j��rtjStjS)a�Determine if the code has been ignored by the user.

        :param code:
            The code for the check that has been run.
        :returns:
            Selected.Implicitly if the ignored list is empty,
            Ignored.Explicitly if the ignored list is not empty and a match was
            found,
            Selected.Implicitly if the ignored list is not empty but no match
            was found.
        )rEr:rrr@rrrFs  r�was_ignoredzDecisionEngine.was_ignored}sL���?�?�4�2�3�3�	'��%�%�
�_�_�T�\�
*�
*�	'��%�%��&�&rc����|����}|����}t�d�||��t	|t
��r!t	|t
��rtjSt	|t��r!t	|t��rtjS|t
jur|tjurtjS|t
jur|tjurtjS|tj	ur|t
j	urtjS|t
jur|tjus|t
j	ur�|tj	urxt�fd�|jD����}t�fd�|jD����}t|��t|��krtjStjStd��d|�d|�����)z-Decide if code should be ignored or selected.z#The user configured %r to be %r, %rc3�F�K�|]}��|���|V��dS�N�rE��.0�srCs  �r�	<genexpr>z/DecisionEngine.make_decision.<locals>.<genexpr>�s4�����I�I��d�o�o�a�6H�6H�I�!�I�I�I�I�I�Irc3�F�K�|]}��|���|V��dSrLrMrNs  �rrQz/DecisionEngine.make_decision.<locals>.<genexpr>�s4�����H�H��T�_�_�Q�5G�5G�H�!�H�H�H�H�H�Hrzunreachable � )rGrI�LOG�debug�
isinstancerr rrr�nextr=r@�len�AssertionError)rArCr=r@r5r8s `    r�
make_decisionzDecisionEngine.make_decision�s�����$�$�T�*�*���"�"�4�(�(���	�	�1����		
�	
�	
��h��)�)�	M�j��(�.K�.K�	M��$�$�
��'�
*�
*�	M�z�'�7�/K�/K�	M��#�#���+�+�+��w�1�1�1��$�$��H�/�/�/��7�-�-�-��#�#�
��+�
+�
+��8�;N�0N�0N��#�#���+�+�+��7�;M�0M�0M���+�+�+��7�;M�0M�0M��I�I�I�I�T�]�I�I�I�I�I�F��H�H�H�H�T�\�H�H�H�H�H�F��6�{�{�S��[�[�(�(��(�(��'�'� �!K��!K�!K�x�!K�!K�'�!K�!K�L�L�Lrc��|j�|��}|�;|�|��}||j|<t�d||��|S)a�Return the decision for a specific code.

        This method caches the decisions for codes to avoid retracing the same
        logic over and over again. We only care about the select and ignore
        rules as specified by the user in their configuration files and
        command-line flags.

        This method does not look at whether the specific line is being
        ignored in the file itself.

        :param code: The code for the check that has been run.
        Nz"%s" will be "%s")r4�getrZrTrU)rArC�decisions   r�decision_forzDecisionEngine.decision_for�sX���:�>�>�$�'�'�����)�)�$�/�/�H�'�D�J�t���I�I�)�4��:�:�:��r)rrrr�argparse�	NamespacerB�strr
rrrGrIr rZr^rrrr1r1Js���������
�� 2�
�t�
�
�
�
�4&��&��x��/@�)A�&�&�&�&�$'��'��h��.?�(@�'�'�'�'�&(M�#�(M�(�(M�(M�(M�(M�T���������rr1c��eZdZdZ	ddejdejdee	ddfd�Z
dejdedfd	�Zd
e
ddfd�Zejd
e
dedfd
���Z	dde
d
e
dedede
dee
defd�Zdee
eefddfd�ZdS)�StyleGuideManagerz.Manage multiple style guides for a single run.Nr2�	formatter�deciderr#c��||_||_tj��|_|pt|��|_g|_t|||j|���|_	ttj|j	g|�
|������|_tjd���|j��|_dS)�SInitialize our StyleGuide.

        .. todo:: Add parameter documentation.
        )reN)�maxsize)r2rdr�
Statistics�statsr1re�style_guidesr�default_style_guide�list�	itertools�chain�populate_style_guides_with�	functools�	lru_cache�_style_guide_for�style_guide_for)rAr2rdres    rrBzStyleGuideManager.__init__�s������"����*�,�,��
��9�.��"9�"9���.0���#-��Y��
�G�$
�$
�$
�� �!��O��)�*��/�/��8�8�
�
�
�
��� A�y�2�4�@�@�@��!� 
� 
����r�rNNc#�K�tj|j��}|D]#\}}|j�||���V��$dS)z�Generate style guides from the per-file-ignores option.

        :param options:
            The original options parsed from the CLI and config file.
        :returns:
            A copy of the default style guide with overridden values.
        )�filename�extend_ignore_withN)r
�parse_files_to_codes_mapping�per_file_ignoresrl�copy)rAr2�per_filerw�
violationss     rrpz,StyleGuideManager.populate_style_guides_with�sm�����5�g�6N�O�O��$,�	�	� �H�j��*�/�/�!�j�0���
�
�
�
�	�	rrwrc�J��t�fd�|jD��d����S)z3Find the StyleGuide for the filename in particular.c3�F�K�|]}|�����|V��dSrL)�
applies_to)rO�grws  �rrQz5StyleGuideManager._style_guide_for.<locals>.<genexpr>s4�����D�D�1�Q�\�\�(�-C�-C�D�Q�D�D�D�D�D�Drc�.�t|jpd��S)N�)rXrw)r�s r�<lambda>z4StyleGuideManager._style_guide_for.<locals>.<lambda>s��#�a�j�.�B�/�/�r)�key)�maxrk�rArws `rrsz"StyleGuideManager._style_guide_for�s:����D�D�D�D��)�D�D�D�/�/�
�
�
�	
rc#�K�|�|��}|�|��5|V�ddd��dS#1swxYwYdS�z9Record the fact that we're processing the file's results.N)rt�processing_file)rArw�guides   rr�z!StyleGuideManager.processing_files�����
�$�$�X�.�.��
�
"�
"�8�
,�
,�	�	��K�K�K�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�?�A�ArC�line_number�
column_number�text�
physical_linec�`�|�|��}|�||||||��S)�Handle an error reported by a check.

        :param code:
            The error code found, e.g., E123.
        :param filename:
            The file in which the error was found.
        :param line_number:
            The line number (where counting starts at 1) at which the error
            occurs.
        :param column_number:
            The column number (where counting starts at 1) at which the error
            occurs.
        :param text:
            The text of the error message.
        :param physical_line:
            The actual physical line causing the error.
        :returns:
            1 if the error was reported. 0 if it was ignored. This is to allow
            for counting of the number of errors found that were not ignored.
        )rt�handle_error)rArCrwr�r�r�r�r�s        rr�zStyleGuideManager.handle_errors<��:�$�$�X�.�.���!�!��(�K���m�
�
�	
r�diffinfoc�D�|jD]}|�|���dS)a5Update the StyleGuides to filter out information not in the diff.

        This provides information to the underlying StyleGuides so that only
        the errors in the line number ranges are reported.

        :param diffinfo:
            Dictionary mapping filenames to sets of line number ranges.
        N)rk�add_diff_ranges)rAr�r�s   rr�z!StyleGuideManager.add_diff_ranges1s7���&�	,�	,�E��!�!�(�+�+�+�+�	,�	,rrL)rrrrr_r`�base_formatter�
BaseFormatterrr1rBrrprars�
contextlib�contextmanagerr��intr�rrr�rrrrcrc�s�������8�8�-1�	
�
��#�
�"�/�
��.�)�	
�

�
�
�
�
�:��)��	�+�	,����� 
��
��
�
�
�
������	�+�	,�������(,� 
� 
�� 
�� 
��	 
�
� 
��
 
� ��}� 
�

� 
� 
� 
� 
�D
,��S�#�c�(�]�(;�
,��
,�
,�
,�
,�
,�
,rrcc�j�eZdZdZ		ddejdejdej	de
ede
ef
d�Z
d	efd
�Z		dde
ede
eed	dfd�Zejded	ed
fd���Zded	efd�Zded	efd�Z	ddededededede
ed	efd�Zdeeeefd	dfd�ZdS)rz#Manage a Flake8 user's style guide.Nr2rdrjrwrec���||_||_||_|pt|��|_||_|jrt
j|j��|_i|_dS)rgN)	r2rdrjr1rerwr
�normalize_path�_parsed_diff)rAr2rdrjrwres      rrBzStyleGuide.__init__Asa�����"�����
��9�.��"9�"9��� ��
��=�	@�!�0���?�?�D�M�13����rr#c��d|j�d�S)z5Make it easier to debug which StyleGuide we're using.z
<StyleGuide [z]>�rw)rAs r�__repr__zStyleGuide.__repr__Vs��0�t�}�0�0�0�0rrxc���|p|j}tj|j��}|jpg|_|j�|pg��t
||j|j|���S)z8Create a copy of this style guide with different values.r�)	rwr{�deepcopyr2r9r"rrdrj)rArwrxr2s    rr{zStyleGuide.copyZsr���,�t�}���-���-�-�� '� 5� ;������$�$�%7�%=�2�>�>�>���T�^�T�Z�(�
�
�
�	
rruc#�zK�|j�|��|V�|j�|��dSr�)rd�	beginning�finishedr�s  rr�zStyleGuide.processing_filehsC����
	
�� � ��*�*�*��
�
�
������)�)�)�)�)rc�`�|j�dStj||jg|�d�t���S)aCheck if this StyleGuide applies to the file.

        :param filename:
            The name of the file with violations that we're potentially
            applying this StyleGuide to.
        :returns:
            True if this applies, False otherwise
        NTz! does %(whether)smatch "%(path)s")�patterns�log_message�logger)rwr
�matches_filenamerTr�s  rr�zStyleGuide.applies_toqsD���=� ��4��%���m�_��D�D�D��	
�
�
�	
rrCc�6�|j�|��S)a�Determine if the error code should be reported or ignored.

        This method only cares about the select and ignore rules as specified
        by the user in their configuration files and command-line flags.

        This method does not look at whether the specific line is being
        ignored in the file itself.

        :param code:
            The code for the check that has been run.
        )rer^rFs  r�should_report_errorzStyleGuide.should_report_error�s���|�(�(��.�.�.rr�r�r�r�c�z�|jj}|sd}t||||dz||��}|�|j��t
ju}	|�|��du}
|�|j	��}|	r:|
r8|r6|j
�|��|j�
|��dSdS)r�r�F)r2�disable_noqarr�rCr r�is_inline_ignored�is_inr�rd�handlerj�record)rArCrwr�r�r�r�r��error�error_is_selected�is_not_inline_ignored�is_included_in_diffs            rr�zStyleGuide.handle_error�s���:�|�0���	��M������A����

�
��
�$�$�U�Z�0�0�H�4E�E�	�!&� 7� 7�� E� E�� N��#�k�k�$�*;�<�<���	�!6�	�;N�	��N�!�!�%�(�(�(��J���e�$�$�$��1��qrr�c��||_dS)a(Update the StyleGuide to filter out information not in the diff.

        This provides information to the StyleGuide so that only the errors
        in the line number ranges are reported.

        :param diffinfo:
            Dictionary mapping filenames to sets of line number ranges.
        N)r�)rAr�s  rr�zStyleGuide.add_diff_ranges�s��%����r)NNrL)rrrrr_r`r�r�rrirrar1rBr�rr{r�r�rr��boolr�r r�r�r�rrr�rrrrr>s�������-�-�#'�,0�
4�4��#�4�"�/�4��$�	4�
�3�-�4��.�)�
4�4�4�4�*1�#�1�1�1�1�#'�6:�
�
��3�-�
�%�X�c�]�3�
�
�	
�
�
�
���*��*�	�+�	,�*�*�*���*�
�3�
�4�
�
�
�
�$/��/��/�/�/�/�*(,�3�3��3��3��	3�
�3��
3� ��}�3�

�3�3�3�3�j	%��S�#�c�(�]�(;�	%��	%�	%�	%�	%�	%�	%rr)(rr_r�r{�enumrqrn�logging�typingrrrrrrr	r
�flake8rrr
�flake8.formattingrr��flake8.violationr�__all__�	getLoggerrrT�Enumrrr rar+r/r1rcrrrr�<module>r�s*��6�6�����������������������������������������������������������������������������������������������4�4�4�4�4�4�&�&�&�&�&�&�
���g���!�!��'�'�'�'�'�t�y�'�'�'�&�&�&�&�&�d�i�&�&�&� � � � � �t�y� � � �,��T�#�Y��,�
�T�#�Y��,��3��8�_�	,�,�,�,�,��T�#�Y��,��3��8�_�,��3�i�	,�

�T�#�Y��,��3��8�_�
,�,�,�,�B�B�B�B�B�B�B�B�Jl,�l,�l,�l,�l,�l,�l,�l,�^Q%�Q%�Q%�Q%�Q%�Q%�Q%�Q%�Q%�Q%r

?>