
    zi                    F   d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZmZ ddlmZ ddlmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZmZ ddl m!Z! ddl"m#Z#m$Z$  ee          Z G d d          Z% edd           G d d                      Z& G d de          Z'e(e#e)e*ee+         ee+         f                  f         Z, G d d          Z- G d de-          Z. G d de-          Z/ G d de-          Z0d%d"Z1 G d# d$          Z2dS )&zCode parsing for coverage.py.    )annotationsN)CallableIterableSequence)	dataclass)OptionalProtocolcast)env)
ByteParser)short_stack)NoSource	NotPython)isolate_module	nice_pair)generate_tokens)TArcTLineNoc                      e Zd ZdZ	 	 	 d)d*d	Zd+dZd,dZ ej        d          d-d            Z	d.dZ
d/dZd0dZd,dZd1dZd,dZd0d Zej        d2d"            Zd3d%Zd4d'Zd4d(ZdS )5PythonParserzParse code to find executable lines, excluded lines, etc.

    This information is all based on static analysis: no code execution is
    involved.

    Ntext
str | NonefilenameexcludereturnNonec                   |s|s
J d            |pd| _         ||| _        nJddlm} 	  || j                   | _        n-# t          $ r }t          d| j          d|           |d}~ww xY w|| _        d| _        t                      | _	        t                      | _
        t                      | _        t                      | _        t                      | _        d| _        i | _        d| _        d| _        i | _        dS )	z
        Source can be provided as `text`, the text itself, or `filename`, from
        which the text will be read.  Excluded lines are those that match
        `exclude`, a regex string.

        z*PythonParser needs either text or filenamez<code>Nr   )get_python_sourcezNo source for code: 'z': F)r   r   coverage.pythonr   OSErrorr   r   	_ast_rootset
statementsexcludedraw_statementsraw_excludedraw_docstringsshow_tokensmultiline_map	_all_arcs_missing_arc_fragments_with_jump_fixers)selfr   r   r   r   errs         Z/var/www/tmov.alphamb/tmov_inventario/venv/lib/python3.11/site-packages/coverage/parser.py__init__zPythonParser.__init__&   s7    MxMM!MMMM ,H!DII999999Y--dm<<		 Y Y YNt}NNNNOOUXXY  *.
 ), '*ee -0EE +.%% -0EE ! 68 ,0<@#@Bs   ? 
A)	A$$A)regexstrset[TLineNo]c           	         t                      }d}d}t          j        | j        t          j                  D ]}|                                \  }}| j                            d||          z   }| j                            d||          z   }	|                     fdt          |dz   |	dz             D                        |}|}|S )zFind the lines matching a regex.

        Returns a set of line numbers, the lines that contain a match for
        `regex`. The entire line needn't match, just a part of it.
        Handles multiline regex patterns.

        r   )flags
c              3  N   K   | ]}j                             ||          V   d S Nr)   get).0ir-   s     r/   	<genexpr>z.PythonParser.lines_matching.<locals>.<genexpr>u   sG        12"&&q!,,               )	r"   refinditerr   	MULTILINEspancountupdaterange)
r-   r1   matches
last_startlast_start_linematchstartend
start_lineend_lines
   `         r/   lines_matchingzPythonParser.lines_matchinge   s     !$
[	FFF 	) 	)EJE3(49??4U+S+SSJ&z3)O)OOHNN    6;JNHWXL6Y6Y      J(OOr>   c           
        | j         r8|                     | j                   | _        t          | j                  | _        d}d}d}d}d}d}| j        J t          | j                  }|D ]\  }}	\  }
}\  }}}| j        rJt          t          j
                            ||          ddt          |
|f          dd|	dd|           |t          j        k    r|d	z  }n|t          j        k    r|d	z  }n|t          j        k    rn|	d
k    rT|dk    rN| j                            t%          ||d	z                       }|s |r| j                            |           |}d}nN|	dv r|d	z  }nD|	dv r|d	z  }n:|t          j        k    r*|r&||k    r t%          ||d	z             D ]}|| j        |<   d}|	                                r<|t          j        k    r,d}|s(|
}|r||k    rd}|r| j                            |           |sGt1          | j        | j                  }| j                            |                                           |                     | j                  | _        | j        J t?          j         | j                  D ]}tC          |t>          j"        t>          j#        t>          j$        t>          j%        f          r|j&        r|j&        d         }tC          |t>          j'                  rtC          |j(        t>          j)                  rgtC          |j(        j(        tT                    rH| j+                            t%          |j,        t[          t\          |j/                  d	z                        tC          |t>          j"        t>          j#        t>          j$        f          rta          d |j1        D             |j,                  }| j                            t%          ||j,        d	z                       rC| j                            t%          |t[          t\          |j/                  d	z                        dS )zwParse the source to find the interesting facts about its lines.

        A handful of attributes are updated.

        r   FTNz>10 z>520r?   :z([{z)]})r   r   c              3  $   K   | ]}|j         V  d S r8   lineno)r;   ds     r/   r=   z*PythonParser._raw_parse.<locals>.<genexpr>   s$      !H!Hq!(!H!H!H!H!H!Hr>   )default)2r   rP   r&   r"   r$   r   r   r(   printtokenizetok_namer:   r   tokenINDENTDEDENTOPintersectionrG   addNEWLINEr)   stripCOMMENTr   r   r%   rF   find_statementsfirst_linesr!   astwalk
isinstanceClassDefFunctionDefAsyncFunctionDefModulebodyExprvalueConstantr2   r'   rW   r
   int
end_linenomindecorator_list)r-   indentexclude_indent	excluding
first_lineemptynestingtokgentoktypettextslineno_elinenoltextshould_excludelbyte_parsernodefirsts                      r/   
_raw_parsezPythonParser._raw_parse|   s    < 	3 $ 3 3DL A AD 122DM 	
y$$$ ++AG 0	3 0	3=GULWa,7A 	 !)--gw?????!7G"455555   %,&&!EL((!EH$$C<<GqLL%)]%?%?jRY\]R]@^@^%_%_N$ ) ) ))'222)/$(	e^^qLGGe^^qLGEM)) ;'Z"7"7 #:w{;; ; ;0:*1--
{{}} 
3H,<!<!<! 3!(J  *V~%=%=$)	  3))'222  	F$$)dmLLLK&&{'B'B'D'DEEE((77 ~)))HT^,, 	\ 	\D$s@TVYV` abb 
9 	 IaLE"5#(33&u{CLAA 'u{'8#>>
 +22!%,S%:J0K0Ka0OPP  
 $s@T UVV \ !H!HD4G!H!H!HRVR]^^^
