
    %jaA                    V   d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZmZ er$d dlmZmZmZ d dlmZ d dl m!Z!m"Z" d dl#m$Z$ d dl%m&Z& dZ'e G d d                      Z(edddQd            Z)e	 dRddddSd'            Z*e	 dRdddddddd(dd(dd(d(d)dTd<            Z+e	 dRdddddddddd(dd(d(d)dTd=            Z,edddddddd>dUdA            Z-edddddddddBdVdE            Z.d(dFdWdJZ/dXdKZ0dd(dLdYdPZ1dS )Z    )annotationsN)contextmanager)	dataclass)invalidate_caches)Path)dedent)TYPE_CHECKING)inspect)visit)LinesCollection)load)ModuleObject)IteratorMappingSequence)ModulesCollection)DocstringOptionsDocstringStyle)Parser)
Extensionsgriffe_c                  @    e Zd ZU dZded<   	 ded<   	 ded<   	 dd	Zd
S )
TmpPackagezA temporary package.

    The `tmpdir` and `path` parameters can be passed as relative path.
    They will be resolved to absolute paths after initialization.
    r   tmpdirstrnamepathreturnNonec                ~    | j                                         | _         | j                                        | _        d S N)r   resolver   )selfs    ^/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/griffe/_internal/tests.py__post_init__zTmpPackage.__post_init__0   s0    k))++I%%''			    N)r   r    )__name__
__module____qualname____doc____annotations__r&    r'   r%   r   r   !   sZ           LLL9III8JJJ( ( ( ( ( (r'   r   modulemodule_namecoder   r0   r   Iterator[tuple[str, Path]]c             #     K   t          j        t                    5 }t          |          | dz  }|                    t          |           d           ||fV  ddd           dS # 1 swxY w Y   dS )aB  Create a Python file containing the given code in a temporary directory.

    Parameters:
        code: The code to write to the temporary file.
        module_name: The name of the temporary module.

    Yields:
        module_name: The module name, as to dynamically import it.
        module_path: The module path.
    prefix.pyutf8encodingN)tempfileTemporaryDirectory_TMPDIR_PREFIXr   
write_textr   )r1   r0   r   tmpfiles       r%   temporary_pyfiler?   5   s       
	$N	;	;	; #vv,,K!4!4!446$<<&9997""""# # # # # # # # # # # # # # # # # #s   A A**A.1A.Tinitinitspackagemodules(Sequence[str] | Mapping[str, str] | NonerA   boolrB   Iterator[TmpPackage]c             #  `  K   |pi }t          |t                    rt                              |d          }ddd}t	          j        t                    5 }t          |          }d                    t          |           j	                  }|| z  } |j
        di | |r'|                    d                                           |                                D ]\  }	}
|}t          |	          j	        D ]}|                    d          r8|                    |                              t!          |
          d	           O||z  } |j
        di | |r'|                    d                                           t#          |||          V  d
d
d
           d
S # 1 swxY w Y   d
S )a(  Create a package containing the given modules in a temporary directory.

    Parameters:
        package: The package name. Example: `"a"` gives
            a package named `a`, while `"a/b"` gives a namespace package
            named `a` with a package inside named `b`.
            If `init` is false, then `b` is also a namespace package.
        modules: Additional modules to create in the package.
            If a list, simply touch the files: `["b.py", "c/d.py", "e/f"]`.
            If a dict, keys are the file names and values their contents:
            `{"b.py": "b = 1", "c/d.py": "print('hey from c')"}`.
        init: Whether to create an `__init__` module in the top package.
        inits: Whether to create `__init__` modules in subpackages.

    Yields:
        A temporary package.
     T)parentsexist_okr4   .__init__.py)r6   z.pyir7   r8   Nr-   )
