
    c                        d Z ddlmZ ddlZddlZddlZ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j        e          Zd	Z G d
 d          Z G d d          ZddZdS )zModule containing shims around Flake8 2.x behaviour.

Previously, users would import :func:`get_style_guide` from ``flake8.engine``.
In 3.0 we no longer have an "engine" module but we maintain the API from it.
    )annotationsN)Any)expand_paths)base)application)
parse_args)get_style_guidec                  :    e Zd ZdZddZedd            ZddZdS )Reporta"  Public facing object that mimic's Flake8 2.0's API.

    .. note::

        There are important changes in how this object behaves compared to
        the object provided in Flake8 2.x.

    .. warning::

        This should not be instantiated by users.

    .. versionchanged:: 3.0.0
    r   app.ApplicationreturnNonec                `    |j         J || _        |j         | _        | j        j        | _        dS )zlInitialize the Report for the user.

        .. warning:: This should not be instantiated by users.
        N)guide_application_style_guidestats_statsselfr   s     1lib/python3.11/site-packages/flake8/api/legacy.py__init__zReport.__init__'   s7    
  ,,,''-'-    intc                    | j         j        S )z"Return the total number of errors.)r   result_countr   s    r   total_errorszReport.total_errors1   s      --r   	violationstr	list[str]c                J    d | j                             |          D             S )zGet the list of occurrences of a violation.

        :returns:
            List of occurrences of a violation formatted as:
            {Count} {Error Code} {Message}, e.g.,
            ``8 E531 Some error message about the error``
        c                @    g | ]}|j          d |j         d |j         S ) )count
error_codemessage).0ss     r   
<listcomp>z)Report.get_statistics.<locals>.<listcomp>>   sD     
 
 
 w3333	33
 
 
r   )r   statistics_for)r   r   s     r   get_statisticszReport.get_statistics6   s3    
 
[//	::
 
 
 	
r   Nr   r   r   r   )r   r   )r   r    r   r!   )__name__
__module____qualname____doc__r   propertyr   r,    r   r   r   r      sf         . . . . . . . X.
 
 
 
 
 
r   r   c                  z    e Zd ZdZddZed d            Zed!d
            Zd"d#dZd"d$dZ		 d"d%dZ
	 	 	 d&d'dZdS )(
StyleGuideaD  Public facing object that mimic's Flake8 2.0's StyleGuide.

    .. note::

        There are important changes in how this object behaves compared to
        the StyleGuide object provided in Flake8 2.x.

    .. warning::

        This object should not be instantiated directly by users.

    .. versionchanged:: 3.0.0
    r   r   r   r   c                ,    || _         |j        | _        dS )zInitialize our StyleGuide.N)r   file_checker_manager_file_checker_managerr   s     r   r   zStyleGuide.__init__S   s    '%0%E"""r   argparse.Namespacec                6    | j         j        J | j         j        S )zuReturn application's options.

        An instance of :class:`argparse.Namespace` containing parsed options.
        )r   optionsr   s    r   r;   zStyleGuide.optionsX   s"      (444 ((r   r!   c                @    | j         j        J | j         j        j        S )z+Return the extra arguments passed as paths.)r   r;   	filenamesr   s    r   pathszStyleGuide.pathsa   s%      (444 (22r   Nr>   list[str] | Noner   c                    | j         j        J || j         j        _        | j                                          | j                                          t          | j                   S )a)  Run collected checks on the files provided.

        This will check the files passed in and return a :class:`Report`
        instance.

        :param paths:
            List of filenames (or paths) to check.
        :returns:
            Object that mimic's Flake8 2.0's Reporter class.
        )r   r;   r=   
run_checksreport_errorsr   )r   r>   s     r   check_fileszStyleGuide.check_filesg   s_      (444.3!+$$&&&'')))d'(((r   filenamer    parent
str | Noneboolc                     d fd} ||          p,|duo( |t           j                            ||                    S )a"  Determine if a file is excluded.

        :param filename:
            Path to the file to check if it is excluded.
        :param parent:
            Name of the parent directory containing the file.
        :returns:
            True if the filename is excluded, False otherwise.
        pathr    r   rG   c                    t          t          | gj        j        j        j        j        j                            }| S )N)r>   stdin_display_namefilename_patternsexclude)tupler   r;   rK   rD   rM   )rI   r>   r   s     r   excludedz%StyleGuide.excluded.<locals>.excluded   sK    &'+|'F&*l&; L0	   E 9r   N)rI   r    r   rG   )osrI   join)r   rD   rE   rO   s   `   r   rO   zStyleGuide.excludedx   sa    		 		 		 		 		 		 x!! 