=--eJa.P.PQQ \M((z4T_;U;UXY;Y)Z)Z[[[%	\ 	\r>   i  )maxsizerW   r   c                    |dk     r| j                             | |            }n| j                             ||          }|S )zAReturn the first line number of the statement including `lineno`.r   r9   )r-   rW   s     r/   rz   zPythonParser.first_line   sK     A::(,,fWvg>>>FF'++FF;;Fr>   linenosIterable[TLineNo]c                       fd|D             S )zMap the line numbers in `linenos` to the correct first line of the
        statement.

        Returns a set of the first lines.

        c                :    h | ]}                     |          S  rz   )r;   r   r-   s     r/   	<setcomp>z+PythonParser.first_lines.<locals>.<setcomp>   s%    444q""444r>   r   )r-   r   s   ` r/   rg   zPythonParser.first_lines   s     5444G4444r>   linesc                ,    |                      |          S )z)Implement `FileReporter.translate_lines`.)rg   )r-   r   s     r/   translate_lineszPythonParser.translate_lines   s    &&&r>   arcsIterable[TArc]	set[TArc]c                F      fd                      |          D             S )z(Implement `FileReporter.translate_arcs`.c                j    h | ]/\  }}                     |                               |          f0S r   r   )r;   abr-   s      r/   r   z.PythonParser.translate_arcs.<locals>.<setcomp>   s:    aaaVa##T__Q%7%78aaar>   )fix_with_jumps)r-   r   s   ` r/   translate_arcszPythonParser.translate_arcs   s,    aaaatGZGZ[_G`G`aaaar>   c                   	 t          j        | j                  | _        |                                  n{# t
          j        t          t          f$ r\}t          |d          r|j
        }n|j        d         d         }t          d| j         d|j        d         d| z             |d}~ww xY w| j        | j        z  }| j        |z
  }|                     |          |z
  | _        dS )zParse source text to find executable lines, excluded lines, etc.

        Sets the .excluded and .statements attributes, normalized to the first
        line of multi-line statements.

        rW   r?   r   zCouldn't parse 'z' as Python source: z	 at line N)rh   parser   r!   r   r[   
TokenErrorIndentationErrorSyntaxErrorhasattrrW   argsr   r   r$   r'   r%   rg   r#   )r-   r.   rW   ignorestartss        r/   parse_sourcezPythonParser.parse_source   s    	 Yty11DNOO#%5{C 	 	 	sH%% (!QF4=FFFXa[55V556  	 !44$v-**622V;s   25 B-AB((B-c                X    | j         |                                  | j         J | j         S )zGet information about the arcs available in the code.

        Returns a set of line number pairs.  Line numbers have been normalized
        to the first line of multi-line statements.

        )r*   _analyze_astr-   s    r/   r   zPythonParser.arcs  s4     >!~)))~r>   c                   | j         J t          | j        | j         | j        | j                  }|                                 |j        }|                                | _        | j        r| 	                    |          }t                      | _        |D ]Q\  }}|                     |          }|                     |          }||k    r| j                            ||f           R|j        | _        dS )zkRun the AstArcAnalyzer and save its results.

        `_all_arcs` is the set of arcs in the code.

        N)r!   AstArcAnalyzerr   r%   r)   analyzer   with_jump_fixersr,   r   r"   r*   rz   rb   missing_arc_fragmentsr+   )r-   aaar   l1l2fl1fl2s          r/   r   zPythonParser._analyze_ast$  s     ~)))T]DND<OQUQcddx!$!5!5!7!7! 	-&&t,,D 	/ 	/FB//"%%C//"%%Cczz""C:...&)&?###r>   c                   t                      }t                      }|D ]}|| j        v r|d         }|                    |           | j        |         \  }}|| j        v rC|                    |           | j        |         \  }}|                    |           || j        v C|                    ||d         f           |                    |           t          |          |z  |z
  }|S )a  Adjust arcs to fix jumps leaving `with` statements.

        Consider this code:

            with open("/tmp/test", "w") as f1:
                a = 2
                b = 3
            print(4)

        In 3.10+, we get traces for lines 1, 2, 3, 1, 4.  But we want to present
        it to the user as if it had been 1, 2, 3, 4.  The arc 3->1 should be
        replaced with 3->4, and 1->4 should be removed.

        For this code, the fixers dict is {(3, 1): ((1, 4), (3, 4))}.  The key
        is the actual measured arc from the end of the with block back to the
        start of the with-statement.  The values are start_next (the with
        statement to the next statement after the with), and end_next (the end
        of the with-statement to the next statement after the with).

        With nested with-statements, we have to trace through a few levels to
        correct a longer chain of arcs.

        r   r?   )r"   r,   rb   )r-   r   	to_removeto_addarcend0
