
    i{A                    ,   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  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  S SKJrJr  \(       a$  S SKJrJrJr  S SKJr  S SK J!r!J"r"  S SK#J$r$  S SK%J&r&  Sr'\ " S S5      5       r(\SS.S)S jj5       r)\ S*SSS.         S+S jjj5       r*\ S*SSSSSSSSSSSSSS.                               S,S jjj5       r+\ S*SSSSSSSSSSSSSS.                               S,S jjj5       r,\SSSSSSSS .                 S-S! jj5       r-\SSSSSSSSS".                   S.S# jj5       r.SS$.S/S% jjr/S0S& jr0SSS'.S1S( jjr1g)2    )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                  H    \ rS rSr% SrS\S'    S\S'    S\S'    SS jrS	rg
)
TmpPackage!   zA 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pathc                    U R                   R                  5       U l         U R                  R                  5       U l        g N)r   resolver   )selfs    P/home/james-whalen/.local/lib/python3.13/site-packages/griffe/_internal/tests.py__post_init__TmpPackage.__post_init__0   s*    kk))+II%%'	    )r   r   N)returnNone)__name__
__module____qualname____firstlineno____doc____annotations__r%   __static_attributes__ r'   r$   r   r   !   s&     L9
I8
J(r'   r   modulemodule_namec             #     #    [         R                  " [        S9 n[        U5      U S3-  nUR	                  [        U 5      SS9  X4v   SSS5        g! , (       d  f       g= f7f)a&  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   )coder4   r   tmpfiles       r$   temporary_pyfilerB   5   sW      
	$	$N	;vv,K=!446$<&9"" 
<	;	;s   A%0A	A%
A"A%Tinitinitsc             #  B  #    U=(       d    0 n[        U[        5      (       a  [        R                  US5      nSSS.n[        R
                  " [        S9 n[        U5      nSR                  [        U 5      R                  5      nX`-  nUR                  " S0 UD6  U(       a  UR                  S5      R                  5         UR                  5        H  u  pUn[        U	5      R                   H  nUR                  S5      (       a*  UR                  U5      R                  [!        U
5      SS	9  MC  X-  nUR                  " S0 UD6  U(       d  Mb  UR                  S5      R                  5         M     M     [#        XgU5      v   S
S
S
5        g
! , (       d  f       g
= f7f)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_okr6   .__init__.py)r8   z.pyir9   r:   Nr1   )
isinstancelistdictfromkeysr<   r=   r>   r   joinpartsmkdirjoinpathtouchitemsendswithr?   r   r   )packagemodulesrD   rE   mkdir_kwargsr   
tmpdirpathpackage_namepackage_pathr4   module_contentscurrent_pathparts                r$   temporary_pypackager`   G   sJ    2 mG'4  --,#6L		$	$N	;v&\
xxW 3 34!+*\*!!-0668,3MMO(K'L[)//==11 ))$/::6/;R]c:d (L &&66u$--m<BBD 0 -< <@@# 
<	;	;s%   AFC6F5F	F
FFF)rD   rE   
extensionsdocstring_parserdocstring_optionslines_collectionmodules_collectionallow_inspectionstore_sourceresolve_aliasesresolve_externalresolve_implicitsearch_sys_pathc             #     #    U(       a  [         R                  O/ n[        XX#S9 n[        UR                  UR
                  /UQUUUUUU	U
UUUSS9v   SSS5        g! , (       d  f       g= f7f)aY  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.
rC   Fsearch_pathsra   rb   rc   rd   re   rf   rg   rh   ri   rj   force_inspectionN)sysr   r`   r   r   r   )rW   rX   rD   rE   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rn   tmp_packages                    r$   temporary_visited_packagerr   x   su     b  /388BL	WD	F+%,,<|<!-/-1-%+--"
 	
 
G	F	Fs   $A//A	A/
A,(A/c             #    #    U(       a  [         R                  O/ n[        XX#S9 n [        UR                  UR
                  /UQUUUUUU	U
UUUSS9v   [        [         R                  R                  5       5       HD  nUU :X  d  UR                  U  S35      (       d  M$  [         R                  R                  US5        MF     [        5          SSS5        g! [        [         R                  R                  5       5       HD  nUU :X  d  UR                  U  S35      (       d  M$  [         R                  R                  US5        MF     [        5         f = f! , (       d  f       g= f7f)a8  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.
rC   Trm   rJ   N)rp   r   r`   r   r   r   tuplerX   keys
startswithpopr   )rW   rX   rD   rE   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rn   rq   r   s                     r$   temporary_inspected_packagerx      s(    b  /388BL	WD	F+	   )00@<@%!1"3!1#5!1) /!1!1!%   ckk..017?doo	m&D&DKKOOD$/ 2 + 
G	F$ ckk..017?doo	m&D&DKKOOD$/ 2 + 
G	FsA   $E(E.CAE!.E	E(AE%/EE
E%!E()r4   ra   parentrb   rc   rd   re   c             #     #    [        U 5      n [        XS9 u  pU=(       d
    [        5       nU R                  5       Xi'   [	        UU	U UUUUUUS9	n
XR
                  U'   U
v   SSS5        g! , (       d  f       g= f7f)a  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.
r3   )filepathr@   ra   ry   rb   rc   rd   re   N)r   rB   r   
splitlinesr   re   )r@   r4   ra   ry   rb   rc   rd   re   _r   r2   s              r$   temporary_visited_moduler~     s     6 $<D	$	8IQ+@/@!%!2!-/-1

 28!!+. 
9	8	8s   A<AA+"	A<+
A95A<)r4   import_pathsra   ry   rb   rc   rd   re   c             #    #    [        XS9 u  pU=(       d
    [        5       nU R                  5       Xz'    [        UU
UUUUUUUS9	nXR                  U'   Uv   U[
        R                  ;   a  [
        R                  U	 [        5          SSS5        g! U[
        R                  ;   a  [
        R                  U	 [        5         f = f! , (       d  f       g= f7f)aO  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.
r3   )r{   r   ra   ry   rb   rc   rd   re   N)rB   r   r|   r
   re   rp   rX   r   )r@   r4   r   ra   ry   rb   rc   rd   re   r}   r   r2   s               r$   temporary_inspected_moduler   4  s     : 
$	8IQ+@/@!%!2	 )%!1"3!1#5
F 6<%%k2Lckk)KK,) 
9	8$ ckk)KK,) 
9	8s3   
C(C#B/C	C1CC
CC)return_leafc                    U(       d  [        S5      eUS   nUnUSS  H!  nUR                  UR                  U5        UnM#     U (       a  U$ U$ )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   objectstopleafobjs        r$   vtreer   h  sW     ?@@
!*CDqr{#&  4'C'r'   c                     U (       d  [        S5      eU S   nU SS  H  nUR                  UR                  U5        M!     U$ )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     sC     ?@@
!*Cqr{sxx% Jr'   )leaf_packager   c                  U R                  S5      n[        U5       VVs/ s H  u  pE[        U[        / USU QSP76 S9PM     nnnU(       d*  US   R                  R                  US   5      nXvS   l        [        USU06$ s  snnf )aK  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.
rJ   NrK   )r{   r   )split	enumerater   r   r{   	with_stem	_filepathr   )r   r   r   rQ   indexr   rX   r{   s           r$   module_vtreer     s     JJsOE]fgl]mn]mkevdT%H5%=%H-%HI]mGn2;''11%)< ('3{33	 os   $B)r@   r   r4   r   r(   zIterator[tuple[str, Path]]r!   )
rW   r   rX   (Sequence[str] | Mapping[str, str] | NonerD   boolrE   r   r(   zIterator[TmpPackage]) rW   r   rX   r   rD   r   rE   r   ra   Extensions | Nonerb   DocstringStyle | Parser | Nonerc   DocstringOptions | Nonerd   LinesCollection | Nonere   ModulesCollection | Nonerf   r   rg   r   rh   r   ri   zbool | Nonerj   r   rk   r   r(   Iterator[Module])r@   r   r4   r   ra   r   ry   Module | Nonerb   r   rc   r   rd   r   re   r   r(   r   )r@   r   r4   r   r   zlist[Path] | Nonera   r   ry   r   rb   r   rc   r   rd   r   re   r   r(   r   )r   r   r   r   r(   r   )r   r   r(   r   )r   r   r   r   r   r   r(   r   )2
__future__r   rp   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   rB   r`   rr   rx   r~   r   r   r   r   r1   r'   r$   <module>r      s  
 # 
  % ! '     5 1 8 ( 2;;>T4; ( ( (& 6> # #"  9=-A -A-A5-A 	-A
 -A -A -A`  9=@
 $(7;15/337"!$("!!@
@
5@
 	@

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