VL idZddlmZddlZddlZddlZddlZddlmZddl Z ddl m Z ddl m Z ddl m Z ddl m Z dd lmZdd lmZdd lmZdd lmZdd lmZej.eZGddZy)z3Module containing the application logic for Flake8.) annotationsN)Sequence)checker)defaults) exceptions) style_guide) BaseFormatter)debug) parse_args)finder)reportercxeZdZdZddZddZddZddZddZddZ ddZ dd Z dd Z dd Z dd Zdd ZddZy) Applicationz&Abstract our application into a class.ctj|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ y)zInitialize our application.NrF) time start_timeend_timeplugins formatterguidefile_checker_manageroptions result_counttotal_result_countcatastrophic_failureselfs ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/flake8/main/application.py__init__zApplication.__init__sb))+&* .2 /3<@ =A!37 #$%*!c|jry|jJ|jjryt|jdkDS)zReturn the program exit code.r)rr exit_zerointrrs r exit_codezApplication.exit_code:sD  $ $||''' << ! !t((1,- -r c|jJ|jJtj|jj|j|_y)z3Initialize a formatter based on the parsed options.N)rrr make reportersrrs rmake_formatterzApplication.make_formatterDsB||'''||'''!t||'='=t||Lr c|jJ|jJtj|j|j|_y)zInitialize our StyleGuide.N)rrrStyleGuideManagerrrs r make_guidezApplication.make_guideJsA~~)))||''' 22 LL$..  r c|jJ|jJtj|j|jj||_y)z#Initialize our FileChecker Manager.N)rrargv)rrrManagercheckersrrr.s rmake_file_checker_managerz%Application.make_file_checker_managerRsJzz%%%||'''$+OO LL))% !r c|jJ|jj |jjtjd|jjtj|_ y#tj$r0}t t |t dd|_Yd}~d}~wwxYw)zRun the actual checks with the FileChecker Manager. This method encapsulates the logic to make a :class:`~flake8.checker.Manger` instance run the checks it is managing. Nz5Run flake8 with greater verbosity to see more detailsTzFinished running) rstartrunrPluginExecutionFailedprintstrrLOGinfostoprr)r plugin_faileds r run_checkszApplication.run_checks\s((444 !!'') -  % % ) ) + #$ !!&&(  // - #m$ % I J(,D % % -sB C &C  Cc|jJ|jjsy|jJ|jJ|j|jz }d|fg}|j }t jdzD]F}|jj|}d|d}|||f|d}||t||z fH|jJ|jj|y)z9Aggregate, calculate, and report benchmarks for this run.Nzseconds elapsed)filesztotal z processedz processed per second) r benchmarkrrrappendrSTATISTIC_NAMES statisticsr$rshow_benchmarks)r time_elapsedrC add_statistic statisticvaluetotal_descriptionper_second_descriptions rreport_benchmarkszApplication.report_benchmarksps||'''||%% ((444}}(((}}t6 (,78 ")) !11J> OI--88CE"( : >  ,e4 5(1{2G%H " 13u|7K3LM N  O~~))) &&z2r ctjd|jJ|jj}|\|_|_tjd|j|j y)zReport all the errors found by flake8 3.0. This also updates the :attr:`result_count` attribute with the total number of errors, warnings, and other messages found. zReporting errorsNz.Found a total of %d violations and reported %d)r9r:rreportrr)rresultss r report_errorszApplication.report_errorssh #$((444++2245<2!2  <  # #    r c|jJ|jjsy|jJ|jJ|jj |jj y)z.Aggregate and report statistics from this run.N)rrCrrshow_statisticsstatsrs rreport_statisticszApplication.report_statisticss^||'''||&& ~~)))zz%%% &&tzz'7'78r cvt|\|_|_|jjrZt j t j|j}ttj|ddtd|j|j|j|y)zInitialize the application to be run. This finds the plugins, registers their options, and parses the command-line arguments. T)indent sort_keysrN)r rr bug_reportr informationflake8 __version__r7jsondumps SystemExitr)r,r2)rr.r:s r initializezApplication.initializes &0%5" dl << " "$$V%7%7FD $**T!t< =Q-    &&t,r c|jJ|jj|j|j|j |jj y)z*Report errors, statistics, and benchmarks.N)rr4rOrSrKr;rs rrMzApplication.reportsV~~)))       r cf|j||j|jy)N)r_r=rMr1s r_runzApplication._runs!   r c& |j||jJ|jjrt|jyy#t $rF}tdt jdt j|d|_ Yd}~yd}~wtj$r<}tdt|t j|d|_ Yd}~yd}~wtj$rd|_ tdYywxYw)zRun our application. This method will also handle KeyboardInterrupt exceptions for the entirety of the flake8 application. If it sees a KeyboardInterrupt it will forcibly clean up the :class:`~flake8.checker.Manager`. Nz ... stoppedz#Caught keyboard interrupt from userTz6There was a critical error during execution of Flake8:z"... stopped while processing files) rbrcountr7rKeyboardInterruptr9critical exceptionrrExecutionError EarlyQuit)rr.excs rr5zApplication.runs ) IIdO<<+ ++||!!d''("! - - LL> ? MM# (,D % %(( - J K #J MM# (,D % %## 8(,D % 6 7 8s)A Dr{sX9"  $ 00!#g!~)~)r