
    g                       d dl m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mZmZmZmZ d dlmZ d d	lmZmZ d d
lmZmZmZ d dlmZmZmZmZ d dlm Z m!Z! d dl"m#Z# d dl$m%Z% er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/  G d d      Z0 G d d      Z1 G d d      Z2 G d d      Z3 G d de%      Z4 G d de%      Z5 G d  d!e4      Z6 G d" d#e4      Z7 G d$ d%e4      Z8 G d& d'e4      Z9y)(    )annotationsN)defaultdict)suppress)Path)dedent)TYPE_CHECKINGAnyCallableUnioncast)c3linear_merge)DocstringStyleparse)KindParameterKindParser)AliasResolutionErrorBuiltinModuleErrorCyclicAliasErrorNameResolutionError)ExprCallExprName)logger)ObjectAliasMixin)Sequence)LinesCollectionModulesCollection)DocstringSection)Expr)cached_propertyc                  2    e Zd ZdZddZedd       ZddZy)		Decoratorz!This class represents decorators.c               2    || _         	 || _        	 || _        y)zInitialize the decorator.

        Parameters:
            value: The decorator code.
            lineno: The starting line number.
            endlineno: The ending line number.
        Nvaluelineno	endlineno)selfr%   r&   r'   s       C/var/www/openai/venv/lib/python3.12/site-packages/_griffe/models.py__init__zDecorator.__init__"   s"     "'
E"(8%.6    c                    t        | j                  t              r| j                  j                  n| j                  }t        |t              r|S |j
                  S )z+The path of the callable used as decorator.)
isinstancer%   r   functionstrcanonical_pathr(   r%   s     r)   callable_pathzDecorator.callable_path1   s@     (2$**h'G

##TZZ"5#.uHE4H4HHr+   c                J    | j                   | j                  | j                  dS )zReturn this decorator's data as a dictionary.

        Parameters:
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        r$   r$   )r(   kwargss     r)   as_dictzDecorator.as_dict7   s#     ZZkk
 	
r+   N)r%   z
str | Exprr&   
int | Noner'   r6   returnNoner7   r/   r4   r	   r7   dict[str, Any])__name__
__module____qualname____doc__r*   propertyr2   r5    r+   r)   r"   r"      s%    +7 I I

r+   r"   c                      e Zd ZdZdddddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZedd       Zedd       Zedd       Z		 d	 	 	 	 	 ddZ
d	d
	 	 	 	 	 ddZy)	Docstringz!This class represents docstrings.N)r&   r'   parentparserparser_optionsc                   t        j                  |j                               | _        	 || _        	 || _        	 || _        	 || _        	 |xs i | _        y)a  Initialize the docstring.

        Parameters:
            value: The docstring value.
            lineno: The starting line number.
            endlineno: The ending line number.
            parent: The parent object on which this docstring is attached.
            parser: The docstring parser to use. By default, no parsing is done.
            parser_options: Additional docstring parsing options.
        N)	inspectcleandocrstripr%   r&   r'   rD   rE   rF   )r(   r%   r&   r'   rD   rE   rF   s          r)   r*   zDocstring.__init__J   sj    ( "**5<<>:
	
 #)	@ &/	: &,76<	 /=.B	r+   c                8    | j                   j                  d      S )z\The lines of the docstring.

        See also: [`source`][griffe.Docstring.source].
        
)r%   splitr(   s    r)   lineszDocstring.lines   s     zz%%r+   c                   | j                   t        d      t        | j                   j                  t              rt        d      | j
                  | j                  t        d      dj                  | j                   j                  | j                   j                     | j
                  dz
  | j                         S )zThe original, uncleaned value of the docstring as written in the source.

        See also: [`value`][griffe.Docstring.value].
        z3Cannot get original docstring without parent objectz3Cannot get original docstring for namespace packagez2Cannot get original docstring without line numbersrL      )	rD   
ValueErrorr-   filepathlistr&   r'   joinlines_collectionrN   s    r)   sourcezDocstring.source   s     ;;RSSdkk**D1RSS;;$.."8QRRyy55dkk6J6JKDKKZ[O^b^l^lmnnr+   c                "    | j                         S )z4The docstring sections, parsed into structured data.)r   rN   s    r)   parsedzDocstring.parsed   s     zz|r+   c                T    t        | |xs | j                  fi |xs | j                  S )a  Parse the docstring into structured data.

        See also: [`parser`][griffe.Docstring.parser],
        [`parser_options`][griffe.Docstring.parser_options].

        Parameters:
            parser: The docstring parser to use.
                In order: use the given parser, or the self parser, or no parser (return a single text section).
            **options: Additional docstring parsing options.

        Returns:
            The parsed docstring as a list of sections.
        )r   rE   rF   )r(   rE   optionss      r)   r   zDocstring.parse   s*    $ T60T[[UW5S@S@SUUr+   Ffullc               p    | j                   | j                  | j                  d}|r| j                  |d<   |S )zReturn this docstring's data as a dictionary.

        Parameters:
            full: Whether to return full info, or just base info.
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        r$   rY   )r%   r&   r'   rY   r(   r]   r4   bases       r)   r5   zDocstring.as_dict   s7      ZZkk 

 ![[DNr+   )r%   r/   r&   r6   r'   r6   rD   zObject | NonerE   DocstringStyle | Parser | NonerF   zdict[str, Any] | Noner7   r8   r7   z	list[str]r9   )r7   list[DocstringSection]N)rE   ra   r[   r	   r7   rc   r]   boolr4   r	   r7   r;   )r<   r=   r>   r?   r*   r@   rO   rW   r    rY   r   r5   rA   r+   r)   rC   rC   G   s    + " $ $150433 	3
 3 3 /3 .3 
3j & & o o   26V.V V 
 	V.   	
 
r+   rC   c                  r    e Zd ZdZddddd	 	 	 	 	 	 	 	 	 	 	 ddZddZddZddZedd       Z	d	d
ddZ
y)	ParameterzaThis class represent a function parameter.

    See also: [`Parameters`][griffe.Parameters].
    N)
annotationkinddefault	docstringc               b    || _         	 || _        	 || _        	 || _        	 || _        	 d| _        y)aF  Initialize the parameter.

        Parameters:
            name: The parameter name, without leading stars (`*` or `**`).
            annotation: The parameter annotation, if any.
            kind: The parameter kind.
            default: The parameter default, if any.
            docstring: The parameter docstring.
        N)nameri   rj   rk   rl   r.   )r(   rn   ri   rj   rk   rl   s         r)   r*   zParameter.__init__   sB    $ 	!-7,*.	!*1*+4& *.3r+   c                    | j                    d| j                   d| j                   }| j                  rd| j                  j                   d| S |S )Nz: z = [z] )rn   ri   rk   rj   r%   )r(   params     r)   __str__zParameter.__str__   sM    99+R0DLL>B99tyy'r%11r+   c           	     p    d| j                   d| j                  d| j                  d| j                  d	S )NzParameter(name=z, annotation=z, kind=z
, default=)rn   ri   rj   rk   rN   s    r)   __repr__zParameter.__repr__   s>     ]4??:MWUYU^U^Taaklplxlxk{{|}}r+   c                  t        |t              st        S | j                  |j                  k(  xrO | j                  |j                  k(  xr4 | j
                  |j
                  k(  xr | j                  |j                  k(  S )zYParameters are equal if all their attributes except `docstring` and `function` are equal.)r-   rh   NotImplementedrn   ri   rj   rk   r1   s     r)   __eq__zParameter.__eq__   sj    %+!!II# .5#3#33.		UZZ'. -		
r+   c                    | j                   du S )z#Whether this parameter is required.N)rk   rN   s    r)   requiredzParameter.required  s     ||t##r+   Fr\   c                   | j                   | j                  | j                  | j                  d}| j                  r| j                  j                  |      |d<   |S )zReturn this parameter's data as a dictionary.

        Parameters:
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        ru   r\   rl   )rn   ri   rj   rk   rl   r5   r_   s       r)   r5   zParameter.as_dict  sQ     II//II||	 
 >> $ 6 6D 6 ADr+   )rn   r/   ri   str | Expr | Nonerj   zParameterKind | Nonerk   r}   rl   Docstring | Noner7   r8   r9   )r%   objectr7   rf   r7   rf   re   )r<   r=   r>   r?   r*   rr   rv   ry   r@   r{   r5   rA   r+   r)   rh   rh      s     )-%)%)&*44 &	4
 #4 #4 $4 
4B~	
 $ $ ', r+   rh   c                  T    e Zd ZdZddZddZddZddZddZd Z	d Z
