
    -h?                    R   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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" d dl#m$Z$ d dl%m&Z& dZ'e G d d                      Z(edddPd            Z)e	 dQddddRd'            Z*e	 dQdddddddd(dd(dd(d)dSd;            Z+e	 dQdddddddddd(dd(d)dSd<            Z,edddddddd=dTd@            Z-edddddddddAdUdD            Z.d(dEdVdIZ/dWdJZ0dd(dKdXdOZ1dS )Y    )annotationsN)contextmanager)	dataclass)invalidate_caches)Path)dedent)TYPE_CHECKINGAny)inspect)visit)LinesCollection)load)ModuleObject)IteratorMappingSequence)ModulesCollection)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    J/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/_griffe/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          |                      ||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.pyN)tempfileTemporaryDirectory_TMPDIR_PREFIXr   
write_textr   )r1   r0   r   tmpfiles       r%   temporary_pyfiler<   5   s       
	$N	;	;	; #vv,,K!4!4!446$<<(((7""""# # # # # # # # # # # # # # # # # #s   >A((A,/A,Tinitinitspackagemodules(Sequence[str] | Mapping[str, str] | Noner>   boolr?   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          r6|                    |                              t!          |
                     M||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.pyiNr-   )
isinstancelistdictfromkeysr7   r8   r9   r   joinpartsmkdirjoinpathtouchitemsendswithr:   r   r   )r@   rA   r>   r?   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SSSS 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   D>F!!F%(F%F)r>   r?   
extensionsdocstring_parserdocstring_optionslines_collectionmodules_collectionallow_inspectionstore_sourceresolve_aliasesresolve_externalresolve_implicitr^   Extensions | Noner_   DocstringStyle | Parser | Noner`   dict[str, Any] | Nonera   LinesCollection | Nonerb   ModulesCollection | Nonerc   rd   re   rf   bool | Nonerg   Iterator[Module]c             #     K   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: Additional 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.

    Yields:
        A module.
    r=   Fsearch_pathsr^   r_   r`   ra   rb   rc   rd   re   rf   rg   force_inspectionN)r]   r   r   r   )r@   rA   r>   r?   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   tmp_packages                  r%   temporary_visited_packagert   x   s      ^ 
WgD	F	F	F 
+%,-!-/-1-%+--"
 
 
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   *AAAc             #    K   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 )ab  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: Additional 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.

    Yields:
        A module.
    r=   Trp   rI   N)r]   r   r   r   tuplesysrA   keys
startswithpopr   )r@   rA   r>   r?   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rs   r   s                   r%   temporary_inspected_packager{      s     ^ 
WgD	F	F	F  +	  )01%!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	)B<A;E	<A<D88E		EE)r0   r^   parentr_   r`   ra   rb   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 )aS  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: Additional docstring parsing options.
        lines_collection: A collection of source code lines.
        modules_collection: A collection of modules.

    Yields:
        The visited module.
    r/   )filepathr1   r^   r|   r_   r`   ra   rb   N)r   r<   r   
splitlinesr   rb   )r1   r0   r^   r|   r_   r`   ra   rb   _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_pathsr^   r|   r_   r`   ra   rb   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: Additional docstring parsing options.
        lines_collection: A collection of source code lines.
        modules_collection: A collection of modules.

    Yields:
        The inspected module.
    r/   )r   r   r^   r|   r_   r`   ra   rb   N)r<   r   r   r   rb   rw   rA   r   )r1   r0   r   r^   r|   r_   r`   ra   rb   r   r   r.   s               r%   temporary_inspected_moduler   .  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   b  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   y  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.
    rI   c                `    g | ]*\  }}t          |t          g d |         dR            +S )NrJ   )r   )r   r   ).0indexr   rP   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   rA   r   rP   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"   )
r@   r   rA   rB   r>   rC   r?   rC   r   rD   )r@   r   rA   rB   r>   rC   r?   rC   r^   rh   r_   ri   r`   rj   ra   rk   rb   rl   rc   rC   rd   rC   re   rC   rf   rm   rg   rC   r   rn   )r1   r   r0   r   r^   rh   r|   r}   r_   ri   r`   rj   ra   rk   rb   rl   r   rn   )r1   r   r0   r   r   r   r^   rh   r|   r}   r_   ri   r`   rj   ra   rk   rb   rl   r   rn   )r   r   r   rC   r   r   )r   r   r   r   )r   r   r   rC   r   rC   r   r   )2
__future__r   rw   r7   
contextlibr   dataclassesr   	importlibr   pathlibr   textwrapr   typingr	   r
   _griffe.agents.inspectorr   _griffe.agents.visitorr   _griffe.collectionsr   _griffe.loaderr   _griffe.modelsr   r   collections.abcr   r   r   r   _griffe.docstrings.parsersr   _griffe.enumerationsr   _griffe.extensions.baser   r9   r   r<   r]   rt   r{   r   r   r   r   r   r-   r'   r%   <module>r      s  
 # " " " " " 



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