ó
    áÅŸg  ã                  óv   • S r SSKJr  SSKJr  SSKJr  SSKJr   " S S5      r " S S	\5      r	 " S
 S5      r
g)z&Statistic collection logic for Flake8.é    )Úannotations)Ú	Generator)Ú
NamedTuple)Ú	Violationc                  óP   • \ rS rSrSrS	S jrS
S jrSS jr S     SS jjrSr	g)Ú
Statisticsé
   z5Manager of aggregated statistics for a run of Flake8.c                ó   • 0 U l         g)z8Initialize the underlying dictionary for our statistics.N©Ú_store©Úselfs    ÚR/var/www/blue/EV-Temp_rev04/venv/lib/python3.13/site-packages/flake8/statistics.pyÚ__init__ÚStatistics.__init__   s	   € à,.ˆ�ó    c                óh   • [        U R                   Vs1 sH  oR                  iM     sn5      $ s  snf )zQReturn all unique error codes stored.

:returns:
    Sorted list of error codes.
)Úsortedr   Úcode)r   Úkeys     r   Úerror_codesÚStatistics.error_codes   s'   € ô ¨4¯;ª;Ó7©; C—x”x©;Ñ7Ó8Ð8ùÒ7s   ”/c                óÊ   • [         R                  U5      nX R                  ;  a"  [        R                  U5      U R                  U'   U R                  U   R	                  5         g)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   Úerrorr   s      r   ÚrecordÚStatistics.record   sJ   € ô �o‰o˜eÓ$ˆØ—k‘kÓ!Ü(×4Ñ4°UÓ;ˆD�K‰K˜ÑØ�‰�CÑ×"Ñ"Õ$r   Nc              #  ó„   ^^#   • [        UU4S jU R                   5       5      nU H  nU R                  U   v •  M     g7f)aº  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  óV   >#   • U H  oR                  TT5      (       d  M  Uv •  M!     g 7f©N)Úmatches)Ú.0r   ÚfilenameÚprefixs     €€r   Ú	<genexpr>Ú,Statistics.statistics_for.<locals>.<genexpr>>   s!   øé € ð !
Ù&�C¯+©+°f¸h×*G�C‰Cš;ùs   ƒ) 	)N)r   r   )r   r'   r&   Úmatching_errorsÚ
error_codes    ``  r   Ústatistics_forÚStatistics.statistics_for%   s>   ùé € ô2 !õ !
ØŸ;š;ó!
ó 
ˆó *ˆJØ—+‘+˜jÑ)Ô)ò *ùs   „<A r   ©ÚreturnÚNone)r/   z	list[str])r   r   r/   r0   r#   )r'   Ústrr&   ú
str | Noner/   z Generator[Statistic, None, None])
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r,   Ú__static_attributes__© r   r   r   r   
   s;   † Ù?ô/ô9ô
%ð 37ð*Øð*Ø%/ð*à	)÷*ð *r   r   c                  óL   • \ rS rSr% SrS\S'   S\S'   \S
S j5       rSS jrSr	g	)r   éE   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.
r1   r&   r   c                ó8   • U " UR                   UR                  S9$ )z6Create a Key from :class:`flake8.violation.Violation`.©r&   r   r=   ©Úclsr   s     r   r   ÚKey.create_fromP   s   € ñ ˜EŸN™N°·±Ñ<Ð<r   c                óz   • U R                   R                  U5      =(       a    USL =(       d    U R                  U:H  $ )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$   ÚKey.matchesU   s6   € ð �y‰y×#Ñ# FÓ+÷ 
Ø˜Ð×9 §¡°Ñ 9ð	
r   r9   N)r   r   r/   r   )r'   r1   r&   r2   r/   Úbool)
r3   r4   r5   r6   r7   Ú__annotations__Úclassmethodr   r$   r8   r9   r   r   r   r   E   s*   ‡ ñð ƒMØ
ƒIàó=ó ð=÷
r   r   c                  óT   • \ rS rSrSr          SS jr\S	S j5       rS
S jrSr	g)r   éf   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.
c                ó4   • Xl         X l        X0l        X@l        g)zInitialize our Statistic.N©r+   r&   ÚmessageÚcount)r   r+   r&   rK   rL   s        r   r   ÚStatistic.__init__n   s   € ð %ŒØ ŒØŒØ�
r   c                óP   • U " UR                   UR                  UR                  SS9$ )z>Create a Statistic from a :class:`flake8.violation.Violation`.r   rJ   )r   r&   Útextr>   s     r   r   ÚStatistic.create_fromw   s)   € ñ Ø—z‘zØ—^‘^Ø—J‘JØñ	
ð 	
r   c                ó.   • U =R                   S-  sl         g)zAIncrement the number of times we've seen this error in this file.é   N)rL   r   s    r   r   ÚStatistic.increment�   s   € à�
Š
�a‰Ž
r   )rL   r+   r&   rK   N)
r+   r1   r&   r1   rK   r1   rL   Úintr/   r0   )r   r   r/   r   r.   )
r3   r4   r5   r6   r7   r   rF   r   r   r8   r9   r   r   r   r   f   sM   † ñðØðØ),ðØ7:ðØCFðà	ôð ó
ó ð
÷r   r   N)r7   Ú
__future__r   Útypingr   r   Úflake8.violationr   r   r   r   r9   r   r   Ú<module>rX      s6   ðÙ ,Ý "å Ý å &÷8*ñ 8*ôv
ˆ*ô 
÷Bò r   