
     h>                    r   S r SSKJr  SSKrSSKrSSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJrJr  \(       a  SS	KJr  SS
KJr            SS jr\R*                   " S S5      5       r\\   r " S S5      r\R*                   " S S5      5       rSS jr      SS jr S       SS jjrSS jrg)z Results of coverage measurement.    )annotationsN)Iterable)TYPE_CHECKING)ConfigError)	nice_pair)TArcTLineNo)CoverageData)FileReporterAnalysisc                   U R                  5       nUR                  5       nUR                  5       nUR                  U R                  U5      =(       d    / 5      nU(       Ga1  UR	                  5       nU R	                  U5      =(       d    / n	UR                  U	5      n	[        R                  " [        5      n
U H  u  pX   R                  U5        M     U
R                  5        VVs0 s H%  u  p[        U5      S:X  d  M  U[        U5      S   _M'     nnn[        5       nU	 H:  u  pX:w  a  UR                  X45        M  X;   d  M%  UR                  XU   45        M<     UR                  U5      nUR                  5       nUR                  5       nO [        5       n[        5       n0 n[        5       n[        UUUUUUUUUUS9
$ s  snnf )z'Create an Analysis from a FileReporter.   r   
	precisionfilenamehas_arcs
statementsexcludedexecutedarc_possibilities_setarcs_executed_setexit_counts	no_branch)r   linesexcluded_linestranslate_linesarcstranslate_arcscollectionsdefaultdictsetadditemslenlistr   no_branch_linesr   )datar   file_reporterr   r   r   r   r   r   r   destsfromnotonotonossingle_destsnew_arcsr   r   r   s                      n/root/racknerd_01/codex-conversation/amazon-q-terraform/.venv/lib/python3.13/site-packages/coverage/results.pyanalysis_from_file_reporterr0      s    }}H$$&J++-H,,TZZ-A-GRHH - 2 2 4#yy28b++D1 '',1LFMd# 2 9>
8E}vUWX"FDKN" 	 
 5 LF~f^,)LL&v*>!?@ ! *88B#//1!113	 #EE	3+ )