isinstancelistdictfromkeysr:   r;   r<   r   joinpartsmkdirjoinpathtouchitemsendswithr=   r   r   )rC   rD   rA   rB   mkdir_kwargsr   
tmpdirpathpackage_namepackage_pathr0   module_contentscurrent_pathparts                r%   temporary_pypackager`   G   s/     2 mG'4   ---,,#66L		$N	;	;	; Av&\\
xxW 344!G+**\*** 	9!!-0066888,3MMOO 		E 		E(K'L[))/ E E==11 E ))$//::6/;R;R]c:dddd D(L&L&66666 E$--m<<BBDDDE \<@@@@@#A A A A A A A A A A A A A A A A A As   E F##F'*F'F)rA   rB   
extensionsdocstring_parserdocstring_optionslines_collectionmodules_collectionallow_inspectionstore_sourceresolve_aliasesresolve_externalresolve_implicitsearch_sys_pathra   Extensions | Nonerb   DocstringStyle | Parser | Nonerc   DocstringOptions | Nonerd   LinesCollection | Nonere   ModulesCollection | Nonerf   rg   rh   ri   bool | Nonerj   rk   Iterator[Module]c             #     K   |rt           j        ng }t          | |||          5 }t          |j        |j        g|||||||	|
|||d          V  ddd           dS # 1 swxY w Y   dS )a  Create and visit a temporary package.

    Parameters:
        package: The package name. Example: `"a"` gives
            a package named `a`, while `"a/b"` gives a namespace package
            named `a` with a package inside named `b`.
            If `init` is false, then `b` is also a namespace package.
        modules: Additional modules to create in the package.
            If a list, simply touch the files: `["b.py", "c/d.py", "e/f"]`.
            If a dict, keys are the file names and values their contents:
            `{"b.py": "b = 1", "c/d.py": "print('hey from c')"}`.
        init: Whether to create an `__init__` module in the top package.
        inits: Whether to create `__init__` modules in subpackages.
        extensions: The extensions to use.
        docstring_parser: The docstring parser to use. By default, no parsing is done.
        docstring_options: Docstring parsing options.
        lines_collection: A collection of source code lines.
        modules_collection: A collection of modules.
        allow_inspection: Whether to allow inspecting modules when visiting them is not possible.
        store_source: Whether to store code source in the lines collection.
        resolve_aliases: Whether to resolve aliases.
        resolve_external: Whether to try to load unspecified modules to resolve aliases.
            Default value (`None`) means to load external modules only if they are the private sibling
            or the origin module (for example when `ast` imports from `_ast`).
        resolve_implicit: When false, only try to resolve an alias if it is explicitly exported.
        search_sys_path: Whether to search the system paths for the package.

    Yields:
        A module.
    r@   Fsearch_pathsra   rb   rc   rd   re   rf   rg   rh   ri   rj   force_inspectionN)sysr   r`   r   r   r   )rC   rD   rA   rB   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   ru   tmp_packages                    r%   temporary_visited_packagery   x   s      b  /6388BL	WgD	F	F	F 
