AlkantarClanX12

Your IP : 18.222.164.176


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__/checker.cpython-311.pyc

�

�܋f�]�	�(�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
ddl
mZddl
mZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZe
eeeeeeefZeje ��Z!ej"hZ#Gd�d��Z$Gd�d��Z%d d�Z&dedeej'j(fd�Z)dededefd�Z*de%deeeeeefffd�Z+dedej,deeeffd�Z-dS)!z$Checker Manager and Checker classes.�N)�Any)�Dict)�List)�Optional)�Tuple)�defaults)�
exceptions)�	processor)�utils)�expand_paths)�Checkers)�LoadedPlugin)�StyleGuideManagerc���eZdZdZdededdfd�Zdd�Zdefd�Z	d	e
d
edefd�Zdde
ee
ddfd
�Zdeeeffd�Zdd�Zdd�Zdd�Zdde
ee
ddfd�Zdd�ZdS)�ManageraRManage the parallelism and checker instances for each plugin and file.

    This class will be responsible for the following:

    - Determining the parallelism of Flake8, e.g.:

      * Do we use :mod:`multiprocessing` or is it unavailable?

      * Do we automatically decide on the number of jobs to use or did the
        user provide that?

    - Falling back to a serial way of processing files if we run into an
      OSError related to :mod:`multiprocessing`

    - Organizing the results of each checker so we can group the output
      together and make our output deterministic.
    �style_guide�plugins�returnNc��||_|j|_||_|���|_g|_g|_ddddd�|_ttj
|jj|jj����|_dS)z Initialize our Manager instance.r)�files�
logical lines�physical lines�tokensN)
r�optionsr�
_job_count�jobs�
_all_checkers�checkers�
statistics�tuple�	itertools�chain�exclude�extend_exclude)�selfrrs   �_/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/flake8/checker.py�__init__zManager.__init__@s���'���"�*�������O�O�%�%��	�02���+-��
�����	
�
�����O�D�L�0�$�,�2M�N�N�
�
�����c���|jD]1}tjD]"}|j|xx|j|z
cc<�#�2|jdxxt	|j��z
cc<dS)Nr)rr�STATISTIC_NAMESr�len)r%�checker�	statistics   r&�_process_statisticszManager._process_statisticsVs����}�	L�	L�G�%�5�
L�
L�	���	�*�*�*�g�.@��.K�K�*�*�*�*�
L���� � � �C��
�$6�$6�6� � � � � r(c��tj��dkrt�d��dSt	j|jj��rt�d��dS|jjrt�d��dS|jj	}|j
r%	tj��S#t$rYdSwxYw|j
S)N�forkzGThe multiprocessing module is not available. Ignoring --jobs arguments.rz]The --jobs option is not compatible with supplying input using - . Ignoring --jobs arguments.zcThe --diff option was specified with --jobs but they are not compatible. Ignoring --jobs arguments.)�multiprocessing�get_start_method�LOG�warningr�is_using_stdinr�	filenames�diffr�is_auto�	cpu_count�NotImplementedError�n_jobs)r%rs  r&rzManager._job_count\s����+�-�-��7�7��K�K�-�
�
�
��1����� 6�7�7�	��K�K�=�
�
�
��1��<��	��K�K�F�
�
�
��1��|� ���<�	�
�&�0�2�2�2��&�
�
�
��q�q�
����
�{�s�*B=�=
C�
C�filename�resultsc
�j�|j}d}|D]&\}}}}}	||�||||||	���z
}�'|S)Nr)�coder<�line_number�
column_number�text�
physical_line)r�handle_error)
r%r<r=r�reported_results_count�
error_coder@�columnrBrCs
          r&�_handle_resultszManager._handle_results�si���&��!"��FM�	�	�B�Z��f�d�M�"�k�&>�&>��!�'�$��+�
'?�'�'�
�"�"�&�%r(�pathsc�:��|��jj}�fd�t|�jj�jj�j�jj���D���_d��jD���_t�
dt�j����dS)zCreate checkers for each file.Nc�H��g|]}t|�j�j�����S))r<rr)�FileCheckerrr)�.0r<r%s  �r&�
<listcomp>z)Manager.make_checkers.<locals>.<listcomp>�sG���

�

�

��
�!�����
�
�
�

�

�

r()rI�stdin_display_name�filename_patternsr#�is_running_from_diffc� �g|]}|j�	|��S�)�should_process)rM�cs  r&rNz)Manager.make_checkers.<locals>.<listcomp>�s ��K�K�K�q�!�:J�K��K�K�Kr(zChecking %d files)rr6rrOr<r#r7rrr3�infor+�r%rIs` r&�
make_checkerszManager.make_checkers�s�����=��L�*�E�

�

�

�

�)��#'�<�#B�"&�,�"7���%)�\�%6����


�

�

���L�K�D�$6�K�K�K��
����$�c�$�-�&8�&8�9�9�9�9�9r(c��dx}}|jD]}}t|jd����}|j}|j�|��5||�||��z
}ddd��n#1swxYwY|t|��z
}�~||fS)aReport all of the errors found in the managed file checkers.

        This iterates over each of the checkers and reports the errors sorted
        by line number.

        :returns:
            A tuple of the total results found and the results reported.
        rc�"�|d|dfS)N��rS)�tups r&�<lambda>z Manager.report.<locals>.<lambda>�s��s�1�v�s�1�v�>N�r()�keyN)r�sortedr=�display_namer�processing_filerHr+)r%�results_reported�
results_foundr,r=r<s      r&�reportzManager.report�s���,-�,��=��)�	*�	*�G��W�_�2N�2N�O�O�O�G��+�H��!�1�1�(�;�;�
L�
L� �D�$8�$8��7�$K�$K�K� �
L�
L�
L�
L�
L�
L�
L�
L�
L�
L�
L����
L�
L�
L�
L��S��\�\�)�M�M��/�0�0s�A,�,A0	�3A0	c	���tjt��}tjt��}t	|j��}|�|���dSd}	|�t|j	tt|j	��|j�����}|D]}|\}}}	|||<|	||<�|���|�
��d}|s(|���|�
��n0#|s)|���|�
��wwxYw|j	D]#}
|
j}|||
_|||
_�$dS)zRun the checkers in parallel.NF)�	chunksizeT)�collections�defaultdict�list�dict�_try_initialize_processpoolr�
run_serial�imap_unordered�_run_checksr�calculate_pool_chunksizer+�close�join�	terminaterar=r)r%�
final_results�final_statistics�pool�pool_closed�pool_map�retr<r=rr,s           r&�run_parallelzManager.run_parallel�s���T_�Sj�ko�Sp�Sp�
�6A�6M�d�6S�6S��+�4�9�5�5���<��O�O�����F���	��*�*���
�2���
�&�&��	���+���H� �
8�
8��03�-��'�:�*1�
�h�'�-7� ��*�*��J�J�L�L�L��I�I�K�K�K��K��
���� � � ��	�	�������
���� � � ��	�	�����
�����}�	<�	<�G��+�H�+�H�5�G�O�!1�(�!;�G���	<�	<s
�"BD�-Ec�B�|jD]}|����dS)zRun the checkers in serial.N)r�
run_checks)r%r,s  r&rmzManager.run_serial�s2���}�	!�	!�G���� � � � �	!�	!r(c��	|jdkr.t|j��dkr|���dS|���dS#t
$r/t�d��tj	d���wxYw)a#Run all the checkers.

        This will intelligently decide whether to run the checks in parallel
        or whether to run them in serial.

        If running the checks in parallel causes a problem (e.g.,
        :issue:`117`) this also implements fallback to serial processing.
        r[z"Flake8 was interrupted by the userzEarly quit while running checksN)
rr+rrzrm�KeyboardInterruptr3r4r	�	EarlyQuit�r%s r&�runzManager.run�s���	J��y�1�}�}��T�]�!3�!3�a�!7�!7��!�!�#�#�#�#�#����!�!�!�!�!�� �	J�	J�	J��K�K�<�=�=�=��&�'H�I�I�I�	J���s�7A�A�9B
c�d�t�d��|�|��dS)z�Start checking files.

        :param paths:
            Path names to check. This is passed directly to
            :meth:`~Manager.make_checkers`.
        zMaking checkersN)r3rVrXrWs  r&�startz
