§
    øyIf  ã                  óŠ   — d Z ddlmZ ddlmZ ddlmZ ddlmZ  G d„ d¦  «        Z G d„ d	e¦  «        Z	 G d
„ d¦  «        Z
dS )z&Statistic collection logic for Flake8.é    )Úannotations)Ú	Generator)Ú
NamedTuple)Ú	Violationc                  ó6   — e Zd ZdZdd„Zdd„Zdd	„Z	 ddd„Zd
S )Ú
Statisticsz5Manager of aggregated statistics for a run of Flake8.ÚreturnÚNonec                ó   — i | _         dS )z8Initialize the underlying dictionary for our statistics.N)Ú_store©Úselfs    úE/var/www/piapp/venv/lib/python3.11/site-packages/flake8/statistics.pyÚ__init__zStatistics.__init__   s   € à,.ˆŒˆˆó    ú	list[str]c                ó>   — t          d„ | j        D ¦   «         ¦  «        S )ziReturn all unique error codes stored.

        :returns:
            Sorted list of error codes.
        c                ó   — h | ]	}|j         ’Œ
S © )Úcode)Ú.0Úkeys     r   ú	<setcomp>z)Statistics.error_codes.<locals>.<setcomp>   s   € Ð7Ð7Ð7 C�s”xÐ7Ð7Ð7r   ©Úsortedr   r   s    r   Úerror_codeszStatistics.error_codes   s#   € õ Ð7Ð7¨4¬;Ð7Ñ7Ô7Ñ8Ô8Ð8r   Úerrorr   c                óÎ   — t                                |¦  «        }|| j        vr"t                               |¦  «        | j        |<   | j        |                              ¦   «          dS )z°Add the fact that the error was seen in the file.

        :param error:
            The Violation instance containing the information about the
            violation.
        N)ÚKeyÚcreate_fromr   Ú	StatisticÚ	increment)r   r   r   s      r   ÚrecordzStatistics.record   s[   € õ �oŠo˜eÑ$Ô$ˆØ�d”kÐ!Ð!Ý(×4Ò4°UÑ;Ô;ˆDŒK˜ÑØŒ�CÔ×"Ò"Ñ$Ô$Ð$Ð$Ð$r   NÚprefixÚstrÚfilenameú
str | Noneú Generator[Statistic, None, None]c              #  óx   ‡‡K  — t          ˆˆfd„| j        D ¦   «         ¦  «        }|D ]}| j        |         V — ŒdS )aB  Generate statistics for the prefix and filename.

        If you have a :class:`Statistics` object that has recorded errors,
        you can generate the statistics for a prefix (e.g., ``E``, ``E1``,
        ``W50``, ``W503``) with the optional filter of a filename as well.

        .. code-block:: python

            >>> stats = Statistics()
            >>> stats.statistics_for('E12',
                                     filename='src/flake8/statistics.py')
            <generator ...>
            >>> stats.statistics_for('W')
            <generator ...>

        :param prefix:
            The error class or specific error code to find statistics for.
        :param filename:
            (Optional) The filename to further filter results by.
        :returns:
            Generator of instances of :class:`Statistic`
        c              3  óH   •K  — | ]}|                      ‰‰¦  «        ¯|V — Œd S ©N)Úmatches)r   r   r&   r$   s     €€r   ú	<genexpr>z,Statistics.statistics_for.<locals>.<genexpr>>   sJ   øè è € ð !
ð !
Ø¨#¯+ª+°f¸hÑ*GÔ*Gð!
Øð!
ð !
ð !
ð !
ð !
ð !
r   Nr   )r   r$   r&   Úmatching_errorsÚ
error_codes    ``  r   Ústatistics_forzStatistics.statistics_for%   sw   øøè è € õ2 !ð !
ð !
ð !
ð !
ð !
Øœ;ð!
ñ !
ô !
ñ 
ô 
ˆð *ð 	*ð 	*ˆJØ”+˜jÔ)Ð)Ð)Ð)Ð)ð	*ð 	*r   ©r	   r
   )r	   r   )r   r   r	   r
   r+   )r$   r%   r&   r'   r	   r(   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r#   r0   r   r   r   r   r   
   st   € € € € € Ø?Ð?ð/ð /ð /ð /ð9ð 9ð 9ð 9ð
