ó
    Ð]j—  ã                  ó|   • S r SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	  \ " S S5      5       r
 " S	 S
5      rSS jrg)z*Find functions and classes in Python code.é    )ÚannotationsN)Úcast)Ú	dataclass)Ú
CodeRegionc                  ó8   • \ rS rSr% SrS\S'   S\S'   S\S'   Srg	)
ÚContexté   z0The nested named context of a function or class.ÚstrÚnameÚkindzset[int]Úlines© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Ú__static_attributes__r   ó    ÚM/home/mande/repo/quber/.venv/lib/python3.13/site-packages/coverage/regions.pyr   r      s   ‡ á:à
ƒIØ
ƒIØ†Or   r   c                  ó^   • \ rS rSrS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S	 jrS
rg)ÚRegionFinderé   z�An ast visitor that will find and track regions of code.

Functions and classes are tracked by name. Results are in the .regions
attribute.

c                ó    • / U l         / U l        g ©N)ÚregionsÚcontext©Úselfs    r   Ú__init__ÚRegionFinder.__init__    s   € Ø)+ˆŒØ&(ˆ�r   c                óN   • U R                  [        R                  " U5      5        g)zCParse `source` and walk the ast to populate the .regions attribute.N)Úhandle_nodeÚastÚparse)r    Úsources     r   Úparse_sourceÚRegionFinder.parse_source$   s   € à×ÑœŸš 6Ó*Õ+r   c                óF   • SR                  S U R                   5       5      $ )z6Get the current fully qualified name we're processing.Ú.c              3  ó8   #   • U  H  oR                   v •  M     g 7fr   )r   )Ú.0Úcs     r   Ú	<genexpr>Ú,RegionFinder.fq_node_name.<locals>.<genexpr>*   s   é € Ð5ª 1Ÿžªùs   ‚)Újoinr   r   s    r   Úfq_node_nameÚRegionFinder.fq_node_name(   s   € à�x‰xÑ5¨¯ªÓ5Ó5Ð5r   c                ó
  • [        U[        R                  [        R                  45      (       a  U R	                  U5        g[        U[        R
                  5      (       a  U R                  U5        gU R                  U5        g)zRecursively handle any node.N)Ú
isinstancer%   ÚFunctionDefÚAsyncFunctionDefÚhandle_FunctionDefÚClassDefÚhandle_ClassDefÚhandle_node_body)r    Únodes     r   r$   ÚRegionFinder.handle_node,   sY   € ä�dœSŸ_™_¬c×.BÑ.BÐC×DÑDØ×#Ñ# DÕ)Ü˜œcŸl™l×+Ñ+Ø× Ñ  Õ&à×!Ñ! $Õ'r   c                óN   • [        USS5       H  nU R                  U5        M     g)z9Recursively handle the nodes in this node's body, if any.Úbodyr   N)Úgetattrr$   )r    r<   Ú	body_nodes      r   r;   ÚRegionFinder.handle_node_body5   s#   € ä   v¨rÖ2ˆIØ×Ñ˜YÖ'ò 3r   c           
     ó  • [        [        UR                  S   R                  [	        [
        UR                  S   R                  5      S-   5      5      nU R                  (       a?  U R                  S   R                  S:X  a"  U R                  S   =R                  U-  sl	        [        U R                  5       H*  nUR                  S:X  d  M  U=R                  U-  sl	          O   U R                  R                  [        UR                  SU5      5        U R                  R                  [        SU R!                  5       UR                  US95        U R#                  U5        U R                  R%                  5         g)z Called for `def` or `async def`.r   éÿÿÿÿé   ÚclassÚfunction©r   r   Ústartr   N)ÚsetÚranger?   Úlinenor   ÚintÚ
end_linenor   r   r   ÚreversedÚappendr   r   r   r   r2   r;   Úpop©r    r<   r   Úancestors       r   r8   ÚRegionFinder.handle_FunctionDef:   s  € ä”E˜$Ÿ)™) A™,×-Ñ-¬t´C¸¿¹À2¹×9QÑ9QÓ/RÐUVÑ/VÓWÓXˆØ�<�<˜DŸL™L¨Ñ,×1Ñ1°WÓ<à�L‰L˜Ñ×"Ò" eÑ+Õ"ä  §¡Ö.ˆHØ�}‰} 
Õ*Ø—’ %Ñ'•Ùñ /ð 	�‰×ÑœG D§I¡I¨z¸5ÓAÔBØ�‰×ÑÜØØ×&Ñ&Ó(Ø—k‘kØñ	ô	
ð 	×Ñ˜dÔ#Ø�‰×ÑÕr   c           	     óÎ  • [        5       nU R                  R                  [        UR                  SU5      5        U R
                  R                  [        SU R                  5       UR                  US95        U R                  U5        U R                  R                  5         [        U R                  5       H*  nUR                  S:X  d  M  U=R                  U-  sl        M,     g)zCalled for `class`.rF   rH   N)rJ   r   rP   r   r   r   r   r2   rL   r;   rQ   rO   r   r   rR   s       r   r:   ÚRegionFinder.handle_ClassDefQ   sª   € ô
 ›%ˆØ�‰×ÑœG D§I¡I¨w¸Ó>Ô?Ø�‰×ÑÜØØ×&Ñ&Ó(Ø—k‘kØñ	ô	
ð 	×Ñ˜dÔ#Ø�‰×ÑÔä  §¡Ö.ˆHØ�}‰} Õ'Ø—’ %Ñ'—ò /r   )r   r   N)ÚreturnÚNone)r'   r
   rW   rX   )rW   r
   )r<   zast.ASTrW   rX   )r<   z&ast.FunctionDef | ast.AsyncFunctionDefrW   rX   )r<   zast.ClassDefrW   rX   )r   r   r   r   r   r!   r(   r2   r$   r;   r8   r:   r   r   r   r   r   r      s*   † ñô)ô,ô6ô(ô(ô
÷.(r   r   c                óP   • [        5       nUR                  U 5        UR                  $ )a%  Find function and class regions in source code.

Analyzes the code in `source`, and returns a list of :class:`CodeRegion`
objects describing functions and classes as regions of the code::

    [
        CodeRegion(kind="function", name="func1", start=8, lines={10, 11, 12}),
        CodeRegion(kind="function", name="MyClass.method", start=30, lines={34, 35, 36}),
        CodeRegion(kind="class", name="MyClass", start=25, lines={34, 35, 36}),
    ]

The line numbers will include comments and blank lines.  Later processing
will need to ignore those lines as needed.

Nested functions and classes are excluded from their enclosing region.  No
line should be reported as being part of more than one function, or more
than one class.  Lines in methods are reported as being in a function and
in a class.

)r   r(   r   )r'   Úrfs     r   Úcode_regionsr[   h   s!   € ô* 
‹€BØ‡O�O�FÔØ�:‰:Ðr   )r'   r
   rW   zlist[CodeRegion])r   Ú
__future__r   r%   Útypingr   Údataclassesr   Úcoverage.pluginr   r   r   r[   r   r   r   Ú<module>r`      sD   ðñ 1å "ã 
Ý Ý !å &ð ÷ð ó ð÷M(ñ M(õ`r   