Manager.starts1��	���"�#�#�#����5�!�!�!�!�!r(c�.�|���dS)zStop checking files.N)r.r�s r&�stopzManager.stops��� � �"�"�"�"�"r(�rN�N)�__name__�
__module__�__qualname__�__doc__rr
r'r.�intr�str�ResultsrHrrrXrrerzrmr�r�r�rSr(r&rr-s��������$
�&�
��
�
�	
�
�
�
�,7�7�7�7�/�C�/�/�/�/�b&��&�g�&�#�&�&�&�&�:�:�8�D��I�#6�:�$�:�:�:�:�,1��c�3�h��1�1�1�1�$%<�%<�%<�%<�N!�!�!�!�
J�J�J�J�$"�"�8�D��I�.�"�$�"�"�"�"�#�#�#�#�#�#r(rc
�R�eZdZdZdededejddfd�Zdefd�Z	de
ejfd	�Z
d
e
ededed
edef
d�Zdededefd�Zededeeeffd���Zdd�Zdd�Zdeddfd�Zdd�Zdeeeeeefffd�Zdeddfd�Zdej deddfd�Z!dS) rLz;Manage running checks for a file and aggregate the results.r<rrrNc�V�||_||_||_g|_dddd�|_|���|_||_d|_|j�S|jj|_|j�	��|_t|jj��|jd<dSdS)zInitialize our file checker.r)rrrFNr)rr<rr=r�_make_processorr
rarT�should_ignore_filer+�lines)r%r<rrs    r&r'zFileChecker.__init__s������ ��
���� "������
�
���
�-�-�/�/���$���#����>�%� $�� 7�D��&*�n�&G�&G�&I�&I�"I�D��03�D�N�4H�0I�0I�D�O�,�-�-�-�&�%r(c��d|j��S)z)Provide helpful debugging representation.zFileChecker for )r<r�s r&�__repr__zFileChecker.__repr__,s��1�$�-�1�1�1r(c	���	tj|j|j��S#t$r:}|�dddt
|��j�d|����Yd}~dSd}~wwxYw)N�E902r�: )r
�
FileProcessorr<r�OSErrorre�typer�)r%�es  r&r�zFileChecker._make_processor0s{��
	��*�4�=�$�,�G�G�G���	�	�	�
�K�K���1��a���)9�&@�&@�Q�&@�&@�A�A�A��4�4�4�4�4�����	���s�!�
A%�/A � A%rFr@rGrBc���|�|�dd��\}}t|d��r"|j�|j�|��}nd}|j�|||||f��|S)z2Report an error by storing it in the results list.N� r[r
)�split�hasattrr
�
noqa_line_forr=�append)r%rFr@rGrB�lines      r&rezFileChecker.report=s�����#�z�z�#�q�1�1��J���4��%�%�	�$�.�*D��>�/�/��<�<�D�D��D�����Z��f�d�D�I�J�J�J��r(�plugin�	argumentsc�|�|j�J�	|j�|j|��}n-#t$r }t	j|j|����d}~wwxYw	|jdi|�|��S#t$rH}t�
d|jd���t	j|j|j|����d}~wwxYw)z!Run the check in a single plugin.N)�plugin_name�	exceptionz(Plugin %s raised an unexpected exceptionT)�exc_info)r<r�r�rS)
r
�keyword_arguments_for�
parameters�AttributeErrorr	� PluginRequestedUnknownParametersra�obj�	Exceptionr3�critical�PluginExecutionFailedr<)r%r�r��params�ae�all_excs      r&�	run_checkzFileChecker.run_checkRs���~�)�)�)�	��^�9�9��!�9���F�F���	�	�	��=�"�/�2����
�����	����	��6�:�4�4�	�4�V�4�4�4���
	�
	�
	��L�L�:��#��
�
�
�
�
�2���"�/�!����
�����
	���s-� ,�
A�A�A�A)�)
B;�3AB6�6B;r�c���t|j��dkrF|jdr9t|jd��dkr|jd}|dd�\}}njt|tj��rIt|j��dkr1t|jd��dkrd}|jd\}}nd}d\}}|dkr�|r�t|t
��r�t|��dkrqd}d}|d}|�Y|�d���d��}t|��dz
}|d}t|��}	||	kr|	}||z}||z}||fS)	Nr[r\�rS)r[rr��
)r+�args�
isinstance�tokenize�
TokenError�SyntaxError�rstripr�)
r��token�rowrG�
column_offset�
row_offsetrCr��logical_line�logical_line_lengths
          r&�_extract_syntax_informationz'FileChecker._extract_syntax_informationks���
�	����!�#�#���q�!�
$��I�N�1�%�&�&��*�*��N�1�%�E���!��*�K�C����y�(�"5�6�6�		!��I�N�#�#�q�(�(��I�N�1�%�&�&�!�+�+��E�#�.��+�K�C����E� �K�C��
�Q�J�J��
��9�k�2�2�
��E�
�
�a���
�M��J�"�!�H�M�
�(�
&�,�,�T�2�2�8�8��>�>�� ��Z�Z�!�^�
�$�Q�x��&)�,�&7�&7�#��/�/�/�0�F��:��C��m�#�F��F�{�r(c�,�|j�J�|j���}|jjD]d}|�||���}	|���}n#t$r|}YnwxYw|D] \}}}}|�d|||����!�edS)z1Run all checks expecting an abstract syntax tree.N)�tree�rFr@rGrB)r
�	build_astrr�r�r�r�re)	r%�astr�r,�runnerr@�offsetrB�_s	         r&�run_ast_checkszFileChecker.run_ast_checks�s����~�)�)�)��n�&�&�(�(���l�'�	�	�F��n�n�V�#�n�6�6�G�
!� ��������!�
!�
!�
!� ����
!����28�
�
�.��f�d�A����#� +�!��	�����
�	�	s�	A�A-�,A-c�\�|j�J�|j���\}}}|sdS|j�|��t�d|�����|jjD]�}|j�|��|�	||���pd}|D]\\}}t||��\}}	||	cxkrdkrnnt�d|��|�d||	|����]��|j�
��dS)z(Run all checks expecting a logical line.NzLogical line: "%s")r�rSrz#position of error out of bounds: %sr�)r
�build_logical_line�update_stater3�debugr�rr��update_checker_state_forr��find_offsetr4re�next_logical_line)
r%�commentsr��mappingr�r=r�rBr@r�s
          r&�run_logical_checkszFileChecker.run_logical_checks�s]���~�)�)�)�*.�.�*K�*K�*M�*M�'��,���	��F���#�#�G�,�,�,��	�	�&��(;�(;�(=�(=�>�>�>��l�/�	�	�F��N�3�3�F�;�;�;��n�n�V�,�n�G�G�M�2�G� '�	
�	
����-8���-I�-I�*��]��-�4�4�4�4�1�4�4�4�4�4��K�K� E�v�N�N�N����#� +�(��	�����		
�	
��(�(�*�*�*�*�*r(rCc�l�|j�J�|jjD]�}|j�|��|�||���}|�hd}	|d}n#t
tf$rYnwxYwt|t��r|f}|D]*}|\}}|�	d|jj
||����+��dS)zoRun all checks for a given physical line.

        A single physical check may return multiple errors.
        N)rCrr�)r
rrCr�r��
IndexError�	TypeErrorr�r�rer@)r%rCr��resultr��
result_singlerBs       r&�run_physical_checkszFileChecker.run_physical_checks�s��
�~�)�)�)��l�0�	�	�F��N�3�3�F�;�;�;��^�^�F�-�^�H�H�F��!� $�
��$*�1�I�M�M��"�I�.�����D������m�S�1�1�'�$�Y�F�%+���M�*7�'�M�4��K�K�#'�$(�N�$>�,�!�	 ������%	�	s�A�A+�*A+c��|j�J�d}|j}|j}d}|���D]�}|dxxdz
cc<|�||��|dd�\}}|tjkrtj||��}n/|dkr)tj|��r|�|��|d}��|j	r6|�
|jd��|���dSdS)	z�Process tokens and trigger checks.

        Instead of using this directly, you should use
        :meth:`flake8.checker.FileChecker.run_checks`.
        Nr�rr[r\r����)