%ð 
%ð 
%ð 
%ð 37ð*ð *ð *ð *ð *ð *ð *r   r   c                  óH   — e Zd ZU dZded<   ded<   edd„¦   «         Zdd„ZdS )r   zäSimple key structure for the Statistics dictionary.

    To make things clearer, easier to read, and more understandable, we use a
    namedtuple here for all Keys in the underlying dictionary for the
    Statistics object.
    r%   r&   r   r   r   r	   c                ó0   —  | |j         |j        ¬¦  «        S )z6Create a Key from :class:`flake8.violation.Violation`.©r&   r   r8   ©Úclsr   s     r   r    zKey.create_fromP   s   € ð ˆs˜EœN°´Ð<Ñ<Ô<Ð<r   r$   r'   Úboolc                óT   — | j                              |¦  «        o|du p
| j        |k    S )aÜ  Determine if this key matches some constraints.

        :param prefix:
            The error code prefix that this key's error code should start with.
        :param filename:
            The filename that we potentially want to match on. This can be
            None to only match on error prefix.
        :returns:
            True if the Key's code starts with the prefix and either filename
            is None, or the Key's filename matches the value passed in.
        N)r   Ú
startswithr&   )r   r$   r&   s      r   r,   zKey.matchesU   s5   € ð Œy×#Ò# FÑ+Ô+ð 
Ø˜ÐÐ9 ¤°Ò 9ð	
r   N)r   r   r	   r   )r$   r%   r&   r'   r	   r;   )r2   r3   r4   r5   Ú__annotations__Úclassmethodr    r,   r   r   r   r   r   E   sf   € € € € € € ðð ð €M€M�MØ€I€I�Iàð=ð =ð =ñ „[ð=ð
ð 
ð 
ð 
ð 
ð 
r   r   c                  ó:   — e Zd ZdZdd
„Zedd„¦   «         Zdd„ZdS )r!   zßSimple wrapper around the logic of each statistic.

    Instead of maintaining a simple but potentially hard to reason about
    tuple, we create a class which has attributes and a couple
    convenience methods on it.
    r/   r%   r&   ÚmessageÚcountÚintr	   r
   c                ó>   — || _         || _        || _        || _        dS )zInitialize our Statistic.N©r/   r&   rA   rB   )r   r/   r&   rA   rB   s        r   r   zStatistic.__init__n   s$   € ð %ˆŒØ ˆŒØˆŒØˆŒ
ˆ
ˆ
r   r   r   c                ó>   —  | |j         |j        |j        d¬¦  «        S )z>Create a Statistic from a :class:`flake8.violation.Violation`.r   rE   )r   r&   Útextr9   s     r   r    zStatistic.create_fromw   s/   € ð ˆsØ”zØ”^Ø”JØð	
ñ 
ô 
ð 	
r   c                ó&   — | xj         dz  c_         dS )zAIncrement the number of times we've seen this error in this file.é   N)rB   r   s    r   r"   zStatistic.increment�   s   € àˆ
Œ
�a‰ˆ
Œ
ˆ
ˆ
r   N)
r/   r%   r&   r%   rA   r%   rB   rC   r	   r
   )r   r   r	   r!   r1   )r2   r3   r4   r5   r   r?   r    r"   r   r   r   r!   r!   f   sf   € € € € € ðð ðð ð ð ð ð
ð 
ð 
ñ „[ð
ðð ð ð ð ð r   r!   N)r5   Ú
__future__r   Útypingr   r   Úflake8.violationr   r   r   r!   r   r   r   ú<module>rM      sÙ   ðØ ,Ð ,Ø "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &ð8*ð 8*ð 8*ð 8*ð 8*ñ 8*ô 8*ð 8*ðv
ð 
ð 
ð 
ð 
ˆ*ñ 
ô 
ð 
ðBð ð ð ð ñ ô ð ð ð r   