s   (GGc                      \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'   S	\S'   S	\S'   S\S'   S\S'   S\S'   S	\S'   SS jrSSS jjrS S jrS!S jr	S"S jr
S#S jrS#S jrS$S jrSrg)%r   M   z(The results of analyzing a FileReporter.intr   strr   boolr   set[TLineNo]r   r   r   	set[TArc]r   r   zdict[TLineNo, int]r   r   c                N  ^  [        T R                  5      T l        [        T R                  5      T l        T R
                  T R                  -
  T l        T R                  (       ad  T R                  5       nT R                  5       n[        U 4S jUR                  5        5       5      n[        S UR                  5        5       5      nOS=n=p4[        T R                  S[        T R
                  5      [        T R                   5      [        T R                  5      UUUS9T l        g )Nc              3  b   >#    U  H$  u  pUTR                   ;  d  M  [        U5      v   M&     g 7fN)missingr$   ).0kvselfs      r/   	<genexpr>)Analysis.__post_init__.<locals>.<genexpr>d   s)     $]qPTP\P\G\VSVVs   //c              3  <   #    U  H  u  p[        U5      v   M     g 7fr:   )r$   )r<   r=   r>   s      r/   r@   rA   e   s     $DSVVs   r   r   )r   n_filesn_statements
n_excluded	n_missing
n_branchesn_partial_branchesn_missing_branches)sortedr   arc_possibilitiesr   arcs_executedr   r   r;   r   _total_branchesmissing_branch_arcssumr#   Numbersr   r$   r   numbers)r?   rG   mbarH   rI   s   `    r/   __post_init__Analysis.__post_init__\   s    !'(B(B!C#D$:$:;6==--/J**,C!$$]		$]!]!$$D		$D!DCDDJD+nnT__-4==)$,,'!11	
    c                    U(       a0  U R                   (       a  U R                  5       R                  5       nOSn[        U R                  U R
                  US9$ )zThe missing line numbers, formatted nicely.

Returns a string like "1-2, 5-11, 13-14".

If `branches` is true, includes the missing branch arcs also.

N)r   )r   rN   r#   format_linesr   r;   )r?   branchesr   s      r/   missing_formattedAnalysis.missing_formattedt   s@     ++-335DDDOOT\\EErU   c                F   ^  U 4S jT R                    5       n[        U5      $ )z:Returns a sorted list of the un-executed arcs in the code.c              3     >#    U  HC  nUTR                   ;  d  M  US    TR                  ;  d  M*  US   TR                  ;  d  M?  Uv   ME     g7f)r   r   N)r   r   r   )r<   pr?   s     r/   r@   (Analysis.arcs_missing.<locals>.<genexpr>   sV      
+...  !DNN*  !DMM)	 A+s   AAA	A)rK   rJ   )r?   r;   s   ` r/   arcs_missingAnalysis.arcs_missing   s$    
++
 grU   c                |    U R                   R                  5        VVs/ s H  u  pUS:  d  M  UPM     snn$ s  snnf )z<Returns a list of line numbers that have more than one exit.r   )r   r#   )r?   l1counts      r/   _branch_linesAnalysis._branch_lines   s3    $($4$4$:$:$<J$<yr	$<JJJs   88c                V    [        S U R                  R                  5        5       5      $ )z"How many total branches are there?c              3  4   #    U  H  oS :  d  M
  Uv   M     g7f)r   N )r<   rc   s     r/   r@   +Analysis._total_branches.<locals>.<genexpr>   s     M&?U1955&?s   		)rO   r   valuesr?   s    r/   rM   Analysis._total_branches   s"    Md&6&6&=&=&?MMMrU   c                   U R                  5       n[        U R                  5       5      n[        R                  " [
        5      nU H>  u  pEXE:w  d   SU R                   SU SU 35       eXB;   d  M+  X4   R                  U5        M@     U$ )zWReturn arcs that weren't executed from branch lines.

Returns {l1:[l2a,l2b,...], ...}

zIn z, didn't expect z == )r_   r!   rd   r   r    r%   r   append)r?   r;   branch_linesrR   rb   l2s         r/   rN   Analysis.missing_branch_arcs   s     ##%4--/0%%d+FB8Ns4==/1A"T"NN8!r"  
rU   c                   [        U R                  5       5      n[        R                  " [        5      nU R
                   HF  u  p4X4:w  d   SU< SU< 35       eX44U R                  ;  a  M,  X1;   d  M3  X#   R                  U5        MH     U$ )zReturn arcs that were executed from branch lines.

Only include ones that we considered possible.

Returns {l1:[l2a,l2b,...], ...}

z+Oops: Didn't think this could happen: l1 = z, l2 = )r!   rd   r   r    r%   rL   r   rn   )r?   ro   ebarb   rp   s        r/   executed_branch_arcsAnalysis.executed_branch_arcs   s     4--/0%%d+((FB8VKbWHrgVV8xt999!r" ) 
rU   c                    U R                  5       n0 nU R                  5        H'  nU R                  U   n[        X   5      nXDU-
  4X#'   M)     U$ )zhGet stats about branches.

Returns a dict mapping line numbers to a tuple:
(total_exits, taken_exits).

)rN   rd   r   r$   )r?   missing_arcsstatslnumexitsr;   s         r/   branch_statsAnalysis.branch_stats   s\     //1&&(D$$T*E,,-G '/2EK ) rU   )rK   rL   r;   rQ   N)returnNone)F)rX   r5   r}   r4   )r}   z
list[TArc])r}   zlist[TLineNo]r}   r3   )r}   zdict[TLineNo, list[TLineNo]])r}   zdict[TLineNo, tuple[int, int]])__name__
__module____qualname____firstlineno____doc____annotations__rS   rY   r_   rd   rM   rN   rt   r{   __static_attributes__rh   rU   r/   r   r   M   si    2NMN$$  ##
0F	KN$rU   c                  6    \ rS rSrSrSS jrS	S jrS
S jrSrg)AnalysisNarrower   a  
For reducing an `Analysis` to a subset of its lines.

Originally this was a simpler method on Analysis, but that led to quadratic
behavior.  This class does the bulk of the work up-front to provide the
same results in linear time.

Create an AnalysisNarrower from an Analysis, bulk-add region lines to it
with `add_regions`, then individually request new narrowed Analysis objects
for each region with `narrow`.  Doing most of the work in limited calls to
`add_regions` lets us avoid poor performance.
c                    Xl         [        R                  " [        5      U l        [        R                  " [        5      U l        [        R                  " [        5      U l        g r:   )analysisr   r    r!   region2arc_possibilitiesregion2arc_executeddictregion2exit_counts)r?   r   s     r/   __init__AnalysisNarrower.__init__   sF     GRG^G^_bGc%BMBYBYZ]B^ JUJaJaK
rU   c                  ^	 U R                   R                  (       a  0 m	U H  n[        U5      nU H  nUT	U'   M
     M           SU	4S jjnU" U R                   R                  U R                  5        U" U R                   R
                  U R                  5        U R                   R                  R                  5        H0  u  pgT	R                  U5      =n(       d  M  XpR                  U   U'   M2     gg)z
Pre-process a number of sets of line numbers.  Later calls to `narrow`
with one of these sets will provide a narrowed Analysis.
c                   > U  H_  u  p#TR                  U5      =n(       a  X   R                  X#45        TR                  U5      =n(       d  MK  X   R                  X#45        Ma     g r:   )getr"   )arc_setregion2arcsabrline2regions        r/   collect_arcs2AnalysisNarrower.add_regions.<locals>.collect_arcs   s]     $DA'OOA..q.#**A62'OOA..q.#**A62	 $rU   N)r   r7   r   zdict[TRegionLines, set[TArc]]r}   r~   )r   r   	frozensetr   r   r   r   r   r#   r   r   )
r?   linessr   fzlinesliner   lnonumr   r   s
            @r/   add_regionsAnalysisNarrower.add_regions   s    
 ==!!79K#E*!D(/K% "  
3"3:3 3 <<d>[>[\88$:R:RS MM55;;=#,,1,69++A.s3 >+ "rU   c                N   U R                   R                  U-  nU R                   R                  U-  nU R                   R                  U-  nU R                   R                  (       aR  [        U5      nU R                  U   nU R                  U   nU R                  U   nU R                   R                  U-  n	O [        5       n[        5       n0 n[        5       n	[        U R                   R                  U R                   R                  U R                   R                  UUUUUUU	S9
$ )zxCreate a narrowed Analysis.

The current analysis is copied to make a new one that only considers
the lines in `lines`.
r   )r   r   r   r   r   r   r   r   r   r   r!   r   r   r   )
r?   r   r   r   r   r   r   r   r   r   s
             r/   narrowAnalysisNarrower.narrow  s    ]]--5
==))E1==))E1==!!&G$($A$A'$J! $ 8 8 A11':K//%7I$'E! #KImm--]]++]]++!"7/#
 	
rU   )r   r   r   r   N)r   r   r}   r~   )r   zIterable[set[TLineNo]]r}   r~   )r   r6   r}   r   )	r   r   r   r   r   r   r   r   r   rh   rU   r/   r   r      s    
:<&
rU   r   c                     \ rS rSr% SrSrS\S'   SrS\S'   SrS\S'   Sr	S\S'   Sr
S\S	'   SrS\S
'   SrS\S'   SrS\S'   \SS j5       r\SS j5       r\SS j5       r\SS j5       r\SS j5       rSS jrSS jrSrg)rP   i*  zThe numerical results of measuring coverage.

This holds the basic statistics from `Analysis`, and is used to roll
up statistics across files.

r   r3   r   rC   rD   rE   rF   rG   rH   rI   c                4    U R                   U R                  -
  $ )z*Returns the number of executed statements.)rD   rF   rk   s    r/   
n_executedNumbers.n_executed<  s       4>>11rU   c                4    U R                   U R                  -
  $ )z(Returns the number of executed branches.)rG   rI   rk   s    r/   n_executed_branchesNumbers.n_executed_branchesA  s     !8!888rU   c                Z    U R                   S:  a  U R                  u  pSU-  U-  nU$ SnU$ )z/Returns a single percentage value for coverage.r         Y@)rD   ratio_covered)r?   	numeratordenominatorpc_covs       r/   
pc_coveredNumbers.pc_coveredF  sB     q %)%7%7"Ii';6F  FrU   c                B    [        U R                  U R                  5      $ )zReturns the percent covered, as a string, without a percent sign.

Note that "0" is only returned when the value is truly zero, and "100"
is only returned when the value is truly 100.  Rounding can never
result in either "0" or "100".

)display_coveredr   r   rk   s    r/   pc_covered_strNumbers.pc_covered_strP  s     t??rU   c                l    U R                   U R                  -   nU R                  U R                  -   nX4$ )z:Return a numerator and denominator for the coverage ratio.)r   r   rD   rG   )r?   r   r   s      r/   r   Numbers.ratio_covered[  s5     OOd&>&>>	''$//9%%rU   c                |   [        U R                  U R                  UR                  -   U R                  UR                  -   U R                  UR                  -   U R
                  UR
                  -   U R                  UR                  -   U R                  UR                  -   U R                  UR                  -   5      $ r:   )	rP   r   rC   rD   rE   rF   rG   rH   rI   r?   others     r/   __add__Numbers.__add__b  s    NNLL5==( 2 22OOe...NNU__,OOe...##e&>&>>##e&>&>>	
 		
rU   c                    US:X  d   eU $ )Nr   rh   r   s     r/   __radd__Numbers.__radd__n  s    zzrU   rh   Nr   )r}   float)r}   r4   )r}   ztuple[int, int])r   rP   r}   rP   )r   r3   r}   rP   )r   r   r   r   r   r   r   rC   rD   rE   rF   rG   rH   rI   propertyr   r   r   r   r   r   r   r   rh   rU   r/   rP   rP   *  s     IsGSL#JIsJ2 2 9 9   @ @ & &

rU   rP   c                    SSU-  -  nSU s=:  a  U:  a  O  OUn O$SU-
  U s=:  a  S:  a	  O  OSU-
  n O[        X5      n U SU S3 $ )zReturn a displayable total percentage, as a string.

Note that "0" is only returned when the value is truly zero, and "100"
is only returned when the value is truly 100.  Rounding can never
result in either "0" or "100".

g      ?
   r   r   d   .f)round)pcr   near0s      r/   r   r   t  sY     "i-E2~~
%-2	#	#U]2!9+Q rU   c                   [        U 5      n [        U5      n/ nSnSnU  HL  nU[        U5      :  a    O<XQU   :X  a  US-  nU(       d  UnUnM.  U(       d  M7  UR                  UW45        SnMN     U(       a  UR                  UW45        U$ )z,Produce a list of ranges for `format_lines`.Nr   r   )rJ   r$   rn   )r   r   pairsstartlidxstmtends          r/   _line_rangesr     s    
 
#J5MEE ED3u:;AIDCULL%&E  eS\"LrU   c                V   [        X5       Vs/ s H  o3S   [        U5      4PM     nnUbW  [        U5      nU HF  u  pg[        U5       H2  nXa;  d  M
  X;  d  M  US:  a  UOSn	UR                  Xf SU	 345        M4     MH     SR	                  S [        U5       5       5      n
U
$ s  snf )a  Nicely format a list of line numbers.

Format a list of line numbers for printing by coalescing groups of lines as
long as the lines represent consecutive statements.  This will coalesce
even if there are gaps between statements.

For example, if `statements` is [1,2,3,4,5,10,11,12,13,14] and
`lines` is [1,2,5,10,11,13,14] then the result will be "1-2, 5-11, 13-14".

Both `lines` and `statements` can be any iterable. All of the elements of
`lines` must be in `statements`, and all of the values must be positive
integers.

If `arcs` is provided, they are (start,[end,end,end]) pairs that will be
included in the output as long as start isn't in `lines`.

r   exitz->z, c              3  *   #    U  H	  oS    v   M     g7f)Nrh   )r<   ts     r/   r@   format_lines.<locals>.<genexpr>  s     6#5abE#5s   )r   r   rJ   rn   join)r   r   r   pair
line_items
line_exitsr   rz   exdestrets              r/   rW   rW     s    , :Fj9XY9X7IdO,9XJYD\
%KDUm$!#a2VD%%tvRv->&?@ $ & ))66*#56
6CJ Zs   B&c                x    SUs=::  a  S::  d  O  SU S3n[        U5      eUS:X  a  U S:w  a  g[        X5      U:  $ )a  Determine if a total should fail due to fail-under.

`total` is a float, the coverage measurement total. `fail_under` is the
fail_under setting to compare with. `precision` is the number of digits
to consider after the decimal point.

Returns True if the total should fail.

r   r   zfail_under=z' is invalid. Must be between 0 and 100.T)r   r   )total
fail_underr   msgs       r/   should_fail_underr     sN     $u$J<'NO# Uu~"Z//rU   )
r'   r
   r   r3   r(   r   r   r4   r}   r   )r   r   r   r3   r}   r4   )r   Iterable[TLineNo]r   r   r}   zlist[tuple[TLineNo, TLineNo]]r:   )r   r   r   r   r   z.Iterable[tuple[TLineNo, list[TLineNo]]] | Noner}   r4   )r   r   r   r   r   r3   r}   r5   )r   
__future__r   r   dataclassescollections.abcr   typingr   coverage.exceptionsr   coverage.miscr   coverage.typesr   r	   coverage.datar
   coverage.pluginr   r0   	dataclassr   r   TRegionLinesr   rP   r   r   rW   r   rh   rU   r/   <module>r      s   ' "   $   + # (*,4
44  4 	4
 4n w w wt !\
 \
~ F F FR!$! #< <@ !   9  		 F0rU   