r
r�generate_tokens�check_physical_eolr��OP�count_parentheses�token_is_newline�handle_newlinerr�r�r�)r%�parensr�file_processor�
prev_physicalr��
token_typerBs        r&�process_tokenszFileChecker.process_tokens�s.���~�)�)�)����_�
�����
�#�3�3�5�5�		%�		%�E��x� � � �A�%� � � ��#�#�E�=�9�9�9�$�Q�q�S�z��J���X�[�(�(�"�4�V�T�B�B����1����-�e�4�4�4��'�'�
�3�3�3�!�!�H�M�M�� �	&��$�$�^�%9�"�%=�>�>�>��#�#�%�%�%�%�%�	&�	&r(c
��|j�J�	|���|���n�#ttjf$r�}t
|tj��rdnd}|�|��\}}|�|||t|��j
�d|jd����|j|j
|jfcYd}~Sd}~wwxYw|jjd}||jd<|j|j
|jfS)zRun checks against the file.Nr��E999r�rr)r
r�r�r�r�r�r�r�rer�r�r�r<r=r)r%r�r?r�rG�
logical_liness      r&r|zFileChecker.run_checkss!���~�)�)�)�	@����!�!�!����!�!�!�!���X�0�1�	@�	@�	@�'��8�+>�?�?�K�6�6�V�D��:�:�1�=�=�K�C���K�K��c�6�d�1�g�g�.>�+M�+M�!�&��)�+M�+M�N�N�N��=�$�,���?�?�?�?�?�?�?�����		@������1�/�B�
�+8����(��}�d�l�D�O�;�;s�(4�C�
BC�
C�Cr�c�`�|j�J�|tjkr/|���|j���dSt|jj��dkr4|j���|j���dS|���dS)z3Handle the logic when encountering a newline token.Nr[)	r
r��NEWLINEr��reset_blank_beforer+r�visited_new_blank_line�delete_first_token)r%r�s  r&r�zFileChecker.handle_newlines����~�)�)�)���)�)�)��#�#�%�%�%��N�-�-�/�/�/�/�/�
���&�
'�
'�1�
,�
,��N�1�1�3�3�3��N�-�-�/�/�/�/�/��#�#�%�%�%�%�%r(r�r�c���|j�J�tj|��r@|ddkr|�|��dS|�|d��dStj|��rw|dd}|j�|���5|j�|��D]}|�|���	ddd��dS#1swxYwYdSdS)z@Run physical checks if and only if it is at the end of the line.Nr�r�r\r)r@)r
�is_eol_tokenr��is_multiline_string�inside_multiline�
split_line)r%r�r��line_nor�s     r&r�zFileChecker.check_physical_eol,sP���~�)�)�)��!�%�(�(�	3��Q�x�2�~�~��(�(��7�7�7�7�7��(�(��q��2�2�2�2�2�
�
*�5�
1�
1�	3��A�h�q�k�G���0�0�W�0�E�E�
3�
3� �N�5�5�e�<�<�3�3�D��,�,�T�2�2�2�2�3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�
3�
3�	3�	3s�3C�C �#C r�)"r�r�r�r�r�r
�argparse�	Namespacer'r�rr
r�r�r�rerrr��staticmethodr�rr�r�r�r�r�r�rr|r�r��	TokenInfor�rSr(r&rLrLs%������E�E�J��J��	J�
�#�J�
�
J�J�J�J�22�#�2�2�2�2���)�*A�!B�������S�M�����	�
��

�
����*���3��3�����2�8�y�8�U�3��8�_�8�8�8��\�8�t����*+�+�+�+�4��������>&�&�&�&�6<�E�#�w��S�#�X��">�?�<�<�<�<� &��&��&�&�&�&�3��'�3�8;�3�	
�3�3�3�3�3�3r(rLrc�X�tjtjtj��dS)z:Ensure correct signaling of ^C using multiprocessing.Pool.N)�signal�SIGINT�SIG_IGNrSr(r&�
_pool_initrLs��
�M�&�-���0�0�0�0�0r(�	job_countc��	tj|t��S#t$r}|jt
vr�Yd}~nd}~wt$rYnwxYwdS)z@Return a new process pool instance if we are able to create one.N)r1�Poolrr��errno�SERIAL_RETRY_ERRNOS�ImportError)r�errs  r&rlrlQsy��
��#�I�z�:�:�:�������9�/�/�/��0�/�/�/�/������
�
�
���
�����4s��
A
�:�
A
�	A
�num_checkers�num_jobsc�.�t||dzzd��S)a�Determine the chunksize for the multiprocessing Pool.

    - For chunksize, see: https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool.imap  # noqa
    - This formula, while not perfect, aims to give each worker two batches of
      work.
    - See: https://github.com/pycqa/flake8/issues/829#note_18878876
    - See: https://github.com/pycqa/flake8/issues/197
    r\r[)�max)rr
s  r&rprp`s���|��1��-�q�1�1�1r(r,c�*�|���Sr�)r|)r,s r&rorols�������r(r�r�c��t|t��r|S|D]}|d}||kr
|d}n�d}dx}}|d|d|z|z
fS)z*Find the offset tuple for a single offset.rr[)rr)r�r )r�r�r��token_offset�positions     r&r�r�ps���&�%� � ���
��"�"���Q�x���\�!�!��Q�x�H��E�"��� !�!����Q�K��!��v�-��<�=�=r(r�).r�r�rhrr!�logging�multiprocessing.poolr1rr��typingrrrrr�flake8rr	r
r�flake8.discover_filesr�flake8.plugins.finderr
r�flake8.style_guiderr�r�r��	getLoggerr�r3�ENOSPCr	rrLrrvrrlrpro�_LogicalMappingr�rSr(r&�<module>rs���*�*�������������������������
�
�
�
�����������������������������������������������������������.�.�.�.�.�.�*�*�*�*�*�*�.�.�.�.�.�.�0�0�0�0�0�0�
�u�S�#�s�C��#��6�7�
8���g���!�!��
�L�
�� `#�`#�`#�`#�`#�`#�`#�`#�Fy3�y3�y3�y3�y3�y3�y3�y3�x	1�1�1�1�
���
�o�"�'�(�����	2�3�	2�#�	2�#�	2�	2�	2�	2� �� ��s�G�T�#�s�(�^�/K�)L� � � � �>��>�#�3�>�
�3��8�_�>�>�>�>�>�>r(