$K88BGLL,J,J#K#K	
r   reporter$type[formatter.BaseFormatter] | Nonec                *   |dS t          |t          j                  st          d           || j                  | j        _        d| j        _        | j                                         d| j        _        | j        	                    g            dS )z*Set up a formatter for this run of Flake8.Nz<Report should be subclass of flake8.formatter.BaseFormatter.)

issubclass	formatterBaseFormatter
ValueErrorr;   r   r   
make_guider7   make_file_checker_manager)r   rR   s     r   init_reportzStyleGuide.init_report   s    
  	F(I$;<< 	2   '/ht|&<&<#"& 	$$&&&15.33B77777r   r   lines
Any | Noneexpectedline_offsetc                .    |                      |g          S )a  Run collected checks on a single file.

        This will check the file passed in and return a :class:`Report`
        instance.

        :param filename:
            The path to the file to check.
        :param lines:
            Ignored since Flake8 3.0.
        :param expected:
            Ignored since Flake8 3.0.
        :param line_offset:
            Ignored since Flake8 3.0.
        :returns:
            Object that mimic's Flake8 2.0's Reporter class.
        )rC   )r   rD   r\   r^   r_   s        r   
input_filezStyleGuide.input_file   s    . 
+++r   r-   )r   r9   )r   r!   )N)r>   r?   r   r   )rD   r    rE   rF   r   rG   )rR   rS   r   r   )NNr   )
rD   r    r\   r]   r^   r]   r_   r]   r   r   )r.   r/   r0   r1   r   r2   r;   r>   rC   rO   r[   ra   r3   r   r   r5   r5   D   s         F F F F
 ) ) ) X) 3 3 3 X3
) ) ) ) )"
 
 
 
 
8 :>8 8 8 8 80 !#"#, , , , , , ,r   r5   kwargsr   r   c                    t          j                    }t          g           \  |_        |_        |j        }|                                 D ]R\  }}	 t          ||           t          |||           (# t          $ r t          
                    d|           Y Ow xY w|                                 |                                 |                    g            t          |          S )zProvision a StyleGuide for use.

    :param \*\*kwargs:
        Keyword arguments that provide some options for the StyleGuide.
    :returns:
        An initialized StyleGuide
    zCould not update option "%s")appApplicationr   pluginsr;   itemsgetattrsetattrAttributeErrorLOGerrormake_formatterrY   rZ   r5   )rb   r   r;   keyvalues        r   r	   r	      s     /##K/9"~~,K, !Gllnn ; ;
U	;GS!!!GS%(((( 	; 	; 	;II4c:::::	;   ))"---k"""s   !A33%BB)rb   r   r   r5   )r1   
__future__r   argparseloggingos.pathrP   typingr   flake8.discover_filesr   flake8.formattingr   rV   flake8.mainr   rd   flake8.options.parse_argsr   	getLoggerr.   rk   __all__r   r5   r	   r3   r   r   <module>r{      s)   
 # " " " " "          . . . . . . / / / / / / * * * * * * 0 0 0 0 0 0g!! )
 )
 )
 )
 )
 )
 )
 )
Xz, z, z, z, z, z, z, z,z# # # # # #r   