+%,<|<!-/-1-%+--"
 
 
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   ,AA#&A#c             #    K   |rt           j        ng }t          | |||          5 }	 t          |j        |j        g|||||||	|
|||d          V  t          t           j                                                  D ]@}|| k    s|	                    |  d          r t           j        
                    |d           At                       n# t          t           j                                                  D ]@}|| k    s|	                    |  d          r t           j        
                    |d           At                       w xY w	 ddd           dS # 1 swxY w Y   dS )a  Create and inspect a temporary package.

    Parameters:
        package: The package name. Example: `"a"` gives
            a package named `a`, while `"a/b"` gives a namespace package
            named `a` with a package inside named `b`.
            If `init` is false, then `b` is also a namespace package.
        modules: Additional modules to create in the package.
            If a list, simply touch the files: `["b.py", "c/d.py", "e/f"]`.
            If a dict, keys are the file names and values their contents:
            `{"b.py": "b = 1", "c/d.py": "print('hey from c')"}`.
        init: Whether to create an `__init__` module in the top package.
        inits: Whether to create `__init__` modules in subpackages.
        extensions: The extensions to use.
        docstring_parser: The docstring parser to use. By default, no parsing is done.
        docstring_options: Docstring parsing options.
        lines_collection: A collection of source code lines.
        modules_collection: A collection of modules.
        allow_inspection: Whether to allow inspecting modules.
        store_source: Whether to store code source in the lines collection.
        resolve_aliases: Whether to resolve aliases.
        resolve_external: Whether to try to load unspecified modules to resolve aliases.
            Default value (`None`) means to load external modules only if they are the private sibling
            or the origin module (for example when `ast` imports from `_ast`).
        resolve_implicit: When false, only try to resolve an alias if it is explicitly exported.
        search_sys_path: Whether to search the system paths for the package.

    Yields:
        A module.
    r@   Trt   rL   N)rw   r   r`   r   r   r   tuplerD   keys
startswithpopr   )rC   rD   rA   rB   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   ru   rx   r   s                     r%   temporary_inspected_packager      s     b  /6388BL	WgD	F	F	F  +	  )0@<@%!1"3!1#5!1) /!1!1!%       ck..0011 0 07??doommm&D&D?KOOD$/// ck..0011 0 07??doommm&D&D?KOOD$///+                                   s*   E+CA;EA<E

EE"E)r0   ra   parentrb   rc   rd   re   r   Module | Nonec             #    K   t          |           } t          | |          5 \  }}	|pt                      }|                                 ||	<   t	          ||	| ||||||	  	        }
|
|
j        |<   |
V  ddd           dS # 1 swxY w Y   dS )aH  Create and visit a temporary module with the given code.

    Parameters:
        code: The code of the module.
        module_name: The name of the temporary module.
        extensions: The extensions to use when visiting the AST.
        parent: The optional parent of this module.
        docstring_parser: The docstring parser to use. By default, no parsing is done.
        docstring_options: Docstring parsing options.
        lines_collection: A collection of source code lines.
        modules_collection: A collection of modules.

    Yields:
        The visited module.
    r/   )filepathr1   ra   r   rb   rc   rd   re   N)r   r?   r   
splitlinesr   re   )r1   r0   ra   r   rb   rc   rd   re   _r   r.   s              r%   temporary_visited_moduler     s      6 $<<D	$K	8	8	8 IQ+@/@/@!%!2!2!-/-1

 

 

 28!+.                 s   ABBB)r0   import_pathsra   r   rb   rc   rd   re   r   list[Path] | Nonec             #    K   t          | |          5 \  }	}
|pt                      }|                                 ||
<   	 t          ||
|||||||	  	        }||j        |<   |V  |t
          j        v rt
          j        |= t                       n.# |t
          j        v rt
          j        |= t                       w xY w	 ddd           dS # 1 swxY w Y   dS )a  Create and inspect a temporary module with the given code.

    Parameters:
        code: The code of the module.
        module_name: The name of the temporary module.
        import_paths: Paths to import the module from.
        extensions: The extensions to use when visiting the AST.
        parent: The optional parent of this module.
        docstring_parser: The docstring parser to use. By default, no parsing is done.
        docstring_options: Docstring parsing options.
        lines_collection: A collection of source code lines.
        modules_collection: A collection of modules.

    Yields:
        The inspected module.
    r/   )r   r   ra   r   rb   rc   rd   re   N)r?   r   r   r
   re   rw   rD   r   )r1   r0   r   ra   r   rb   rc   rd   re   r   r   r.   s               r%   temporary_inspected_moduler   4  sG     : 
$K	8	8	8  IQ+@/@/@!%!2!2	 )%!1"3!1#5
 
 
F 6<F%k2LLLck))K, ck))K,)                                   s)   +C &B&*C+B;;CCC)return_leafobjectsr   r   c                    |st          d          |d         }|}|dd         D ]}|                    |j        |           |} | r|n|S )a<  Link objects together, vertically.

    Parameters:
        *objects: A sequence of objects. The first one is at the top of the tree.
        return_leaf: Whether to return the leaf instead of the root.

    Raises:
        ValueError: When no objects are provided.

    Returns:
        The top or leaf object.
    $At least one object must be providedr      N
ValueError
set_memberr   )r   r   topleafobjs        r%   vtreer   h  sm      A?@@@
!*CDqrr{  #&&&'44C'r'   c                     | st          d          | d         }| dd         D ]}|                    |j        |           |S )a=  Link objects together, horizontally.

    Parameters:
        *objects: A sequence of objects. All objects starting at the second become members of the first.

    Raises:
        ValueError: When no objects are provided.

    Returns:
        The first given object, with all the other objects as members of it.
    r   r   r   Nr   )r   r   r   s      r%   htreer     sZ      A?@@@
!*Cqrr{ & &sx%%%%Jr'   )leaf_packager   r   r   r   c                   |                      d          fdt                    D             }|s3|d         j                            d                   }||d         _        t          |d|iS )ao  Link objects together, vertically.

    Parameters:
        path: The complete module path, like `"a.b.c.d"`.
        leaf_package: Whether the deepest module should also be a package.
        return_leaf: Whether to return the leaf instead of the root.

    Raises:
        ValueError: When no objects are provided.

    Returns:
        The top or leaf module.
    rL   c                `    g | ]*\  }}t          |t          g d |         dR            +S )NrM   )r   )r   r   ).0indexr   rS   s      r%   
