L idZddlmZddlZddlZddlZddlmZddlm Z m Z m Z ddl m Z ddlmZddlmZmZmZdd lmZmZe rdd l mZdd lmZdd lmZeee fZd ZGddZ ddZ!y)zJson reporting for coverage.py) annotationsN)Iterable)IO TYPE_CHECKINGAny) __version__)get_analysis_to_report)AnalysisAnalysisNarrowerNumbers)TLineNoTMorf)Coverage) CoverageData) FileReportercTeZdZdZdZd dZd dZd dZd dZ d dZ ddZ y ) JsonReporterz-A reporter for writing JSON coverage results.z JSON reportc||_|jj|_t|jj|_i|_yN)coverageconfigr precisiontotal report_data)selfrs Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/coverage/jsonreport.py__init__zJsonReporter.__init__'s8  mm** T[[223 $&c |j|j|j|j|j|j |j |jdS)z!Create a dict summarizing `nums`.) covered_linesnum_statementspercent_coveredpercent_covered_display missing_linesexcluded_linespercent_statements_covered"percent_statements_covered_display) n_executed n_statements pc_coveredpc_covered_str n_missing n_excluded pc_statementspc_statements_strrnumss r make_summaryzJsonReporter.make_summary-sN"__"//#'+':':!^^"oo*.*<*<262H2H  rc|j|j|j|j|j|j dS)z4Create a dict summarizing the branch info in `nums`.) num_branchesnum_partial_branchescovered_branchesmissing_branchespercent_branches_covered percent_branches_covered_display) n_branchesn_partial_branchesn_executed_branchesn_missing_branches pc_branchespc_branches_strr1s rmake_branch_summaryz JsonReporter.make_branch_summary:sB!OO$($;$; $ 8 8 $ 7 7(,(8(8040D0D   rc|xstj}|jj}|j |j j tttjjj|j|j jd|jd<i}t|j|D])\}}|j!|||||j#<+||jd<|j%|j&|jd<|jr7|jdj)|j+|j&t-j.|j||j j0rdnd|j&j2xr|j&j4S)zGenerate a json report for `morfs`. `morfs` is a list of modules or file names. `outfile` is a file object to write the json to. )formatversion timestampbranch_coverage show_contextsmetafilestotalsN)indent)sysstdoutrget_dataset_query_contextsrreport_contextsFORMAT_VERSIONrdatetimenow isoformathas_arcsjson_show_contextsrr report_one_filerelative_filenamer3rupdaterAjsondumpjson_pretty_printr*r+)rmorfsoutfile coverage_datameasured_files file_reporteranalysiss rreportzJsonReporter.reportEs'SZZ ..0 (()D)DE$"!**..0::<,557![[;; $  '=dmmU'S  #M8@D@T@TAN=::< = %3!%)%6%6tzz%B"  ! ! #   X & - -d.F.Ftzz.R S    66AD zz&&@4::+@+@@rc|j}|xj|z c_|j|}t|j|t|j t|j d}|jjr|j|j|d<|jrj|j|j|tt|j!|d<tt|j#|d<t%|j'j)}|j+}|j-D]\} t/t1d|dz} |D]!} | j2k7r| | j4z} #t7|} | j9fd|D| j9| gix|| <} |D]J} | j2k7r|j;|| j=| j4| | j><L|j;|| j=| | d<|S)z3Extract the relevant report data for a single file.executed_linessummaryr%r&contextsexecuted_branchesr8c3VK|] }|jk(s|j"ywr)kindlines).0rnouns r z/JsonReporter.report_one_file..s LQQVVt^ Ls))) numbersrr3sortedexecutedmissingexcludedrrWcontexts_by_linenofilenamerVrZrAlist_convert_branch_arcsexecuted_branch_arcsmissing_branch_arcslensource splitlines code_regionscode_region_kindssetrangermrnr add_regionsmake_region_datanarrowname)rr`rcrbr2rh reported_file num_linesregionsplural outside_linesregionnarrower region_datarqs @rrXzJsonReporter.report_one_filens2 d ##D)$X%6%67#H$4$45$X%6%67 " ;; ) )(5(H(HIZIZ([M* %  ! ! # NN433D9 :15$X%B%B%DE2M- .15$X%A%A%CD1M, - ,,.99;< ,,.);;= LD&aQ 78M! .;;$&-  . (1H  L' L L  - 124 4M& !K! ;;$&+/+@+@!OOFLL1, FKK( #33 .KO) 0rc |j}|j|}t|j|t|jt|j d}|j jr |j|j}||d<|jrj|j|j|tt|j|d<tt|j!|d<|S)z0Create the data object for one region of a file.rfrirjr8)rtr3rurvrwrxrrWryrzrVrZrAr{r|r}r~)rr`narrowed_analysis narrowed_numsnarrowed_summary this_regionris rrzJsonReporter.make_region_datas)11 ,,];$%6%?%?@'#$5$=$=>$%6%?%?@  ;; ) )$778I8R8RSH&.K #  ! ! #  # #D$<$<]$K L/3$%6%K%K%MN0K+ ,/3$%6%J%J%LM/K* +rN)rrreturnNone)r2r rJsonObj)r^zIterable[TMorf] | Noner_zIO[str]rfloat)r`rrcr rbrrr)r`rrr rr) __name__ __module__ __qualname____doc__ report_typerr3rArdrXrrrrr"sK7K'    'AR2)25=2NZ2 2hrrc#VK|jD]\}}|D]}||f yw)z4Convert branch arcs to a list of two-element tuples.N)items) branch_arcsrtargetstargets rr|r|s=',,.! !F&.  !!s'))rzdict[TLineNo, list[TLineNo]]rz!Iterable[tuple[TLineNo, TLineNo]])"r __future__rrSr[rMcollections.abcrtypingrrrrrcoverage.report_corer coverage.resultsr r r coverage.typesr rr coverage.datarcoverage.pluginrdictstrrrRrr|rrrrsr%" $)) 7@@)!*, sCx. UUp!-!&!r