start_nextend_nexts           r/   r   zPythonParser.fix_with_jumps;  s    0 EE	 
	* 
	*Cd,,,1vc"""'+'=c'B$
H D$:::MM*---+/+A*+M(JMM(+++ !D$::: 

D(1+.///j)))D		F"i/r>   dict[TLineNo, int]c                    t          j        t                    }|                                 D ]D\  }}|dk    sJ d|d| j                     || j        v r*|| j        v r4||xx         dz  cc<   E|S )zYGet a count of exits from that each line.

        Excluded lines are excluded.

        r   zl1=z  should be greater than zero in r?   )collectionsdefaultdictrs   r   r   r$   )r-   exit_countsr   r   s       r/   r   zPythonParser.exit_countsc  s     +6*A#*F*Fiikk 	! 	!FB666RbRR4=RR666T]""T]""OOOq OOOOr>   
action_msgrM   c                L    ||dk     rd}nd}|                     |          }|S )z=Apply some defaulting and formatting to an arc's description.Nr   zjump to the function exitzjump to line {lineno}rV   )format)r-   r   rM   s      r/   _finish_action_msgzPythonParser._finish_action_msgw  s9    Qww8

4
&&c&22
r>   rL   c                f   | j         |                                  | j         J | j                             ||fdg          }g }|D ]V\  }}|                     ||          }d| d| }||d|                    |           z  }|                    |           Wd                    |          S )z5Provide an English sentence describing a missing arc.NNNzline z didn't z	 because rV   z or )r+   r   r:   r   r   appendjoin)r-   rL   rM   fragment_pairsmsgsmissing_cause_msgr   msgs           r/   missing_arc_descriptionz$PythonParser.missing_arc_description  s    &..:::488%~VV-; 	 	)z00SAAJ5%5555C ,K#4#;#;5#;#I#IKKKKK{{4   r>   c                    | j         |                                  | j         J | j                             ||fdg          }|                     |d         d         |          }|S )z2Provide an English description of an arc's effect.Nr   r   r?   )r+   r   r:   r   )r-   rL   rM   r   r   s        r/   arc_descriptionzPythonParser.arc_description  so    &..:::488%~VV,,^A->q-A3GG
r>   )NNN)r   r   r   r   r   r   r   r   )r1   r2   r   r3   r   r   )rW   r   r   r   )r   r   r   r3   )r   r   r   r3   )r   r   r   r   )r   r   )r   r   )r   r   rM   r   r   r2   )rL   r   rM   r   r   r2   )__name__
__module____qualname____doc__r0   rP   r   	functools	lru_cacherz   rg   r   r   r   r   r   r   r   r   r   r   r   r>   r/   r   r      s          #"	=C =C =C =C =C~   .h\ h\ h\ h\T Y&&&   '&5 5 5 5' ' ' 'b b b b< < < <0
 
 
 
@ @ @ @.& & & &P    &   ! ! ! !&     r>   r   T)frozenorderc                  ,    e Zd ZU dZded<   dZded<   dS )ArcStarta?  The information needed to start an arc.

    `lineno` is the line number the arc starts from.

    `cause` is an English text fragment used as the `missing_cause_msg` for
    AstArcAnalyzer.missing_arc_fragments.  It will be used to describe why an
    arc wasn't executed, so should fit well into a sentence of the form,
    "Line 17 didn't run because {cause}."  The fragment can include "{lineno}"
    to have `lineno` interpolated into it.

    As an example, this code::

        if something(x):        # line 1
            func(x)             # line 2
        more_stuff()            # line 3

    would have two ArcStarts:

    - ArcStart(1, "the condition on line 1 was always true")
    - ArcStart(1, "the condition on line 1 was never true")

    The first would be used to create an arc from 1 to 3, creating a message like
    "line 1 didn't jump to line 3 because the condition on line 1 was always true."

    The second would be used for the arc from 1 to 2, creating a message like
    "line 1 didn't jump to line 2 because the condition on line 1 was never true."

    r   rW    r2   causeN)r   r   r   r   __annotations__r   r   r>   r/   r   r     s2          : OOOEOOOOOOr>   r   c                       e Zd ZdZ	 	 dddZdS )	TAddArcFnz&The type for AstArcAnalyzer.add_arc().NrL   r   rM   r   r   r   r   r   c                    dS )ab  
        Record an arc from `start` to `end`.

        `missing_cause_msg` is a description of the reason the arc wasn't
        taken if it wasn't taken.  For example, "the condition on line 10 was
        never true."

        `action_msg` is a description of what the arc does, like "jump to line
        10" or "exit from function 'fooey'."

        Nr   r-   rL   rM   r   r   s        r/   __call__zTAddArcFn.__call__  s      r>   r   
rL   r   rM   r   r   r   r   r   r   r   )r   r   r   r   r   r   r>   r/   r   r     s;        00 )-!%      r>   r   c                  2    e Zd ZdZddZdd	Zdd
ZddZdS )Blocka;  
    Blocks need to handle various exiting statements in their own ways.

    All of these methods take a list of exits, and a callable `add_arc`
    function that they can use to add arcs if needed.  They return True if the
    exits are handled, or False if the search should continue up the block
    stack.
    exitsset[ArcStart]add_arcr   r   boolc                    dS )zProcess break exits.Fr   r-   r   r   s      r/   process_break_exitszBlock.process_break_exits      ur>   c                    dS )zProcess continue exits.Fr   r   s      r/   process_continue_exitszBlock.process_continue_exits  r   r>   c                    dS )zProcess raise exits.Fr   r   s      r/   process_raise_exitszBlock.process_raise_exits  r   r>   c                    dS )zProcess return exits.Fr   r   s      r/   process_return_exitszBlock.process_return_exits  r   r>   Nr   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r>   r/   r   r     sn                       r>   r   c                  *    e Zd ZdZddZddZddZdS )	LoopBlockz@A block on the block stack representing a `for` or `while` loop.rL   r   r   r   c                :    || _         t                      | _        d S r8   )rL   r"   break_exits)r-   rL   s     r/   r0   zLoopBlock.__init__   s    
*-%%r>   r   r   r   r   r   c                :    | j                             |           dS NT)r   rF   r   s      r/   r   zLoopBlock.process_break_exits  s    &&&tr>   c                H    |D ]} ||j         | j        |j                   dS r   )rW   rL   r   r-   r   r   xits       r/   r   z LoopBlock.process_continue_exits
  s3     	7 	7CGCJ
CI6666tr>   N)rL   r   r   r   r   )r   r   r   r   r0   r   r   r   r>   r/   r   r     sV        JJ0 0 0 0        r>   r   c                  *    e Zd ZdZddZddZddZdS )FunctionBlockz>A block on the block stack representing a function definition.rL   r   namer2   r   r   c                "    || _         || _        d S r8   rL   r  )r-   rL   r  s      r/   r0   zFunctionBlock.__init__  s    
			r>   r   r   r   r   r   c                \    |D ](} ||j         | j         |j        d| j                   )dS )Nzexcept from function TrW   rL   r   r  r   s       r/   r   z!FunctionBlock.process_raise_exits  O     	 	CG
	5	55	    tr>   c                \    |D ](} ||j         | j         |j        d| j                   )dS )Nzreturn from function Tr  r   s       r/   r   z"FunctionBlock.process_return_exits#  r  r>   N)rL   r   r  r2   r   r   r   )r   r   r   r   r0   r   r   r   r>   r/   r   r     sV        HH           r>   r   c                  "    e Zd ZdZddZddZdS )TryBlockz6A block on the block stack representing a `try` block.handler_startTLineNo | Nonefinal_startr   r   c                "    || _         || _        d S r8   )r
  r  )r-   r
  r  s      r/   r0   zTryBlock.__init__1  s    *&r>   r   r   r   r   r   c                V    | j         !|D ]} ||j        | j         |j                   dS r   )r
  rW   r   r   s       r/   r   zTryBlock.process_raise_exits7  s?    ) C C
D$6	BBBBtr>   N)r
  r  r  r  r   r   r   )r   r   r   r   r0   r   r   r>   r/   r	  r	  .  sB        @@' ' ' '     r>   r	  r   ast.ASTr   tuple[bool, bool]c                j   | xt           j        d x\    dt          | j                  fS  xt           j        d x#\    | j        dv rdt          | j                  fS n xt           j        d x?\    t          | j	        t           j
                  rt          | j                  \  }}|| fS n t           j        d xs\   d | j        D             }t          d |D                       }|rDt          | j	        t           j                  rt"          nt          }d |d |D                       fS n dS )	zIs this a compile-time constant test expression?

    We don't try to mimic all of CPython's optimizations.  We just have to
    handle the kinds of constant expressions people might actually use.

    r   NT)TrueFalser   	__debug__c                ,    g | ]}t          |          S r   )is_constant_test_expr)r;   vs     r/   
<listcomp>z)is_constant_test_expr.<locals>.<listcomp>S  s!    BBB)!,,BBBr>   c              3      K   | ]	\  }}|V  
d S r8   r   )r;   is_constr   s      r/   r=   z(is_constant_test_expr.<locals>.<genexpr>T  s&      ??;8Qh??????r>   c              3      K   | ]	\  }}|V  
d S r8   r   )r;   r   r  s      r/   r=   z(is_constant_test_expr.<locals>.<genexpr>W  s&      33da333333r>   )FF)rh   rr   r   rq   NameidevalUnaryOprj   opNotr  operandBoolOpvaluesallOrany)r   is_constantvalretsr   s        r/   r  r  A  s]    S\^^^^^^dj)))) SXZZZZZZw@@@T$']]***  S[]]]]]]$'37++ ,#8#F#F S"G+++  Z\\\\\BBdkBBBD??$?????K 4&tw77@SSSRR33d33333333  <r>   c                  F   e Zd ZdZdNdZdOdZdPdZdQdZdRdZeZ	dSdZ
	 	 dTdUdZdVd ZdWd!ZdXd"ZdYd$ZeZdZd&ZeZeZd[d(Zd\d)Zh d*Zd]d,Z	 	 dTd^d3Zd_d5Zd_d6Zd_d7Zd_d8Zd`d:Zdad;ZeZdbd=Z dcd?Z!e!Z"eZ#eZ$dddAZ%dedCZ&dfdEZ'dgdGZ(dhdIZ)e)Z*didKZ+djdMZ,e,Z-dS )kr   a  Analyze source text with an AST to find executable code paths.

    The .analyze() method does the work, and populates these attributes:

    `arcs`: a set of (from, to) pairs of the the arcs possible in the code.

    `missing_arc_fragments`: a dict mapping (from, to) arcs to lists of
    message fragments explaining why the arc is missing from execution::

        { (start, end): [(missing_cause_msg, action_msg), ...], }

    For an arc starting from line 17, they should be usable to form complete
    sentences like: "Line 17 didn't {action_msg} because {missing_cause_msg}".

    NOTE: Starting in July 2024, I've been whittling this down to only report
    arc that are part of true branches.  It's not clear how far this work will
    go.

    r   r2   	root_noder  r#   r3   	multilinedict[TLineNo, TLineNo]r   r   c                   || _         || _        fd|D             | _        | _        t	          t          t          j        dd                              }|rWt          d| j                    t          d| j                    t          t          j
        | j        dd                     t                      | _        t          j        t                    | _        g | _        t                      | _        t                      | _        t                      | _        t                      | _        t	          t          t          j        d	d                              | _        d S )
Nc                <    h | ]}                     ||          S r   )r:   )r;   r   r-  s     r/   r   z*AstArcAnalyzer.__init__.<locals>.<setcomp>y  s'    CCC19==A..CCCr>   COVERAGE_AST_DUMP0zStatements: zMultiline map: T   )include_attributesrw   COVERAGE_TRACK_ARCS)r   r,  r#   r-  r   rs   osgetenvrZ   rh   dumpr"   r   r   r   listr   block_stackcurrent_with_startsall_with_startswith_entries
with_exitsdebug)r-   r   r,  r#   r-  dump_asts       ` r/   r0   zAstArcAnalyzer.__init__p  s6    !"CCCC
CCC" BI&93??@@AA 	O2223334DN44555#(4>d1MMMNNN"uu	4?4KD4Q4Q"(* 25 -0UU'*uu%(UU #bi(=sCCDDEE


r>   c                    t          j        | j                  D ]/}|j        j        }t          | d| d          }| ||           0dS )zFExamine the AST tree from `self.root_node` to determine possible arcs._code_object__N)rh   ri   r,  	__class__r   getattr)r-   r   	node_namecode_object_handlers       r/   r   zAstArcAnalyzer.analyze  sd    HT^,, 	* 	*D/I")$0L0L0Ld"S"S".##D)))		* 	*r>   dict[TArc, tuple[TArc, TArc]]c                "    i } fd j         D             } j        D ]ofd|D             }|st          |          dk    sJ d| d            |                                }fd j        D             }|D ]}|f||ff||f<   p|S )aK  Get a dict with data for fixing jumps out of with statements.

        Returns a dict.  The keys are arcs leaving a with-statement by jumping
        back to its start.  The values are pairs: first, the arc from the start
        to the next statement, then the arc that exits the with without going
        to the start.

        c                D    h | ]}|d          j         v |j        v|S )r   )r<  r=  )r;   r   r-   s     r/   r   z2AstArcAnalyzer.with_jump_fixers.<locals>.<setcomp>  sB     
 
 
1v---#T=N2N2N 2N2N2Nr>   c                8    h | ]}|d          k    |d         S )r   r?   r   r;   r   rL   s     r/   r   z2AstArcAnalyzer.with_jump_fixers.<locals>.<setcomp>  s&    EEESVu__SV___r>   r?   zExpected one arc, got z with start = c                8    h | ]}|d          k    |d         S )r?   r   r   rK  s     r/   r   z2AstArcAnalyzer.with_jump_fixers.<locals>.<setcomp>  s&    IIIsQ5CFr>   )r   r<  lenpopr>  )r-   fixers
with_nextsnextsnxtendsrM   rL   s   `      @r/   r   zAstArcAnalyzer.with_jump_fixers  s     
 
 
 
y
 
 


 ) 	B 	BEEEEEzEEEE u::???$TU$T$T%$T$T???))++CIIIIdoIIID B B).sCj'AU|$$Br>   r   
ast.Modulec                    |                      |          }|j        rD|                     |j                  }|D ]%}|                     |j        | |j        d           &d S |                     ||            d S )Nzexit the module)line_for_nodero   process_bodyr   rW   r   r-   r   rL   r   r   s        r/   _code_object__Modulez#AstArcAnalyzer._code_object__Module  s    ""4((9 	(%%di00E O OSZ%<MNNNNO O LL'''''r>   ast.FunctionDefc                   |                      |          }| j                            t          ||j                             |                     |j                  }|                     |           | j                                         d S )Nr  )	rV  r:  r   r   r  rW  ro   r   rN  )r-   r   rL   r   s       r/   _code_object__FunctionDefz(AstArcAnalyzer._code_object__FunctionDef  s    ""4((E	 J J JKKK!!$),,!!%(((r>   ast.ClassDefc                    |                      |          }|                     |j                  }|D ]-}|                     |j        | |j        d|j                   .d S )Nzexit class )rV  rW  ro   r   rW   r   r  rX  s        r/   _code_object__ClassDefz%AstArcAnalyzer._code_object__ClassDef  ss    ""4((!!$),, 	U 	UCLLeVSY8Sdi8S8STTTT	U 	Ur>   NrL   r   rM   r   r   r   c           
     Z   | j         r8t          d| d| d|d|           t          t                      d           | j                            ||f           || j        v r| j                            ||f           ||&| j        ||f                             ||f           dS dS )z@Add an arc, including message fragments to use if it is missing.zAdding possible arc: (z, z): z

)rM   N)	r?  rZ   r   r   rb   r;  r=  r   r   r   s        r/   r   zAstArcAnalyzer.add_arc  s     : 	-a5aaCaa<MaaS]aabbb+--V,,,,	ucl###D,,,!!5#,///(J,B&s|4;;=NPZ<[\\\\\ -C,Br>   Iterable[Block]c                *    t          | j                  S )z.Yield the blocks in nearest-to-farthest order.)reversedr:  r   s    r/   nearest_blockszAstArcAnalyzer.nearest_blocks  s    ()))r>   c                   |j         j        }t          t          t          t
          j        gt          f                  t          | d| d                    }| ||          }n|j	        }| j
                            ||          S )z}What is the right line number to use for this node?

        This dispatches to _line__Node functions where needed.

        _line__N)rC  r   r
   r   r   rh   ASTr   rD  rW   r-  r:   )r-   r   rE  handlerlines        r/   rV  zAstArcAnalyzer.line_for_node  s     N+	Xswi012D/I//66
 
 74==DD;D~!!$---r>   c                H    |j         r|j         d         j        }n|j        }|S )zSCompute first line number for things that can be decorated (classes and functions).r   )rv   rW   )r-   r   rW   s      r/   _line_decoratedzAstArcAnalyzer._line_decorated  s+     	!(+2FF[Fr>   
ast.Assignc                6    |                      |j                  S r8   )rV  rq   r-   r   s     r/   _line__AssignzAstArcAnalyzer._line__Assign
  s    !!$*---r>   ast.Dictc                    |j         r1|j         d         |j         d         j        S |j        d         j        S |j        S Nr   )keysrW   r$  rn  s     r/   _line__DictzAstArcAnalyzer._line__Dict  s@    9 	y|'y|** {1~,,;r>   ast.Listc                ^    |j         r |                     |j         d                   S |j        S rr  )eltsrV  rW   rn  s     r/   _line__ListzAstArcAnalyzer._line__List  s.    9 	%%dil333;r>   c                    dS )Nr?   r   rn  s     r/   _line__ModulezAstArcAnalyzer._line__Module#  s    qr>   >   rp   PassAssertAssignDeleteGlobalImportNonlocal	AnnAssign	AugAssign
ImportFromr   c                x   |j         j        }t          t          t          t
          j        gt          t                   f                  t          | d| d                    }| ||          }nJt          j        r|| j        vrt          d|           t          |                     |                    h}|S )a  Find the set of arc starts that exit this node.

        Return a set of ArcStarts, exits from this node to the next. Because a
        node represents an entire sub-tree (including its children), the exits
        from a node can be arbitrarily complex::

            if something(1):
                if other(2):
                    doit(3)
                else:
                    doit(5)

        There are three exits from line 1: they start at lines 1, 3 and 5.
        There are two exits from line 2: lines 3 and 5.

        	_handle__Nz*** Unhandled: )rC  r   r
   r   r   rh   rg  r"   r   rD  r   TESTINGOK_TO_DEFAULTRuntimeErrorrV  )r-   r   rE  rh  
arc_startss        r/   
node_exitszAstArcAnalyzer.node_exits5  s    " N+	XswiX678D1i11488
 
  JJ { AD$666&'?'?'?@@@ #4#5#5d#;#;<<=Jr>   ro   Sequence[ast.AST]
from_startArcStart | Noneprev_startsset[ArcStart] | Nonec                    ||t                      }n|h}n|J |D ]\}|                     |          }|| j        vr!|D ]#}|                     |j        ||j                   $|                     |          }]|S )a  Process the body of a compound statement.

        `body` is the body node to process.

        `from_start` is a single `ArcStart` that starts an arc into this body.
        `prev_starts` is a set of ArcStarts that can all be the start of arcs
        into this body.  Only one of `from_start` and `prev_starts` should be
        given.

        Records arcs within the body by calling `self.add_arc`.

        Returns a set of ArcStarts, the exits from this body.

        )r"   rV  r#   r   rW   r   r  )r-   ro   r  r  	body_noderW   
prev_starts          r/   rW  zAstArcAnalyzer.process_bodyX  s    ( !!ee)l%%%  	5 	5I''	22FT_,,) J J
Z.
8HIIII//)44KKr>   r   c                p    |                                  D ] }|                    || j                  r dS !dS )z0Add arcs due to jumps from `exits` being breaks.N)rd  r   r   r-   r   blocks      r/   r   z"AstArcAnalyzer.process_break_exits  M    ((** 	 	E((== 	 	r>   c                p    |                                  D ] }|                    || j                  r dS !dS )z3Add arcs due to jumps from `exits` being continues.N)rd  r   r   r  s      r/   r   z%AstArcAnalyzer.process_continue_exits  sM    ((** 	 	E++E4<@@ 	 	r>   c                p    |                                  D ] }|                    || j                  r dS !dS )z0Add arcs due to jumps from `exits` being raises.N)rd  r   r   r  s      r/   r   z"AstArcAnalyzer.process_raise_exits  r  r>   c                p    |                                  D ] }|                    || j                  r dS !dS )z1Add arcs due to jumps from `exits` being returns.N)rd  r   r   r  s      r/   r   z#AstArcAnalyzer.process_return_exits  sM    ((** 	 	E))%>> 	 	r>   	ast.Breakc                    |                      |          }t          |d          }|                     |h           t                      S )Nz*the break on line {lineno} wasn't executedr   )rV  r   r   r"   )r-   r   herebreak_starts       r/   _handle__BreakzAstArcAnalyzer._handle__Break  sG    !!$''t+WXXX  +///uur>   c                Z   |j         }|j         }|j        }|rd}|D ]7}|                     |          }|||k    r|                     ||           |}8|J |                     ||           |}|j        s"J d|j        d| j         d|j                      |J t          |          hS )zBAdd arcs for things that can be decorated (classes and functions).NzOops: node.body = z in @)rW   rv   rV  r   ro   r   r   )r-   r   	main_linelastdecsdec_node	dec_starts          r/   _handle_decoratedz AstArcAnalyzer._handle_decorated  s    ![	#{" 	WD  ! ! ..x88	#	T(9(9LLy111 ###LLy)))D
 9VVVtyVVVVVVVVVr>   ast.Continuec                    |                      |          }t          |d          }|                     |h           t                      S )Nz-the continue on line {lineno} wasn't executedr  )rV  r   r   r"   )r-   r   r  continue_starts       r/   _handle__Continuez AstArcAnalyzer._handle__Continue  sH    !!$''!$.]^^^##^$4555uur>   ast.Forc                <   |                      |j                  }| j                            t	          |                     t          |d          }|                     |j        |          }|D ]#}|                     |j	        ||j
                   $| j                                        }t          |t                    sJ |j        }t          |d          }|j        r"|                     |j        |          }||z  }n|                    |           |S )NrL   z'the loop on line {lineno} never startedr  r  z)the loop on line {lineno} didn't complete)rV  iterr:  r   r   r   rW  ro   r   rW   r   rN  rj   r   orelserb   )r-   r   rL   r  r   r   my_block
else_exitss           r/   _handle__ForzAstArcAnalyzer._handle__For  s    ""49--	 6 6 6777e+TUUU
!!$)
!CC 	7 	7CLLUCI6666#''))(I.....$e+VWWW
; 	"**4;:*NNJZEE IIj!!!r>   ast.Ifc                T   |                      |j                  }t          |j                  \  }}t                      }|r|r0t	          |d          }||                     |j        |          z  }|r|s0t	          |d          }||                     |j        |          z  }|S )N-the condition on line {lineno} was never truer  r  .the condition on line {lineno} was always true)rV  testr  r"   r   rW  ro   r  )r-   r   rL   constant_testr)  r   r  s          r/   _handle__IfzAstArcAnalyzer._handle__If  s    ""49--249==s 	I 	I!%/^___JT&&tyZ&HHHE 	KC 	K!%/_```JT&&t{z&JJJEr>   	ast.Matchc                   |                      |          }|}t                      }|j        D ]e}|                      |j                  }|                     ||d           t          |d          }||                     |j        |          z  }|}f|j        }t          |t          j
                  r'|j        d         }t          |t          j
                  't          |t          j                  r/|j        (|j        }t          |t          j                  r|j        (t          |t          j                  o|j        d u o|j        d u }	|	s$|                    t          |d                     |S )Nz+the pattern on line {lineno} always matchedz*the pattern on line {lineno} never matchedr  r  )rV  r"   casespatternr   r   rW  ro   rj   rh   MatchOrpatternsMatchAsguardrb   )
r-   r   rL   rI   r   case
case_startr  r  had_wildcards
             r/   _handle__MatchzAstArcAnalyzer._handle__Match  s   ""4((
J 	$ 	$D++DL99JLLZ1^___!B  J T&&tyZ&HHHE#JJ ,#+.. 	+&r*G #+.. 	+#+.. 	&7?3NoG #+.. 	&7?3N w,,_D1H_TZ[_M_ 	  	II+XYYY   r>   	ast.Raisec                    |                      |          }t          |d          }|                     |h           t                      S )Nz*the raise on line {lineno} wasn't executedr  )rV  r   r   r"   )r-   r   r  raise_starts       r/   _handle__RaisezAstArcAnalyzer._handle__Raise  sG    !!$''t+WXXX  +///uur>   
ast.Returnc                    |                      |          }t          |d          }|                     |h           t                      S )Nz+the return on line {lineno} wasn't executedr  )rV  r   r   r"   )r-   r   r  return_starts       r/   _handle__ReturnzAstArcAnalyzer._handle__Return  sG    !!$'',YZZZ!!<.111uur>   ast.Tryc                z   |j         r!|                     |j         d                   }nd }|j        r!|                     |j        d                   }nd }||J t          ||          }| j                            |           |                     |          }|                     |j        t          |                    }|j        rd |_	        n| j        
                                 t                      }|j         rQ|j         D ]I}|                     |          }d}	t          ||	          }
||                     |j        |
          z  }J|j        r|                     |j        |          }||z  }|j        r;| j        
                                 |}|                     |j        |          }|r|}|S )Nr   r  z3the exception caught by line {lineno} didn't happenr  )r  )handlersrV  	finalbodyr	  r:  r   rW  ro   r   r
  rN  r"   r  )r-   r   r
  r  	try_blockrL   r   handler_exitshandler_node
from_causer  
final_fromfinal_exitss                r/   _handle__TryzAstArcAnalyzer._handle__Try!  s   = 	! ..t}Q/?@@MM M> 	,,T^A->??KKK (K,C,C,C]K88		***""4((!!$)!HH
 > 	#&*I##  """'*uu= 	] $ ] ] $ 2 2< @ @R