dd	Zdd
Zy)
Parametersa+  This class is a container for parameters.

    It allows to get parameters using their position (index) or their name:

    ```pycon
    >>> parameters = Parameters(Parameter("hello"))
    >>> parameters[0] is parameters["hello"]
    True
    ```

    See also: [`Parameter`][griffe.Parameter].
    c                $    t        |      | _        y)zInitialize the parameters container.

        Parameters:
            *parameters: The initial parameters to add to the container.
        N)rT   _params)r(   
parameterss     r)   r*   zParameters.__init__)  s     )-Z(8r+   c                N    ddj                  d | j                  D               dS )NzParameters(, c              3  2   K   | ]  }t        |        y wrd   )repr).0rq   s     r)   	<genexpr>z&Parameters.__repr__.<locals>.<genexpr>2  s     &MutE{   rt   )rU   r   rN   s    r)   rv   zParameters.__repr__1  s%    TYY&M&MMNaPPr+   c                    t        |t              r| j                  |   S |j                  d      	 t	        fd| j                  D              S # t
        $ r}t        d| d      |d}~ww xY w)z!Get a parameter by index or name.*c              3  B   K   | ]  }|j                   k(  s|  y wrd   rn   )r   rq   rn   s     r)   r   z)Parameters.__getitem__.<locals>.<genexpr>:  s     N<%5::;M<s   
parameter 
 not foundN)r-   intr   lstripnextStopIterationKeyError)r(   name_or_indexerrorrn   s      @r)   __getitem__zParameters.__getitem__4  so    mS)<<..##C(	NN4<<NNN 	NZjABM	Ns   A 	A/A**A/c                *   t        |t              r|| j                  |<   y|j                  d      	 t	        fdt        | j                        D              }|| j                  |<   y# t        $ r | j                  j                  |       Y yw xY w)z!Set a parameter by index or name.r   c              3  H   K   | ]  \  }}|j                   k(  s|  y wrd   r   r   idxrq   rn   s      r)   r   z)Parameters.__setitem__.<locals>.<genexpr>E  $     a3JZS%ejj\`N`S3J   ""N)r-   r   r   r   r   	enumerater   append)r(   r   	parameterindexrn   s       @r)   __setitem__zParameters.__setitem__>  s|    mS)*3DLL' '',D0a9T\\3Jaa '0U# ! /##I./s   'A+ +$BBc                   t        |t              r| j                  |= y|j                  d      	 t	        fdt        | j                        D              }| j                  |= y# t        $ r}t        d| d      |d}~ww xY w)z$Delete a parameter by index or name.r   c              3  H   K   | ]  \  }}|j                   k(  s|  y wrd   r   r   s      r)   r   z)Parameters.__delitem__.<locals>.<genexpr>R  r   r   r   r   N)r-   r   r   r   r   r   r   r   )r(   r   r   r   rn   s       @r)   __delitem__zParameters.__delitem__K  s    mS)]+ '',DRa9T\\3Jaa U# ! RM?*EFEQRs   'A' '	B0B  Bc                ,    t        | j                        S )zThe number of parameters.)lenr   rN   s    r)   __len__zParameters.__len__W  s    4<<  r+   c                ,    t        | j                        S )z&Iterate over the parameters, in order.)iterr   rN   s    r)   __iter__zParameters.__iter__[  s    DLL!!r+   c                b    	 t        fd| j                  D               y# t        $ r Y yw xY w)z3Whether a parameter with the given name is present.c              3  `   K   | ]%  }|j                   j                  d       k(  s"| ' yw)r   N)rn   r   )r   rq   
param_names     r)   r   z*Parameters.__contains__.<locals>.<genexpr>b  s)     YL5EJJ*BSBSTWBX4XLs   #..FT)r   r   r   )r(   r   s    `r)   __contains__zParameters.__contains___  s3    	YDLLYY   		s   " 	..c                    |j                   | v rt        d|j                    d      | j                  j                  |       y)zAdd a parameter to the container.

        Parameters:
            parameter: The function parameter to add.

        Raises:
            ValueError: When a parameter with the same name is already present.
        r   z already presentN)rn   rR   r   r   )r(   r   s     r)   addzParameters.addg  s<     >>T!z)..)99IJKKI&r+   N)r   rh   r7   r8   r9   )r   	int | strr7   rh   )r   r   r   rh   r7   r8   )r   r   r7   r8   )r   r/   )r   rh   r7   r8   )r<   r=   r>   r?   r*   rv   r   r   r   r   r   r   r   rA   r+   r)   r   r     s6    9QN0
$!"'r+   r   c                  n   e Zd ZU dZded<   	 dZded<   	 dZded<   	 dZded<   	 d	d	d
d	d	d	d	d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d-dZd.dZ	d/dZ
d0dZed/d       Zed/d       Zd1dZed2d       Zed/d       Zed/d       Zed/d       Zed/d       Zed/d       Zed/d       Zed/d       Zed/d       Zed/d       Zd3dZd4dZed5d       Zed5d        Zed6d!       Zed7d"       Zed7d#       Z ed.d$       Z!ed.d%       Z"ed8d&       Z#ed9d'       Z$ed:d(       Z%ed.d)       Z&d;d*Z'dd+d<d,Z(y	)=Objectz/An abstract class representing a Python object.r   rj   Frf   is_aliasis_collection	inheritedNT)r&   r'   runtimerl   rD   rV   modules_collectionc               >   || _         	 || _        	 || _        	 || _        	 || _        	 i | _        	 t               | _        	 i | _        	 d| _	        	 i | _
        	 || _        	 t        t              | _        	 d| _        	 d| _        	 || _        || _        |r| |_        yy)a*  Initialize the object.

        Parameters:
            name: The object name, as declared in the code.
            lineno: The object starting line, or None for modules. Lines start at 1.
            endlineno: The object ending line (inclusive), or None for modules.
            runtime: Whether this object is present at runtime or not.
            docstring: The object docstring.
            parent: The object parent.
            lines_collection: A collection of source code lines.
            modules_collection: A collection of modules.
        N)rn   r&   r'   rl   rD   memberssetlabelsimportsexportsaliasesr   r   dictextrapublic
deprecated_lines_collection_modules_collection)	r(   rn   r&   r'   r   rl   rD   rV   r   s	            r)   r*   zObject.__init__  s    0 	"(	
 &/	
 ,5	 .4<24	 !$	? (*	 @D	  *,2$	 1<D0A
a#',-1Q9I=O  #I r+   c                    | j                   j                   d| j                  d| j                  d| j                  dS )N(r   rt   )	__class__r<   rn   r&   r'   rN   s    r)   rv   zObject.__repr__  s:    ..))*!DII=4;;/DNNK]]^__r+   c                     y)zAn object is always true-ish.TrA   rN   s    r)   __bool__zObject.__bool__      r+   c                    t        | j                        t        d | j                  j                         D              z   S )z2The number of members in this object, recursively.c              3  2   K   | ]  }t        |        y wrd   )r   )r   members     r)   r   z!Object.__len__.<locals>.<genexpr>  s     &WAVvs6{AVr   )r   r   sumvaluesrN   s    r)   r   zObject.__len__  s.    4<< 3&WATATAV&W#WWWr+   c                ,    t        | j                        S )zWhether this object has a docstring (empty or not).

        See also: [`docstring`][griffe.Object.docstring],
        [`has_docstrings`][griffe.Object.has_docstrings].
        )rf   rl   rN   s    r)   has_docstringzObject.has_docstring  s     DNN##r+   c                    | j                   ry| j                  j                         D ])  }	 |j                  r|j                  r|j
                  r y+ y# t        $ r Y 8w xY w)a>  Whether this object or any of its members has a docstring (empty or not).

        Inherited members are not considered. Imported members are not considered,
        unless they are also public.

        See also: [`docstring`][griffe.Object.docstring],
        [`has_docstring`][griffe.Object.has_docstring].
        TF)r   r   r   is_imported	is_publichas_docstringsr   )r(   r   s     r)   r   zObject.has_docstrings  sb     ll))+F**f.>.>FDYDY ,  ( s   $A	A! A!c                    t        |t              r"|st        d      | j                  d |D        v S t        |t              rt        |      }| j                  |u S )a  Tell if this object is of the given kind.

        See also: [`is_module`][griffe.Object.is_module],
        [`is_class`][griffe.Object.is_class],
        [`is_function`][griffe.Object.is_function],
        [`is_attribute`][griffe.Object.is_attribute],
        [`is_alias`][griffe.Object.is_alias].

        Parameters:
            kind: An instance or set of kinds (strings or enumerations).

        Raises:
            ValueError: When an empty set is given as argument.

        Returns:
            True or False.
        zkind must not be an empty setc              3  V   K   | ]!  }t        |t              r|n
