
    \Og                    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    V/Users/admin/workspace/ai/Jarvis/env/lib/python3.13/site-packages/flake8/statistics.py__init__Statistics.__init__   s	    ,.    c                j    [        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;Cxx;7887s   0c                    [         R                  U5      nX R                  ;  a"  [        R                  U5      U R                  U'   U R                  U   R	                  5         g)zAdd 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     ooe$kk!(44U;DKK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  X   >#    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++fh*GCC;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   zSimple 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     ENN<<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     yy##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   zSimple 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)     zz^^JJ	
 	
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   