<listcomp>z module_vtree.<locals>.<listcomp>  sF    nnnkeUYvdT%H5%=%H-%H%H%HIIInnnr'   r   )split	enumerater   	with_stem	_filepathr   )r   r   r   rD   r   rS   s        @r%   module_vtreer     s|     JJsOOEnnnn]fgl]m]mnnnG )2;'11%)<< ('3{333r'   )r1   r   r0   r   r   r2   r"   )
rC   r   rD   rE   rA   rF   rB   rF   r   rG   ) rC   r   rD   rE   rA   rF   rB   rF   ra   rl   rb   rm   rc   rn   rd   ro   re   rp   rf   rF   rg   rF   rh   rF   ri   rq   rj   rF   rk   rF   r   rr   )r1   r   r0   r   ra   rl   r   r   rb   rm   rc   rn   rd   ro   re   rp   r   rr   )r1   r   r0   r   r   r   ra   rl   r   r   rb   rm   rc   rn   rd   ro   re   rp   r   rr   )r   r   r   rF   r   r   )r   r   r   r   )r   r   r   rF   r   rF   r   r   )2
__future__r   rw   r:   
contextlibr   dataclassesr   	importlibr   pathlibr   textwrapr   typingr	   !griffe._internal.agents.inspectorr
   griffe._internal.agents.visitorr   griffe._internal.collectionsr   griffe._internal.loaderr   griffe._internal.modelsr   r   collections.abcr   r   r   r   #griffe._internal.docstrings.parsersr   r   griffe._internal.enumerationsr    griffe._internal.extensions.baser   r<   r   r?   r`   ry   r   r   r   r   r   r   r-   r'   r%   <module>r      s  
 # " " " " " 



  % % % % % % ! ! ! ! ! ! ' ' ' ' ' '                         5 5 5 5 5 5 1 1 1 1 1 1 8 8 8 8 8 8 ( ( ( ( ( ( 2 2 2 2 2 2 2 2 <;;;;;;;;;;>>>>>>TTTTTTTT444444;;;;;; ( ( ( ( ( ( ( (& 6> # # # # # #"  9=-A -A -A -A -A -A -A`  9=@
 $(7;15/337"!$("!!@
 @
 @
 @
 @
 @
F  9=F  $(7;15/337!!$("!!F  F  F  F  F  F R   $( 7;15/337* * * * * *Z   &*$( 7;15/3370  0  0  0  0  0 f 16 ( ( ( ( ( (.   ( 59e 4 4 4 4 4 4 4 4r'   