%m:FFF
!2!2<3DQ[!2!\!\\; 	F%%dku%EEE> 		$  """J++DN
+SSK $ $r>   	ast.Whilec                   |                      |j                  x}}t          |j                  \  }}| j                            t          |                     t          |d          }|                     |j        |          }|D ]#}| 	                    |j
        ||j                   $t                      }| j                                        }	t          |	t
                    sJ |                    |	j                   t          |d          }|j        r"|                     |j        |          }
||
z  }n|s|                    |           |S )Nr  r  r  r  r  )rV  r  r  r:  r   r   r   rW  ro   r   rW   r   r"   rN  rj   rF   r   r  rb   )r-   r   rL   to_topr  r   r  r   r   r  r  s              r/   _handle__WhilezAstArcAnalyzer._handle__WhileZ  sW   ++DI6660;;q	 7 7 7888e+Z[[[
!!$)
!CC 	8 	8CLLVSY7777#''))(I.....X)***e+[\\\
; 	&**4;:*NNJZEE ! &		*%%%r>   ast.Withc                <    t           j        j        r fd|j        D             }n                     |          g}|D ]6} j                            |            j                            |           7                     |j	        t          |d                             }|d         } j                            |           t          |          h}|rC|D ]>}                     |j        |            j                            |j        |f           ?|}|S )Nc                D    g | ]}                     |j                  S r   )rV  context_expr)r;   itemr-   s     r/   r  z0AstArcAnalyzer._handle__With.<locals>.<listcomp>r  s*    SSSd(():;;SSSr>   r  r  )r   
PYBEHAVIORexit_with_through_ctxmgritemsrV  r;  rb   r<  rW  ro   r   remover   rW   r>  )r-   r   r   rL   r   	with_exitr   s   `      r/   _handle__WithzAstArcAnalyzer._handle__Withp  s.   >2 	0SSSS
SSSFF((../F 	, 	,E$((/// $$U++++!!$)8L8L!MMr
 ''...e__%	 	 9 9SZ///##SZ$78888Er>   )
r   r2   r,  r  r#   r3   r-  r.  r   r   r   )r   rG  )r   rT  r   r   )r   rZ  r   r   )r   r]  r   r   r   r   )r   ra  )r   r  r   r   )r   rZ  r   r   )r   rl  r   r   )r   rp  r   r   )r   ru  r   r   )r   rT  r   r   )r   r  r   r   )ro   r  r  r  r  r  r   r   )r   r   r   r   )r   r  r   r   )r   rZ  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   r   )r   r  r   r   )r   r  r   r   )r   r  r   r   ).r   r   r   r   r0   r   r   rY  r\  _code_object__AsyncFunctionDefr_  r   rd  rV  rk  ro  _line__ClassDefrt  _line__FunctionDef_line__AsyncFunctionDefrx  rz  r  r  rW  r   r   r   r   r  r  _handle__ClassDefr  r  _handle__AsyncFor_handle__FunctionDef_handle__AsyncFunctionDefr  r  r  r  r  _handle__TryStarr  r  _handle__AsyncWithr   r>   r/   r   r   [  s        ($F $F $F $FL* * * *   >( ( ( (    &?"U U U U )-!%] ] ] ] ]$* * * *. . . .,   . . . . &O	 	 	 	 )-        M! ! ! !L '+,0	% % % % %^            "          0 *      ( %, 1
 
 
 
   <      5 5 5 5n $   ,   , 'r>   r   )r   r  r   r  )3r   
__future__r   rh   r   r   r6  rA   r]   r[   collections.abcr   r   r   dataclassesr   typingr   r	   r
   coverager   coverage.bytecoder   coverage.debugr   coverage.exceptionsr   r   coverage.miscr   r   coverage.phystokensr   coverage.typesr   r   r   r   r   dictr9  tupler2   TArcFragmentsr   r   r   r	  r  r   r   r>   r/   <module>r     s   $ # " " " " " " 



         				 				   8 8 8 8 8 8 8 8 8 8 ! ! ! ! ! ! + + + + + + + + + +       ( ( ( ( ( ( & & & & & & 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 / / / / / / ( ( ( ( ( ( ( (^B~ ~ ~ ~ ~ ~ ~ ~L $d###       $#D       . T4hsmXc]&B CDDE       8       &    E   <    u   &   4k' k' k' k' k' k' k' k' k' k'r>   