t        |       # y wrd   )r-   r   )r   knds     r)   r   z!Object.is_kind.<locals>.<genexpr>;  s&      ]X\QT
3(=49!LX\s   '))r-   r   rR   rj   r/   r   r(   rj   s     r)   is_kindzObject.is_kind&  sU    $ dC  !@AA99 ]X\ ]]]dC :DyyD  r+   c                P   t        | t              si S 	 | j                         }i }t        |      D ]E  }|j                  j                         D ]&  \  }}|| j                  vst        ||| d      ||<   ( G |S # t        $ r!}t	        j
                  |       i cY d}~S d}~ww xY w)zMembers that are inherited from base classes.

        This method is part of the consumer API:
        do not use when producing Griffe trees!

        See also: [`members`][griffe.Object.members].
        NT)rD   r   )
r-   ClassmrorR   r   debugreversedr   itemsAlias)r(   r   r   inherited_membersr`   rn   r   s          r)   r   zObject.inherited_members@  s     $&I	((*C SMD $ 2 2 4ft||+.3D&Y].^%d+ !5 " !   	LLI	s   A; ;	B%B B% B%c                :    | j                   t        j                  u S )aa  Whether this object is a module.

        See also:  [`is_init_module`][griffe.Object.is_init_module].
        [`is_class`][griffe.Object.is_class],
        [`is_function`][griffe.Object.is_function],
        [`is_attribute`][griffe.Object.is_attribute],
        [`is_alias`][griffe.Object.is_alias],
        [`is_kind`][griffe.Object.is_kind].
        )rj   r   MODULErN   s    r)   	is_modulezObject.is_moduleW  s     yyDKK''r+   c                :    | j                   t        j                  u S )a(  Whether this object is a class.

        See also:  [`is_module`][griffe.Object.is_module].
        [`is_function`][griffe.Object.is_function],
        [`is_attribute`][griffe.Object.is_attribute],
        [`is_alias`][griffe.Object.is_alias],
        [`is_kind`][griffe.Object.is_kind].
        )rj   r   CLASSrN   s    r)   is_classzObject.is_classd  s     yyDJJ&&r+   c                :    | j                   t        j                  u S )a%  Whether this object is a function.

        See also:  [`is_module`][griffe.Object.is_module].
        [`is_class`][griffe.Object.is_class],
        [`is_attribute`][griffe.Object.is_attribute],
        [`is_alias`][griffe.Object.is_alias],
        [`is_kind`][griffe.Object.is_kind].
        )rj   r   FUNCTIONrN   s    r)   is_functionzObject.is_functionp  s     yyDMM))r+   c                :    | j                   t        j                  u S )a%  Whether this object is an attribute.

        See also:  [`is_module`][griffe.Object.is_module].
        [`is_class`][griffe.Object.is_class],
        [`is_function`][griffe.Object.is_function],
        [`is_alias`][griffe.Object.is_alias],
        [`is_kind`][griffe.Object.is_kind].
        )rj   r   	ATTRIBUTErN   s    r)   is_attributezObject.is_attribute|  s     yyDNN**r+   c                     y)ztWhether this object is an `__init__.py` module.

        See also:  [`is_module`][griffe.Object.is_module].
        FrA   rN   s    r)   is_init_modulezObject.is_init_module       r+   c                     y)z{Whether this object is a package (top module).

        See also:  [`is_subpackage`][griffe.Object.is_subpackage].
        FrA   rN   s    r)   
is_packagezObject.is_package  r   r+   c                     y)zkWhether this object is a subpackage.

        See also:  [`is_package`][griffe.Object.is_package].
        FrA   rN   s    r)   is_subpackagezObject.is_subpackage  r   r+   c                     y)zWhether this object is a namespace package (top folder, no `__init__.py`).

        See also:  [`is_namespace_subpackage`][griffe.Object.is_namespace_subpackage].
        FrA   rN   s    r)   is_namespace_packagezObject.is_namespace_package  r   r+   c                     y)zWhether this object is a namespace subpackage.

        See also:  [`is_namespace_package`][griffe.Object.is_namespace_package].
        FrA   rN   s    r)   is_namespace_subpackagezObject.is_namespace_subpackage  r   r+   c                J    t        |      j                  | j                        S )zTell if this object has all the given labels.

        See also: [`labels`][griffe.Object.labels].

        Parameters:
            *labels: Labels that must be present.

        Returns:
            True or False.
        )r   issubsetr   r(   r   s     r)   
has_labelszObject.has_labels  s     6{##DKK00r+   c                    |s| j                   S | j                   j                         D ci c]  \  }t        fd|D              s| }}}|S c c}}w )a0  Filter and return members based on predicates.

        See also: [`members`][griffe.Object.members].

        Parameters:
            *predicates: A list of predicates, i.e. callables accepting a member as argument and returning a boolean.

        Returns:
            A dictionary of members.
        c              3  .   K   | ]  } |        y wrd   rA   )r   	predicater   s     r)   r   z(Object.filter_members.<locals>.<genexpr>  s     Hwlv_hSYIZlvs   )r   r   all)r(   
predicatesrn   r   r   s      ` r)   filter_memberszObject.filter_members  s^     <<-1\\-?-?-A.
-A\T6SHwlvHwEwD&L-A 	 .
 .
