VL ivdZddlmZddlmZddlmZddlmZGddZ Gdd eZ Gd d Z y ) z&Statistic collection logic for Flake8.) annotations) Generator) NamedTuple) Violationc>eZdZdZddZddZd dZ d d dZy) Statisticsz5Manager of aggregated statistics for a run of Flake8.ci|_y)z8Initialize the underlying dictionary for our statistics.N)_storeselfs W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/flake8/statistics.py__init__zStatistics.__init__ s ,. cft|jDchc]}|jc}Scc}w)ziReturn all unique error codes stored. :returns: Sorted list of error codes. )sortedr code)r keys r error_codeszStatistics.error_codess% 4;;7Csxx7887s.ctj|}||jvr"tj||j|<|j|j y)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 errorrs r recordzStatistics.recordsLooe$ dkk !(44U;DKK  C""$rNc#~Ktfd|jD}|D]}|j|yw)aBGenerate 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') >>> stats.statistics_for('W') :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` c3HK|]}|js|ywN)matches).0rfilenameprefixs r z,Statistics.statistics_for..>s#! #++fh*GC! s""N)rr )r r"r!matching_errors error_codes `` r statistics_forzStatistics.statistics_for%sD2!! ;;!  * *J++j) ) *s9=returnNone)r(z list[str])rrr(r)r)r"strr! str | Noner(zGenerator[Statistic])__name__ __module__ __qualname____doc__rrrr&rr rr s6?/9 %37**%/* *rrc@eZdZUdZded<ded<eddZd dZy) rzSimple 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!rc>||j|jS)z6Create a Key from :class:`flake8.violation.Violation`.r!rr3clsrs r rzKey.create_fromPsENN<r?s r rzStatistic.__init__ns %    rcV||j|j|jdS)z>Create a Statistic from a :class:`flake8.violation.Violation`.rr=)rr!textr4s r rzStatistic.create_fromws)zz^^JJ   rc.|xjdz c_y)zAIncrement the number of times we've seen this error in this file.N)r?r s r rzStatistic.increments a rN) r%r*r!r*r>r*r?intr(r))rrr(rr')r,r-r.r/rr:rrr0rr rrfsM),7:CF   rrN) r/ __future__rcollections.abcrtypingrflake8.violationrrrrr0rr rIs6,"%&8*8*v * Br