s   AAc                    t        | t              r| S | j                  | j                  j                  S t	        d| j
                   d      )a  The parent module of this object.

        See also: [`package`][griffe.Object.package].

        Examples:
            >>> import griffe
            >>> markdown = griffe.load("markdown")
            >>> markdown["core.Markdown.references"].module
            Module(PosixPath('~/project/.venv/lib/python3.11/site-packages/markdown/core.py'))
            >>> # The `module` of a module is itself.
            >>> markdown["core"].module
            Module(PosixPath('~/project/.venv/lib/python3.11/site-packages/markdown/core.py'))

        Raises:
            ValueError: When the object is not a module and does not have a parent.
        zObject z does not have a parent module)r-   ModulerD   modulerR   rn   rN   s    r)   r  zObject.module  sF    $ dF#K;;";;%%%7499+-KLMMr+   c                h    | j                   }|j                  r|j                  }|j                  r|S )aw  The absolute top module (the package) of this object.

        See also: [`module`][griffe.Object.module].

        Examples:
            >>> import griffe
            >>> markdown = griffe.load("markdown")
            >>> markdown["core.Markdown.references"].package
            Module(PosixPath('~/project/.venv/lib/python3.11/site-packages/markdown/__init__.py'))
        )r  rD   )r(   r  s     r)   packagezObject.package  s+     mm]]F mmr+   c                .    | j                   j                  S )a  The file path (or directory list for namespace packages) where this object was defined.

        See also: [`relative_filepath`][griffe.Object.relative_filepath],
        [`relative_package_filepath`][griffe.Object.relative_package_filepath].

        Examples:
            >>> import griffe
            >>> markdown = griffe.load("markdown")
            >>> markdown.filepath
            PosixPath('~/project/.venv/lib/python3.11/site-packages/markdown/__init__.py')
        )r  rS   rN   s    r)   rS   zObject.filepath  s     {{###r+   c                8   | j                   j                  }t        | j                  t              rt        |t              rU|D ]J  }| j                  D ]9  }t	        t
              5  |j                  |j                        cddd       c c S  L t
        | j                  D ]A  }t	        t
              5  |j                  |j                  j                        cddd       c S  t
        t        |t              rL|D ]A  }t	        t
              5  | j                  j                  |j                        cddd       c S  t
        | j                  j                  |j                  j                        S # 1 sw Y   /xY w# 1 sw Y   xY w# 1 sw Y   xY w)a&  The file path where this object was defined, relative to the top module path.

        See also: [`filepath`][griffe.Object.filepath],
        [`relative_filepath`][griffe.Object.relative_filepath].

        Raises:
            ValueError: When the relative path could not be computed.
        N)r  rS   r-   rT   r   rR   relative_torD   )r(   package_pathpkg_path	self_paths       r)   relative_package_filepathz Object.relative_package_filepath  s3    ||,, dmmT*,- ,H%)]]	%j1#,#8#8#I 21 &3 !-  "&I!*-(44\5H5H5O5OP .- "/  lD)(j)==44X__E *) )  }}(()<)<)C)CDD1 21 .- *)s$   $E74%F%F7FF	F	c                   t        j                         }t        | j                  t              rW| j                  D ]-  }t        t              5  |j                  |      cddd       c S  t        d| j                  d|       	 | j                  j                  |      S # 1 sw Y   pxY w# t        $ r | j                  cY S w xY w)a  The file path where this object was defined, relative to the current working directory.

        If this object's file path is not relative to the current working directory, return its absolute path.

        See also: [`filepath`][griffe.Object.filepath],
        [`relative_package_filepath`][griffe.Object.relative_package_filepath].

        Raises:
            ValueError: When the relative path could not be computed.
        NzNo directory in z. is relative to the current working directory )r   cwdr-   rS   rT   r   rR   r  )r(   r  r  s      r)   relative_filepathzObject.relative_filepath3  s     hhjdmmT*!]]	j)$005 *) + //@@nornstuu	!==,,S11	 *)
  	!== 	!s   B"B. "B+	.CCc                    | j                   S )a  The dotted path of this object.

        On regular objects (not aliases), the path is the canonical path.

        See also: [`canonical_path`][griffe.Object.canonical_path].

        Examples:
            >>> import griffe
            >>> markdown = griffe.load("markdown")
            >>> markdown["core.Markdown.references"].path
            'markdown.core.Markdown.references'
        )r0   rN   s    r)   pathzObject.pathJ  s     """r+   c                |    | j                   | j                  S | j                   j                   d| j                   S )zThe full dotted path of this object.

        The canonical path is the path where the object was defined (not imported).

        See also: [`path`][griffe.Object.path].
        .)rD   rn   r  rN   s    r)   r0   zObject.canonical_pathZ  s8     ;;99++""#1TYYK00r+   c                    | j                   | j                   S | j                  t        d      | j                  j                  S )zThe modules collection attached to this object or its parents.

        Raises:
            ValueError: When no modules collection can be found in the object or its parents.
        z3no modules collection in this object or its parents)r   rD   rR   r   rN   s    r)   r   zObject.modules_collectionf  sB     ##/+++;;RSS{{---r+   c                    | j                   | j                   S | j                  t        d      | j                  j                  S )a  The lines collection attached to this object or its parents.

        See also: [`lines`][griffe.Object.lines],
        [`source`][griffe.Object.source].

        Raises:
            ValueError: When no modules collection can be found in the object or its parents.
        z1no lines collection in this object or its parents)r   rD   rR   rV   rN   s    r)   rV   zObject.lines_collections  sB     !!-)));;PQQ{{+++r+   c                ,   	 | j                   }t        |t              rg S 	 | j                  |   }| j                  r|S | j                  | j                  g S || j                  dz
  | j                   S # t        $ r g cY S w xY w# t
        $ r g cY S w xY w)zThe lines containing the source of this object.

        See also: [`lines_collection`][griffe.Object.lines_collection],
        [`source`][griffe.Object.source].
        rQ   )	rS   r   r-   rT   rV   r   r   r&   r'   )r(   rS   rO   s      r)   rO   zObject.lines  s    	}}H h%I	))(3E >>L;;$.."8IT[[1_t~~66 " 	I	  	I	s"   A4 B 4BBBBc                J    t        dj                  | j                              S )zThe source code of this object.

        See also: [`lines`][griffe.Object.lines],
        [`lines_collection`][griffe.Object.lines_collection].
        rL   )r   rU   rO   rN   s    r)   rW   zObject.source  s     dii

+,,r+   c                   || j                   v rK| j                   |   j                  r| j                   |   j                  S | j                   |   j                  S | j                  t        | d| j                         || j                  j                  k(  r,| j                  j                  s| j                  j                  S | j                  j                  |      S )  Resolve a name within this object's and parents' scope.

        Parameters:
            name: The name to resolve.

        Raises:
            NameResolutionError: When the name could not be resolved.

        Returns:
            The resolved name.
        z' could not be resolved in the scope of )	r   r   target_pathr  rD   r   rn   r   resolver(   rn   s     r)   r#  zObject.resolve  s      4<<||D!**||D)555<<%*** ;;%.UVZV_V_U`&abb 4;;###DKK,A,A;;### {{""4((r+   r\   c          
     
   | j                   | j                  d}|r>|j                  | j                  | j                  | j
                  | j                  d       | j                  | j                  |d<   | j                  | j                  |d<   | j                  r| j                  |d<   | j                  |d<   | j                  j                         D ci c]  \  }}| |j                  d	d|i| c}}|d<   |S c c}}w )
a%  Return this object's data as a dictionary.

        See also: [`as_json`][griffe.Object.as_json].

        Parameters:
            full: Whether to return full info, or just base info.
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        )rj   rn   )r  rS   r  r  r&   r'   rl   r   r]   r   rA   )rj   rn   updater  rS   r  r  r&   r'   rl   r   r   r   r5   )r(   r]   r4   r`   rn   r   s         r)   r5   zObject.as_dict  s     IIII 

 KK II $)-)?)?151O1O	 ;;"![[DN>>% $D>> $DXY]YeYeYkYkYmnYmv4!DT!DV!DDYmnY os   C?)rn   r/   r&   r6   r'   r6   r   rf   rl   r~   rD   zModule | Class | NonerV   zLinesCollection | Noner   zModulesCollection | Noner7   r8   r9   r   r7   r   rj   zstr | Kind | set[str | Kind]r7   rf   r7   zdict[str, Alias]r   r/   r7   rf   r  z Callable[[Object | Alias], bool]r7   dict[str, Object | Alias]r7   r
  r7   zPath | list[Path]r7   r   r7   r   r7   r   rb   rn   r/   r7   r/   re   ))r<   r=   r>   r?   __annotations__r   r   r   r*   rv   r   r   r@   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  rS   r  r  r  r0   r   rV   rO   rW   r#  r5   rA   r+   r)   r   r   u  s   9
JHd#M4#It " $&*(,377;o$o$ 	o$
 o$ o$ $o$ &o$ 1o$ 5o$ 
o$b`X $ $   &!4 ! !, 
( 
( 	' 	' 	* 	* 	+ 	+          1$ N N.    $ $ )E )EV ! !, # # 	1 	1 
. 
. , , 7 7, - -)B ', %r+   r   c                  N    e Zd ZU dZdZded<   	 dZded<   	 dddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dPd	ZdQd
ZdRdZ	dSdZ
edTd       ZedRd       ZedRd       ZedUd       Zej                   dVd       ZedQd       ZedWd       ZedXd       ZedYd       ZdddZ fdZed[d       Zed\d       Zed\d       Zed]d       Zej                   d^d       Zed_d       Zed`d       Zedad       ZedYd        Zdbd!ZedRd"       ZedRd#       Z edRd$       Z!edRd%       Z"dcd&Z#ddd'Z$eded(       Z%eded)       Z&edfd*       Z'edgd+       Z(edgd,       Z)edQd-       Z*edhd.       Z+edid/       Z,edQd0       Z-djd1Z.edkd2       Z/edld3       Z0edmd4       Z1edRd5       Z2edRd6       Z3edRd7       Z4edRd8       Z5edRd9       Z6edRd:       Z7ednd;       Z8e8j                   dod<       Z8edpd=       Z9edqd>       Z:e:j                   drd?       Z:edsd@       ZedsdA       Z;edqdB       Z<edqdC       Z=e=j                   dtdD       Z=edudE       Z>dvdFZ?edwdG       Z@e@j                   dxdH       Z@edydI       ZAdzdJZBdzdKZCdzdLZDedRdM       ZEed{dN       ZFddd|dOZG xZHS )}r   aY  This class represents an alias, or indirection, to an object declared in another module.

    Aliases represent objects that are in the scope of a module or class,
    but were imported from another module.

    They behave almost exactly like regular objects, to a few exceptions:

    - line numbers are those of the alias, not the target
    - the path is the alias path, not the canonical one
    - the name can be different from the target's
    - if the target can be resolved, the kind is the target's kind
    - if the target cannot be resolved, the kind becomes [Kind.ALIAS][griffe.Kind]
    Trf   r   Fr   N)r&   r'   r   rD   r   c               $   || _         	 || _        	 || _        	 || _        	 || _        	 d| _        	 d| _        	 || _        d| _        |  	 t        |t              rd| _        || _        y|| _        |j                  | _        | j                          y)a4  Initialize the alias.

        Parameters:
            name: The alias name.
            target: If it's a string, the target resolution is delayed until accessing the target property.
                If it's an object, or even another alias, the target is immediately set.
            lineno: The alias starting line number.
            endlineno: The alias ending line number.
            runtime: Whether this alias is present at runtime or not.
            parent: The alias parent.
            inherited: Whether this alias wraps an inherited member.
        NF)rn   alias_linenoalias_endlinenor   r   r   r   _parent_passed_throughr-   r/   _targetr"  r  _update_target_aliases)r(   rn   targetr&   r'   r   rD   r   s           r)   r*   zAlias.__init__  s    . 	(.4+42$9(@#'+-1P6<%*-fc"26DL%D!DL%{{D'')r+   c                <    d| j                   d| j                  dS )NzAlias(r   rt   )rn   r"  rN   s    r)   rv   zAlias.__repr__=  s"    		}Bt'7'7&:!<<r+   c                     y)zAn alias is always true-ish.TrA   rN   s    r)   r   zAlias.__bool__A  r   r+   c                     y)z#The length of an alias is always 1.rQ   rA   rN   s    r)   r   zAlias.__len__E  s    r+   c                z    	 | j                   j                  S # t        t        f$ r t        j
                  cY S w xY w)zThe target's kind, or `Kind.ALIAS` if the target cannot be resolved.

        See also: [`is_kind`][griffe.Alias.is_kind].
        )final_targetrj   r   r   r   ALIASrN   s    r)   rj   z
Alias.kindM  s8    	$$)))$&67 	::	s    ::c                Z    	 | j                   j                  S # t        t        f$ r Y yw xY w)zWhether this alias' target has a non-empty docstring.

        See also: [`has_docstrings`][griffe.Alias.has_docstrings],
        [`docstring`][griffe.Alias.docstring].
        F)rA  r   r   r   rN   s    r)   r   zAlias.has_docstringY  s1    	$$222$&67 		    **c                Z    	 | j                   j                  S # t        t        f$ r Y yw xY w)zWhether this alias' target or any of its members has a non-empty docstring.

        See also: [`has_docstring`][griffe.Alias.has_docstring],
        [`docstring`][griffe.Alias.docstring].
        F)rA  r   r   r   rN   s    r)   r   zAlias.has_docstringse  s1    	$$333$&67 		rD  c                    | j                   S )zThe parent of this alias.)r8  rN   s    r)   rD   zAlias.parentq       ||r+   c                2    || _         | j                          y rd   )r8  r;  r1   s     r)   rD   zAlias.parentv  s    ##%r+   c                L    | j                   j                   d| j                   S )zzThe dotted path / import path of this object.

        See also: [`canonical_path`][griffe.Alias.canonical_path].
        r  )rD   r  rn   rN   s    r)   r  z
Alias.path{  s$     ++""#1TYYK00r+   c                .    | j                   j                  S )z5The modules collection attached to the alias parents.)rD   r   rN   s    r)   r   zAlias.modules_collection  s     {{---r+   c                    | j                   }|j                  j                         D ci c]  \  }}|t        ||| d       c}}S c c}}w )a-  The target's members (modules, classes, functions, attributes).

        See also: [`inherited_members`][griffe.Alias.inherited_members],
        [`get_member`][griffe.Alias.get_member],
        [`set_member`][griffe.Alias.set_member],
        [`filter_members`][griffe.Alias.filter_members].
        Fr<  rD   r   )rA  r   r   r   r(   rA  rn   r   s       r)   r   zAlias.members  sY     (( !- 4 4 : : <
 <f %VDEJJ <
 	
 
   Ac                    | j                   }|j                  j                         D ci c]  \  }}|t        ||| d       c}}S c c}}w )aI  Members that are inherited from base classes.

        Each inherited member of the target will be wrapped in an alias,
        to preserve correct object access paths.

        This method is part of the consumer API:
        do not use when producing Griffe trees!

        See also: [`members`][griffe.Alias.members].
        TrL  )rA  r   r   r   rM  s       r)   r   zAlias.inherited_members  sY     (( !- > > D D F
 Ff %VDDII F
 	
 
rN  r\   c                   	  | j                   j                  dd|i|S # t        t        f$ r t	        |   dd|i|cY S w xY w)a8  Return this target's data as a JSON string.

        See also: [`as_dict`][griffe.Alias.as_dict].

        Parameters:
            full: Whether to return full info, or just base info.
            **kwargs: Additional serialization options passed to encoder.

        Returns:
            A JSON string.
        r]   rA   )rA  as_jsonr   r   super)r(   r]   r4   r   s      r)   rQ  zAlias.as_json  sU    	8,4$$,,A$A&AA$&67 	87?7777	8s   !  AAc                .    | j                   j                  S )zSNamespaced dictionaries storing extra metadata for this object, used by extensions.)rA  r   rN   s    r)   r   zAlias.extra  s       &&&r+   c                .    | j                   j                  S )zqThe starting line number of the target object.

        See also: [`endlineno`][griffe.Alias.endlineno].
        )rA  r&   rN   s    r)   r&   zAlias.lineno         '''r+   c                .    | j                   j                  S )ziThe ending line number of the target object.

        See also: [`lineno`][griffe.Alias.lineno].
        )rA  r'   rN   s    r)   r'   zAlias.endlineno  s       ***r+   c                .    | j                   j                  S )zThe target docstring.

        See also: [`has_docstring`][griffe.Alias.has_docstring],
        [`has_docstrings`][griffe.Alias.has_docstrings].
        rA  rl   rN   s    r)   rl   zAlias.docstring  s       ***r+   c                &    || j                   _        y rd   rX  )r(   rl   s     r)   rl   zAlias.docstring  s    &/#r+   c                .    | j                   j                  S )zwThe target labels (`property`, `dataclass`, etc.).

        See also: [`has_labels`][griffe.Alias.has_labels].
        )rA  r   rN   s    r)   r   zAlias.labels  rU  r+   c                .    | j                   j                  S )a-  The other objects imported by this alias' target.

        Keys are the names within the object (`from ... import ... as AS_NAME`),
        while the values are the actual names of the objects (`from ... import REAL_NAME as ...`).

        See also: [`is_imported`][griffe.Alias.is_imported].
        )rA  r   rN   s    r)   r   zAlias.imports  s       (((r+   c                .    | j                   j                  S )a   The names of the objects exported by this (module) object through the `__all__` variable.

        Exports can contain string (object names) or resolvable names,
        like other lists of exports coming from submodules:

        ```python
        from .submodule import __all__ as submodule_all

        __all__ = ["hello", *submodule_all]
        ```

        Exports get expanded by the loader before it expands wildcards and resolves aliases.

        See also: [`GriffeLoader.expand_exports`][griffe.GriffeLoader.expand_exports].
        )rA  r   rN   s    r)   r   zAlias.exports  s    "   (((r+   c                .    | j                   j                  S )z$The aliases pointing to this object.)rA  r   rN   s    r)   r   zAlias.aliases  s       (((r+   c                8    | j                   j                  |      S )a
  Tell if this object is of the given kind.

        See also: [`is_module`][griffe.Alias.is_module],
        [`is_class`][griffe.Alias.is_class],
        [`is_function`][griffe.Alias.is_function],
        [`is_attribute`][griffe.Alias.is_attribute],
        [`is_alias`][griffe.Alias.is_alias].

        Parameters:
            kind: An instance or set of kinds (strings or enumerations).

        Raises:
            ValueError: When an empty set is given as argument.

        Returns:
            True or False.
        )rA  r   r   s     r)   r   zAlias.is_kind  s    $   ((..r+   c                .    | j                   j                  S )a[  Whether this object is a module.

        See also:  [`is_init_module`][griffe.Alias.is_init_module].
        [`is_class`][griffe.Alias.is_class],
        [`is_function`][griffe.Alias.is_function],
        [`is_attribute`][griffe.Alias.is_attribute],
        [`is_alias`][griffe.Alias.is_alias],
        [`is_kind`][griffe.Alias.is_kind].
        )rA  r   rN   s    r)   r   zAlias.is_module+  s       ***r+   c                .    | j                   j                  S )a"  Whether this object is a class.

        See also: [`is_module`][griffe.Alias.is_module],
        [`is_function`][griffe.Alias.is_function],
        [`is_attribute`][griffe.Alias.is_attribute],
        [`is_alias`][griffe.Alias.is_alias],
        [`is_kind`][griffe.Alias.is_kind].
        )rA  r   rN   s    r)   r   zAlias.is_class8  s       )))r+   c                .    | j                   j                  S )a  Whether this object is a function.

        See also: [`is_module`][griffe.Alias.is_module],
        [`is_class`][griffe.Alias.is_class],
        [`is_attribute`][griffe.Alias.is_attribute],
        [`is_alias`][griffe.Alias.is_alias],
        [`is_kind`][griffe.Alias.is_kind].
        )rA  r   rN   s    r)   r   zAlias.is_functionD  s       ,,,r+   c                .    | j                   j                  S )a  Whether this object is an attribute.

        See also: [`is_module`][griffe.Alias.is_module],
        [`is_class`][griffe.Alias.is_class],
        [`is_function`][griffe.Alias.is_function],
        [`is_alias`][griffe.Alias.is_alias],
        [`is_kind`][griffe.Alias.is_kind].
        )rA  r   rN   s    r)   r   zAlias.is_attributeP  s       ---r+   c                4     | j                   j                  | S )zTell if this object has all the given labels.

        See also: [`labels`][griffe.Alias.labels].

        Parameters:
            *labels: Labels that must be present.

        Returns:
            True or False.
        )rA  r  r  s     r)   r  zAlias.has_labels\  s     ,t  ++V44r+   c                4     | j                   j                  | S )a  Filter and return members based on predicates.

        See also: [`members`][griffe.Alias.members],
        [`get_member`][griffe.Alias.get_member],
        [`set_member`][griffe.Alias.set_member].

        Parameters:
            *predicates: A list of predicates, i.e. callables accepting a member as argument and returning a boolean.

        Returns:
            A dictionary of members.
        )rA  r  )r(   r  s     r)   r  zAlias.filter_membersi  s     0t  //<<r+   c                .    | j                   j                  S )zThe parent module of this object.

        See also: [`package`][griffe.Alias.package].

        Raises:
            ValueError: When the object is not a module and does not have a parent.
        )rA  r  rN   s    r)   r  zAlias.modulex  s       '''r+   c                .    | j                   j                  S )zrThe absolute top module (the package) of this object.

        See also: [`module`][griffe.Alias.module].
        )rA  r  rN   s    r)   r  zAlias.package  s       (((r+   c                .    | j                   j                  S )zThe file path (or directory list for namespace packages) where this object was defined.

        See also: [`relative_filepath`][griffe.Alias.relative_filepath],
        [`relative_package_filepath`][griffe.Alias.relative_package_filepath].
        )rA  rS   rN   s    r)   rS   zAlias.filepath  s       )))r+   c                .    | j                   j                  S )a  The file path where this object was defined, relative to the current working directory.

        If this object's file path is not relative to the current working directory, return its absolute path.

        See also: [`filepath`][griffe.Alias.filepath],
        [`relative_package_filepath`][griffe.Alias.relative_package_filepath].

        Raises:
            ValueError: When the relative path could not be computed.
        )rA  r  rN   s    r)   r  zAlias.relative_filepath  s       222r+   c                .    | j                   j                  S )a$  The file path where this object was defined, relative to the top module path.

        See also: [`filepath`][griffe.Alias.filepath],
        [`relative_filepath`][griffe.Alias.relative_filepath].

        Raises:
            ValueError: When the relative path could not be computed.
        )rA  r  rN   s    r)   r  zAlias.relative_package_filepath  s       :::r+   c                .    | j                   j                  S )zThe full dotted path of this object.

        The canonical path is the path where the object was defined (not imported).

        See also: [`path`][griffe.Alias.path].
        )rA  r0   rN   s    r)   r0   zAlias.canonical_path  s       ///r+   c                .    | j                   j                  S )a  The lines collection attached to this object or its parents.

        See also: [`lines`][griffe.Alias.lines],
        [`source`][griffe.Alias.source].

        Raises:
            ValueError: When no modules collection can be found in the object or its parents.
        )rA  rV   rN   s    r)   rV   zAlias.lines_collection  s       111r+   c                .    | j                   j                  S )zThe lines containing the source of this object.

        See also: [`source`][griffe.Alias.source],
        [`lines_collection`][griffe.Alias.lines_collection].
        )rA  rO   rN   s    r)   rO   zAlias.lines  s       &&&r+   c                .    | j                   j                  S )zThe source code of this object.

        See also: [`lines`][griffe.Alias.lines],
        [`lines_collection`][griffe.Alias.lines_collection].
        )rA  rW   rN   s    r)   rW   zAlias.source  s       '''r+   c                8    | j                   j                  |      S )r!  )rA  r#  r$  s     r)   r#  zAlias.resolve  s       ((..r+   c                J    t        t        | j                        j                  S rd   )r   r
  rA  	_filepathrN   s    r)   rp  zAlias._filepath  s    FD--.888r+   c                J    t        t        | j                        j                  S )zThe class bases.

        See also: [`Class`][griffe.Class],
        [`resolved_bases`][griffe.Alias.resolved_bases],
        [`mro`][griffe.Alias.mro].
        )r   r   rA  basesrN   s    r)   rr  zAlias.bases  s     E4,,-333r+   c                d    t        t        t        t        f   | j                        j
                  S )zzThe class/function decorators.

        See also: [`Function`][griffe.Function],
        [`Class`][griffe.Class].
        )r   r   r   Functionr<  
decoratorsrN   s    r)   ru  zAlias.decorators  s$     E%/*DKK8CCCr+   c                J    t        t        | j                        j                  S ).Whether this module import future annotations.)r   r
  rA  imports_future_annotationsrN   s    r)   rx  z Alias.imports_future_annotations   s     FD--.IIIr+   c                J    t        t        | j                        j                  S )zrWhether this module is an `__init__.py` module.

        See also: [`is_module`][griffe.Alias.is_module].
        )r   r
  rA  r   rN   s    r)   r   zAlias.is_init_module  s     FD--.===r+   c                J    t        t        | j                        j                  S )zyWhether this module is a package (top module).

        See also: [`is_subpackage`][griffe.Alias.is_subpackage].
        )r   r
  rA  r   rN   s    r)   r   zAlias.is_package  s     FD--.999r+   c                J    t        t        | j                        j                  S )ziWhether this module is a subpackage.

        See also: [`is_package`][griffe.Alias.is_package].
        )r   r
  rA  r   rN   s    r)   r   zAlias.is_subpackage  s     FD--.<<<r+   c                J    t        t        | j                        j                  S )zWhether this module is a namespace package (top folder, no `__init__.py`).

        See also: [`is_namespace_subpackage`][griffe.Alias.is_namespace_subpackage].
        )r   r
  rA  r   rN   s    r)   r   zAlias.is_namespace_package  s     FD--.CCCr+   c                J    t        t        | j                        j                  S )zWhether this module is a namespace subpackage.

        See also: [`is_namespace_package`][griffe.Alias.is_namespace_package].
        )r   r
  rA  r   rN   s    r)   r   zAlias.is_namespace_subpackage%  s     FD--.FFFr+   c                n    t        t        t        t        t        f   | j
                        j                  S )zMThe overloaded signatures declared in this class/module or for this function.r   r   r
  r   rt  rA  	overloadsrN   s    r)   r  zAlias.overloads-  s)     E&%12D4E4EFPPPr+   c                f    |t        t        t        t        t        f   | j
                        _        y rd   r  )r(   r  s     r)   r  zAlias.overloads2  s#    LUU65(*+T->->?Ir+   c                d    t        t        t        t        f   | j                        j
                  S )zThe parameters of the current function or `__init__` method for classes.

        This property can fetch inherited members,
        and therefore is part of the consumer API:
        do not use when producing Griffe trees!
        )r   r   r   rt  rA  r   rN   s    r)   r   zAlias.parameters6  s&     E%/*D,=,=>IIIr+   c                J    t        t        | j                        j                  S )z$The function return type annotation.r   rt  rA  returnsrN   s    r)   r  zAlias.returns@  s     Hd//0888r+   c                B    |t        t        | j                        _        y rd   r  )r(   r  s     r)   r  zAlias.returnsE  s    4;Xt(()1r+   c                J    t        t        | j                        j                  S )z.The setter linked to this function (property).)r   	AttributerA  setterrN   s    r)   r  zAlias.setterI  s     It001888r+   c                J    t        t        | j                        j                  S )z/The deleter linked to this function (property).)r   r  rA  deleterrN   s    r)   r  zAlias.deleterN  s     It001999r+   c                J    t        t        | j                        j                  S )zThe attribute value.)r   r  rA  r%   rN   s    r)   r%   zAlias.valueS  s     It001777r+   c                J    t        t        | j                        j                  S )zThe attribute type annotation.r   r  rA  ri   rN   s    r)   ri   zAlias.annotationX  s     It001<<<r+   c                B    |t        t        | j                        _        y rd   r  )r(   ri   s     r)   ri   zAlias.annotation]  s    8BY))*5r+   c                J    t        t        | j                        j                  S )zResolved class bases.

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        )r   r   rA  resolved_basesrN   s    r)   r  zAlias.resolved_basesa  s     E4,,-<<<r+   c                R    t        t        | j                        j                         S )z@Return a list of classes in order corresponding to Python's MRO.)r   r   rA  r   rN   s    r)   r   z	Alias.mroj  s    E4,,-1133r+   c                R    | j                   s| j                          | j                  S )ax  The resolved target (actual object), if possible.

        Upon accessing this property, if the target is not already resolved,
        a lookup is done using the modules collection to find the target.

        See also: [`final_target`][griffe.Alias.final_target],
        [`resolve_target`][griffe.Alias.resolve_target],
        [`resolved`][griffe.Alias.resolved].
        )resolvedresolve_targetr:  rN   s    r)   r<  zAlias.targetr  s!     }}!||r+   c                    || u s|j                   | j                   k(  rt        | j                  g      || _        |j                   | _        | j                  $| | j                  j
                  | j                   <   y y rd   )r  r   r"  r:  rD   r   r1   s     r)   r<  zAlias.target  sf    D=EJJ$))3"D$4$4#566 ::;;".2DLL  + #r+   c                    i }| }|j                   rO|j                  |v rt        g ||j                        d||j                  <   |j                  }|j                   rO|S )a  The final, resolved target, if possible.

        This will iterate through the targets until a non-alias object is found.

        See also: [`target`][griffe.Alias.target],
        [`resolve_target`][griffe.Alias.resolve_target],
        [`resolved`][griffe.Alias.resolved].
        N)r   r  r   r<  )r(   
paths_seenr<  s      r)   rA  zAlias.final_target  sb    " ')
oo{{j(&'A'AV[['ABB&*Jv{{#]]F	 oo
 r+   c                    | j                   rt        | j                  g      d| _         	 | j                          d| _         y# d| _         w xY w)aI  Resolve the target.

        See also: [`target`][griffe.Alias.target],
        [`final_target`][griffe.Alias.final_target],
        [`resolved`][griffe.Alias.resolved].

        Raises:
            AliasResolutionError: When the target cannot be resolved.
                It happens when the target does not exist,
                or could not be loaded (unhandled dynamic object?),
                or when the target is from a module that was not loaded
                and added to the collection.
            CyclicAliasError: When the resolved target is the alias itself.
        TFN)r9  r   r"  _resolve_targetrN   s    r)   r  zAlias.resolve_target  sK    2 "D$4$4#566#	)  "#(D 5D s   A 	Ac                   	 | j                   j                  | j                        }|| u rt        | j                  g      |j                  r|j                  s	 |j                          || _
        | j                  $| | j                  j                  | j                  <   y y # t        $ r}t	        |       |d }~ww xY w# t
        $ r(}t        | j                  g|j                        |d }~ww xY wrd   )r   
get_memberr"  r   r   r   r   r  r  chainr:  rD   r   r  )r(   r  r   s      r)   r  zAlias._resolve_target  s    	8..99$:J:JKH t"D$4$4#566X%6%6T'')  ;;".2DLL  + #  	8&t,%7	8 $ T&(8(8'G5;;'GHeSTs/   %B" B? "	B<+B77B<?	C0#C++C0c                    t        t        t        t              5  | | j                  j
                  | j                  <   d d d        y # 1 sw Y   y xY wrd   )r   AttributeErrorr   r   r:  r   r  rN   s    r)   r;  zAlias._update_target_aliases  s5    n&:<LM.2DLL  + NMMs   $AAc                    | j                   duS )z'Whether this alias' target is resolved.N)r:  rN   s    r)   r  zAlias.resolved  s     ||4''r+   c                R    | j                   j                  d      r| j                  S y)zThe module on which the wildcard import is performed (if any).

        See also: [`GriffeLoader.expand_wildcards`][griffe.GriffeLoader.expand_wildcards].
        z/*N)rn   endswithr"  rN   s    r)   wildcardzAlias.wildcard  s%     99d####r+   c                   t         j                  | j                  | j                  d}|r| j                  |d<   | j
                  r| j
                  |d<   | j                  r| j                  |d<   |S )a"  Return this alias' data as a dictionary.

        See also: [`as_json`][griffe.Alias.as_json].

        Parameters:
            full: Whether to return full info, or just base info.
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        )rj   rn   r"  r  r&   r'   )r   rB  rn   r"  r  r6  r7  r_   s       r)   r5   zAlias.as_dict  sj     JJII++ 
 99DL!..DN $ 4 4Dr+   )rn   r/   r<  zstr | Object | Aliasr&   r6   r'   r6   r   rf   rD   Module | Class | Alias | Noner   rf   r7   r8   r9   r   r'  )r7   r   )r7   r  )r%   zModule | Class | Aliasr7   r8   r0  )r7   r,  r)  )r]   rf   r4   r	   r7   r/   )r7   r   )r7   r6   )r7   r~   )rl   r~   r7   r8   )r7   zset[str])r7   zdict[str, str])r7   z&set[str] | list[str | ExprName] | Noner(  r*  r+  r-  r.  r/  r1  rb   r2  )r7   Path | list[Path] | None)r7   zlist[Expr | str])r7   zlist[Decorator])r7   z1dict[str, list[Function]] | list[Function] | None)r  zlist[Function] | Noner7   r8   r7   r   r7   r}   )r  r}   r7   r8   )r7   zFunction | None)ri   r}   r7   r8   r7   zlist[Object]r7   list[Class])r7   Object | Alias)r%   r  r7   r8   )r7   r   )r7   r8   )r7   z
str | Nonere   )Ir<   r=   r>   r?   r   r3  r   r*   rv   r   r   r@   rj   r   r   rD   r  r  r   r   r   rQ  r   r&   r'   rl   r   r   r   r   r   r   r   r   r   r  r  r  r  rS   r  r  r0   rV   rO   rW   r#  rp  rr  ru  rx  r   r   r   r   r   r  r   r  r  r%   ri   r  r   r<  rA  r  r  r;  r  r  r5   __classcell__r   s   @r)   r   r     sj    Hd"M4 " $048*8* %8*
 8* 8* 8* .8* 8* 
8*t= 	 	 	 	 	 	   ]]& & 1 1 . .
 
 
& 
 
, ', 8, ' ' ( ( + + + + 0 0 ( ( ) ) ) )$ ) )/( 
+ 
+ 	* 	* 	- 	- 	. 	.5= ( ( ) ) * * 3 3 	; 	; 0 0 	2 	2 ' ' ( (/& 9 9 4 4 D D J J > > : : = = D D G G Q Q V V J J 9 9 ^^< < 9 9 : : 8 8 = = C C = =4   ]]3 3  2)B3 3 ( (   ',  r+   r   c                       e Zd ZdZej
                  Zddd fdZddZe	dd       Z
e	dd       Ze	dd       Ze	dd	       Ze	dd
       Ze	dd       Ze	dd       Zd fdZ xZS )r
  z'The class representing a Python module.N)rS   c               Z    t        |   |i | || _        t        t              | _        y)zInitialize the module.

        Parameters:
            *args: See [`griffe.Object`][].
            filepath: The module file path (directory for namespace [sub]packages, none for builtin modules).
            **kwargs: See [`griffe.Object`][].
        N)rR  r*   rp  r   rT   r  )r(   rS   argsr4   r   s       r)   r*   zModule.__init__
  s-     	$)&)3;4?4E@r+   c                b    	 d| j                   dS # t        $ r d| j                  dcY S w xY w)NzModule(rt   )rS   r   rn   rN   s    r)   rv   zModule.__repr__  s=    	,T]]-Q//! 	,TYYM++	,s    ..c                \    | j                   t        | j                        | j                   S )z{The file path of this module.

        Raises:
            BuiltinModuleError: When the instance filepath is None.
        )rp  r   rn   rN   s    r)   rS   zModule.filepath  s'     >>!$TYY//~~r+   c                    d| j                   v xr7 | j                   d   j                  xr | j                   d   j                  dk(  S )rw  r   z__future__.annotations)r   r   r"  rN   s    r)   rx  z!Module.imports_future_annotations(  sK     T\\) T]+44T]+77;SS	
r+   c                    t        | j                  t              ry	 | j                  j                  j	                  dd      d   dk(  S # t
        $ r Y yw xY w)zsWhether this module is an `__init__.py` module.

        See also: [`is_module`][griffe.Module.is_module].
        Fr  rQ   r   r*   )r-   rS   rT   rn   rM   r   rN   s    r)   r   zModule.is_init_module1  sS     dmmT*	==%%++C3A6*DD! 		s   +A	 		AAc                J    t        | j                         xr | j                  S )zzWhether this module is a package (top module).

        See also: [`is_subpackage`][griffe.Module.is_subpackage].
        rf   rD   r   rN   s    r)   r   zModule.is_package>  s!     $$<)<)<<r+   c                H    t        | j                        xr | j                  S )zjWhether this module is a subpackage.

        See also: [`is_package`][griffe.Module.is_package].
        r  rN   s    r)   r   zModule.is_subpackageF  s     DKK 8T%8%88r+   c                v    	 | j                   du xr t        | j                  t              S # t        $ r Y yw xY w)zWhether this module is a namespace package (top folder, no `__init__.py`).

        See also: [`is_namespace_subpackage`][griffe.Module.is_namespace_subpackage].
        NF)rD   r-   rS   rT   r   rN   s    r)   r   zModule.is_namespace_packageN  s8    	;;$&J:dmmT+JJ! 		s   ), 	88c                   	 | j                   duxrf t        | j                  t              xrJ t	        t
        | j                         j                  xs$ t	        t
        | j                         j                  S # t        $ r Y yw xY w)zWhether this module is a namespace subpackage.

        See also: [`is_namespace_package`][griffe.Module.is_namespace_package].
        NF)	rD   r-   rS   rT   r   r
  r   r   r   rN   s    r)   r   zModule.is_namespace_subpackageY  ss    		4' t}}d3 -BBwd6SWS^S^F_FwFw	 " 		s   A5A8 8	BBc                
   t        |   di |}t        | j                  t              r(| j                  D cg c]  }t        |       c}|d<   |S | j                  rt        | j                        |d<   |S d|d<   |S c c}w )zReturn this module's data as a dictionary.

        See also: [`as_json`][griffe.Module.as_json].

        Parameters:
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        rS   NrA   )rR  r5   r-   rp  rT   r/   )r(   r4   r`   r  r   s       r)   r5   zModule.as_dictj  s     w((dnnd+6:nnEndD	nED
 	 ^^"4>>2D   $D  Fs   B )r  r	   rS   r  r4   r	   r7   r8   r9   r.  r   r:   )r<   r=   r>   r?   r   r   rj   r*   rv   r@   rS   rx  r   r   r   r   r   r5   r  r  s   @r)   r
  r
    s    1;;DHL A,   
 
 
 
 = = 9 9      r+   r
  c                       e Zd ZdZej
                  Zddd	 	 	 	 	 	 	 	 	 d
 fdZedd       Z	edd       Z
dddZddZd fd	Z xZS )r   z&The class representing a Python class.N)rr  ru  c                   t        |   |i | |rt        |      ng | _        	 |xs g | _        	 t        t              | _        y)zInitialize the class.

        Parameters:
            *args: See [`griffe.Object`][].
            bases: The list of base classes, if any.
            decorators: The class decorators, if any.
            **kwargs: See [`griffe.Object`][].
        N)rR  r*   rT   rr  ru  r   r  )r(   rr  ru  r  r4   r   s        r)   r*   zClass.__init__  sK     	$)&)6;tE{
	 ,6+;#4?4E?r+   c                h    	 | j                   d   j                  S # t        $ r t               cY S w xY w)zThe parameters of this class' `__init__` method, if any.

        This property fetches inherited members,
        and therefore is part of the consumer API:
        do not use when producing Griffe trees!
        r*   )all_membersr   r   r   rN   s    r)   r   zClass.parameters  s5    	 ##J/::: 	 <	 s    11c                :   g }| j                   D ]Y  }t        |t              r|n|j                  }	 | j                  |   }|j
                  r|j                  }|j                  |       [ |S # t        t        t        f$ r t        j                  d|       Y w xY w)zResolved class bases.

        This method is part of the consumer API:
        do not use when producing Griffe trees!

        See also: [`bases`][griffe.Class.bases],
        [`mro`][griffe.Class.mro].
        zABase class %s is not loaded, or not static, it cannot be resolved)rr  r-   r/   r0   r   r   rA  r   r   r   r   r   r   )r(   r  r`   	base_pathresolved_bases        r)   r  zClass.resolved_bases  s     JJD *4 54;N;NI5 $ 7 7	 B ))$1$>$>M %%m4  	 )*:HE m`bklms   'A--*BBc           
     p   g || j                   }| j                  D cg c]  }|j                  s| }}|s| gS |D ]?  }|j                   |v sdj                  |      d|j                    z   }t	        d|        | gt        g |D cg c]  }|j                  |       c}| S c c}w c c}w )Nz -> z=Cannot compute C3 linearization, inheritance cycle detected: )r  r  r   rU   rR   r   _mro)r(   seenr`   rr  cycles        r)   r  z
Class._mro  s    !!tyy!/3/B/BT/Btdmmd/BT6MDyyD D)d499+,>> #`af`g!hii  S~RE'JED		$E'JRERSS U (Ks   B.B.B3c                (    | j                         dd S )zReturn a list of classes in order corresponding to Python's MRO.

        See also: [`bases`][griffe.Class.bases],
        [`resolved_bases`][griffe.Class.resolved_bases].
        rQ   N)r  rN   s    r)   r   z	Class.mro  s     yy{12r+   c                    t        |   di |}| j                  |d<   | j                  D cg c]  } |j                  di | c}|d<   |S c c}w )zReturn this class' data as a dictionary.

        See also: [`as_json`][griffe.Class.as_json].

        Parameters:
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        rr  ru  rA   )rR  r5   rr  ru  )r(   r4   r`   decr   s       r)   r5   zClass.as_dict  sY     w((

W?COkckk3F3O\ Ps   A)
r  r	   rr  zSequence[Expr | str] | Noneru  list[Decorator] | Noner4   r	   r7   r8   r  r  )rA   )r  ztuple[str, ...]r7   r  r  r:   )r<   r=   r>   r?   r   r   rj   r*   r@   r   r  r  r   r5   r  r  s   @r)   r   r     s    0::D
 .2-1	@@ +@ +	@
 @ 
@< 
  
   ,	T r+   r   c                  z     e Zd ZdZej
                  Zdddd	 	 	 	 	 	 	 	 	 	 	 d fdZedd       Z	d	 fdZ
 xZS )
rt  z)The class representing a Python function.N)r   r  ru  c                   t        |   |i | |xs
 t               | _        	 || _        	 |xs g | _        	 d| _        	 | j                  D ]	  }| |_         y)a0  Initialize the function.

        Parameters:
            *args: See [`griffe.Object`][].
            parameters: The function parameters.
            returns: The function return annotation.
            decorators: The function decorators, if any.
            **kwargs: See [`griffe.Object`][].
        N)rR  r*   r   r   r  ru  r  r.   )r(   r   r  ru  r  r4   r   r   s          r)   r*   zFunction.__init__  sa    " 	$)&)&0&@JL&*12+5+;&049I!%I )r+   c                    | j                   S )z*The type annotation of the returned value.)r  rN   s    r)   ri   zFunction.annotation  rG  r+   c                   t        |   di |}| j                  D cg c]  } |j                  di | c}|d<   | j                  D cg c]  } |j                  di | c}|d<   | j                  |d<   |S c c}w c c}w )zReturn this function's data as a dictionary.

        See also: [`as_json`][griffe.Function.as_json].

        Parameters:
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        ru  r   r  rA   )rR  r5   ru  r   r  )r(   r4   r`   r  rq   r   s        r)   r5   zFunction.as_dict  s     w((?COkckk3F3O\CG??S?%memm5f5?S\,,Y PSs   A<B)r  r	   r   zParameters | Noner  r}   ru  r  r4   r	   r7   r8   r  r:   )r<   r=   r>   r?   r   r   rj   r*   r@   ri   r5   r  r  s   @r)   rt  rt    sw    3==D
 )-%)-1&& && #	&
 +& & 
&<   r+   rt  c                  b     e Zd ZdZej
                  Zddd	 	 	 	 	 	 	 	 	 d fdZd fdZ xZ	S )r  z@The class representing a Python module/class/instance attribute.N)r%   ri   c               b    t        |   |i | || _        	 || _        	 d| _        	 d| _        y)zInitialize the function.

        Parameters:
            *args: See [`griffe.Object`][].
            value: The attribute value, if any.
            annotation: The attribute annotation, if any.
            **kwargs: See [`griffe.Object`][].
        N)rR  r*   r%   ri   r  r  )r(   r%   ri   r  r4   r   s        r)   r*   zAttribute.__init__)  s?     	$)&)(-
"-7,'+1(,2r+   c                    t        |   di |}| j                  | j                  |d<   | j                  | j                  |d<   |S )zReturn this function's data as a dictionary.

        See also: [`as_json`][griffe.Attribute.as_json].

        Parameters:
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        r%   ri   rA   )rR  r5   r%   ri   )r(   r4   r`   r   s      r)   r5   zAttribute.as_dictB  sJ     w((::! JJDM??&!%Dr+   )
r  r	   r%   r}   ri   r}   r4   r	   r7   r8   r:   )
r<   r=   r>   r?   r   r   rj   r*   r5   r  r  s   @r)   r  r  $  sV    J>>D
 $((,	33 !3 &	3
 3 
32 r+   r  ):
__future__r   rH   collectionsr   
contextlibr   pathlibr   textwrapr   typingr   r	   r
   r   r   _griffe.c3linearr   _griffe.docstrings.parsersr   r   _griffe.enumerationsr   r   r   _griffe.exceptionsr   r   r   r   _griffe.expressionsr   r   _griffe.loggerr   _griffe.mixinsr   collections.abcr   _griffe.collectionsr   r   _griffe.docstrings.modelsr   r   	functoolsr    r"   rC   rh   r   r   r   r
  r   rt  r  rA   r+   r)   <module>r     s    #  #    < < + < < < n n 2 ! +(F:( %%
 %
P} }@Q QhW' W'tt	 t	nV VrwV wthF hV7v 7t. .r+   