o
    h=                     @  s|  d dl mZ d dl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 G dd	 d	ZG d
d deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG d d! d!eZG d"d# d#eZG d$d% d%eZG d&d' d'eZG d(d) d)ZG d*d+ d+eZG d,d- d-eZG d.d/ d/eZ G d0d1 d1eZ!G d2d3 d3eZ"G d4d5 d5eZ#G d6d7 d7eZ$G d8d9 d9eZ%G d:d; d;eZ&G d<d= d=eZ'G d>d? d?eZ(G d@dA dAeZ)G dBdC dCeZ*G dDdE dEeZ+G dFdG dGeZ,G dHdI dIeZ-G dJdK dKeZ.dLS )M    )annotations)TYPE_CHECKING)DocstringSectionKind)	ExprTuple)Sequence)AnyLiteral)Exprc                   @  s*   e Zd ZdZdddd
dZdddZdS )DocstringElementz8This base class represents annotated, nameless elements.N
annotationdescriptionstrr   str | Expr | NonereturnNonec                C  s   || _ 	 || _dS )zInitialize the element.

        Parameters:
            annotation: The element annotation, if any.
            description: The element description.
        Nr   r   )selfr   r    r   c/var/www/html/openai_agents/venv/lib/python3.10/site-packages/griffe/_internal/docstrings/models.py__init__   s   zDocstringElement.__init__kwargsr   dict[str, Any]c                 K  s   | j | jdS )Return this element's data as a dictionary.

        Parameters:
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        r   r   r   )r   r   r   r   r   as_dict!   s   
zDocstringElement.as_dict)r   r   r   r   r   r   r   r   r   r   )__name__
__module____qualname____doc__r   r   r   r   r   r   r
      s    r
   c                      s8   e Zd ZdZdddd fddZd fddZ  ZS )DocstringNamedElementz5This base class represents annotated, named elements.N)r   valuenamer   r   r   r   r"   r   r   c                  s"   t  j||d || _	 || _dS )zInitialize the element.

        Parameters:
            name: The element name.
            description: The element description.
            annotation: The element annotation, if any.
            value: The element value, as a string.
        r   N)superr   r#   r"   )r   r#   r   r   r"   	__class__r   r   r   3   s
   zDocstringNamedElement.__init__r   r   r   c                   s4   d| j it jdi |}| jdur| j|d< |S )r   r#   Nr"   r   )r#   r$   r   r"   )r   r   baser%   r   r   r   I   s   	

zDocstringNamedElement.as_dict)
r#   r   r   r   r   r   r"   r   r   r   r   )r   r   r   r    r   r   __classcell__r   r   r%   r   r!   0   s    r!   c                   @  sL   e Zd ZdZedddZejdd	dZedddZejdddZdS )DocstringAdmonitionz$This class represents an admonition.r   r   c                 C     | j S )zThe kind of this admonition.r   r   r   r   r   kind[      zDocstringAdmonition.kindr"   
str | Exprr   c                 C  
   || _ d S Nr   r   r"   r   r   r   r,   `      
r   c                 C  r*   )z The contents of this admonition.r   r+   r   r   r   contentsd   r-   zDocstringAdmonition.contentsc                 C  r/   r0   r3   r1   r   r   r   r4   i   r2   Nr   r   )r"   r.   r   r   r   r   r"   r   r   r   )r   r   r   r    propertyr,   setterr4   r   r   r   r   r)   X   s    r)   c                   @  s.   e Zd ZdZed
ddZejdddZd	S )DocstringDeprecatedz3This class represents a documented deprecated item.r   r   c                 C  r*   )z The version of this deprecation.r   r+   r   r   r   versionq   r-   zDocstringDeprecated.versionr"   r   c                 C  r/   r0   r   r1   r   r   r   r;   v   r2   Nr6   r7   )r   r   r   r    r8   r;   r9   r   r   r   r   r:   n       r:   c                   @     e Zd ZdZdS )DocstringRaisez/This class represents a documented raise value.Nr   r   r   r    r   r   r   r   r>   {       r>   c                   @  r=   )DocstringWarnz.This class represents a documented warn value.Nr?   r   r   r   r   rA      r@   rA   c                   @  r=   )DocstringReturnz0This class represents a documented return value.Nr?   r   r   r   r   rB      r@   rB   c                   @  r=   )DocstringYieldz/This class represents a documented yield value.Nr?   r   r   r   r   rC      r@   rC   c                   @  r=   )DocstringReceivez1This class represents a documented receive value.Nr?   r   r   r   r   rD      r@   rD   c                   @  s.   e Zd ZdZedddZejdd	dZd
S )DocstringParameterz5This class represent a documented function parameter.r   r   c                 C  r*   )z$The default value of this parameter.r"   r+   r   r   r   default   r-   zDocstringParameter.defaultr"   r   r   c                 C  r/   r0   rF   r1   r   r   r   rG      r2   Nr5   r7   )r   r   r   r    r8   rG   r9   r   r   r   r   rE      r<   rE   c                   @  sj   e Zd ZdZedddZejdd	dZedd
dZejdddZedddZejdddZdS )DocstringTypeParameterz1This class represent a documented type parameter.r   r   c                 C  r*   )z)The default value of this type parameter.rF   r+   r   r   r   rG      r-   zDocstringTypeParameter.defaultr"   r   r   c                 C  r/   r0   rF   r1   r   r   r   rG      r2   c                 C  s   t | jts	| jS dS )z!The bound of this type parameter.N)
isinstancer   r   r+   r   r   r   bound   s   zDocstringTypeParameter.boundrJ   c                 C  r/   r0   r   )r   rJ   r   r   r   rJ      r2   tuple[str | Expr, ...] | Nonec                 C  s   t | jtrt| jjS dS )z'The constraints of this type parameter.N)rI   r   r   tupleelementsr+   r   r   r   constraints   s   z"DocstringTypeParameter.constraintsrN   Sequence[str | Expr] | Nonec                 C  s    |d urt || _d S d | _d S r0   )r   r   )r   rN   r   r   r   rN      s   
Nr5   r7   )rJ   r   r   r   )r   rK   )rN   rO   r   r   )	r   r   r   r    r8   rG   r9   rJ   rN   r   r   r   r   rH      s    rH   c                   @  r=   )DocstringAttributez:This class represents a documented module/class attribute.Nr?   r   r   r   r   rP      r@   rP   c                   @     e Zd ZdZedddZdS )DocstringFunctionz,This class represents a documented function.r   r   c                 C  r*   )zThe function signature.r   r+   r   r   r   	signature   r-   zDocstringFunction.signatureNr5   r   r   r   r    r8   rS   r   r   r   r   rR          rR   c                   @  rQ   )DocstringClassz)This class represents a documented class.r   r   c                 C  r*   )zThe class signature.r   r+   r   r   r   rS      r-   zDocstringClass.signatureNr5   rT   r   r   r   r   rV      rU   rV   c                   @  r=   )DocstringTypeAliasz.This class represents a documented type alias.Nr?   r   r   r   r   rW      r@   rW   c                   @  r=   )DocstringModulez*This class represents a documented module.Nr?   r   r   r   r   rX      r@   rX   c                   @  s<   e Zd ZU dZded< 	 ddd	d
ZdddZdddZdS )DocstringSectionz*This class represents a docstring section.r   r,   Ntitle
str | Noner   r   c                 C  s   || _ 	 d| _dS )z[Initialize the section.

        Parameters:
            title: An optional title.
        N)rZ   r"   )r   rZ   r   r   r   r      s   zDocstringSection.__init__boolc                 C  s
   t | jS )z*Whether this section has a true-ish value.)r\   r"   r+   r   r   r   __bool__   r2   zDocstringSection.__bool__r   r   r   c                 K  sH   t | jdr| jjdi |}n| j}| jj|d}| jr"| j|d< |S )zReturn this section's data as a dictionary.

        Parameters:
            **kwargs: Additional serialization options.

        Returns:
            A dictionary.
        r   )r,   r"   rZ   Nr   )hasattrr"   r   r,   rZ   )r   r   serialized_valuer'   r   r   r   r      s   	
zDocstringSection.as_dictr0   )rZ   r[   r   r   )r   r\   r   )r   r   r   r    __annotations__r   r]   r   r   r   r   r   rY      s   
 
rY   c                      4   e Zd ZU dZejZded< dd fddZ  Z	S )DocstringSectionTextz%This class represents a text section.r   r,   Nr"   r   rZ   r[   r   r   c                      t  | || _dS )zInitialize the section.

        Parameters:
            value: The section text.
            title: An optional title.
        Nr$   r   r"   r   r"   rZ   r%   r   r   r        
zDocstringSectionText.__init__r0   )r"   r   rZ   r[   r   r   )
r   r   r   r    r   textr,   r`   r   r(   r   r   r%   r   rb   	     
 rb   c                      ra   )DocstringSectionParametersz+This class represents a parameters section.r   r,   Nr"   list[DocstringParameter]rZ   r[   r   r   c                   rc   )zInitialize the section.

        Parameters:
            value: The section parameters.
            title: An optional title.
        Nrd   re   r%   r   r   r     rf   z#DocstringSectionParameters.__init__r0   )r"   rj   rZ   r[   r   r   )
r   r   r   r    r   
parametersr,   r`   r   r(   r   r   r%   r   ri     rh   ri   c                   @  s    e Zd ZU dZejZded< dS )DocstringSectionOtherParametersz2This class represents an other parameters section.r   r,   N)r   r   r   r    r   other_parametersr,   r`   r   r   r   r   rl   )  s   
 rl   c                      ra   )DocstringSectionTypeParametersz0This class represents a type parameters section.r   r,   Nr"   list[DocstringTypeParameter]rZ   r[   r   r   c                   rc   )zInitialize the section.

        Parameters:
            value: The section type parameters.
            title: An optional title.
        Nrd   re   r%   r   r   r   4  rf   z'DocstringSectionTypeParameters.__init__r0   )r"   ro   rZ   r[   r   r   )
r   r   r   r    r   type_parametersr,   r`   r   r(   r   r   r%   r   rn   /  rh   rn   c                      ra   )DocstringSectionRaisesz'This class represents a raises section.r   r,   Nr"   list[DocstringRaise]rZ   r[   r   r   c                   rc   )zInitialize the section.

        Parameters:
            value: The section exceptions.
            title: An optional title.
        Nrd   re   r%   r   r   r   D  rf   zDocstringSectionRaises.__init__r0   )r"   rr   rZ   r[   r   r   )
r   r   r   r    r   raisesr,   r`   r   r(   r   r   r%   r   rq   ?  rh   rq   c                      ra   )DocstringSectionWarnsz&This class represents a warns section.r   r,   Nr"   list[DocstringWarn]rZ   r[   r   r   c                   rc   )zInitialize the section.

        Parameters:
            value: The section warnings.
            title: An optional title.
        Nrd   re   r%   r   r   r   T  rf   zDocstringSectionWarns.__init__r0   )r"   ru   rZ   r[   r   r   )
r   r   r   r    r   warnsr,   r`   r   r(   r   r   r%   r   rt   O  rh   rt   c                      ra   )DocstringSectionReturnsz(This class represents a returns section.r   r,   Nr"   list[DocstringReturn]rZ   r[   r   r   c                   rc   )zInitialize the section.

        Parameters:
            value: The section returned items.
            title: An optional title.
        Nrd   re   r%   r   r   r   d  rf   z DocstringSectionReturns.__init__r0   )r"   rx   rZ   r[   r   r   )
r   r   r   r    r   returnsr,   r`   r   r(   r   r   r%   r   rw   _  rh   rw   c                      ra   )DocstringSectionYieldsz'This class represents a yields section.r   r,   Nr"   list[DocstringYield]rZ   r[   r   r   c                   rc   )zInitialize the section.

        Parameters:
            value: The section yielded items.
            title: An optional title.
        Nrd   re   r%   r   r   r   t  rf   zDocstringSectionYields.__init__r0   )r"   r{   rZ   r[   r   r   )
r   r   r   r    r   yieldsr,   r`   r   r(   r   r   r%   r   rz   o  rh   rz   c                      ra   )DocstringSectionReceivesz)This class represents a receives section.r   r,   Nr"   list[DocstringReceive]rZ   r[   r   r   c                   rc   )zInitialize the section.

        Parameters:
            value: The section received items.
            title: An optional title.
        Nrd   re   r%   r   r   r     rf   z!DocstringSectionReceives.__init__r0   )r"   r~   rZ   r[   r   r   )
r   r   r   r    r   receivesr,   r`   r   r(   r   r   r%   r   r}     rh   r}   c                      s6   e Zd ZU dZejZded< 	dd fddZ  Z	S )DocstringSectionExamplesz*This class represents an examples section.r   r,   Nr"   Slist[tuple[Literal[DocstringSectionKind.text, DocstringSectionKind.examples], str]]rZ   r[   r   r   c                   rc   )zInitialize the section.

        Parameters:
            value: The section examples.
            title: An optional title.
        Nrd   re   r%   r   r   r     s   
z!DocstringSectionExamples.__init__r0   )r"   r   rZ   r[   r   r   )
r   r   r   r    r   examplesr,   r`   r   r(   r   r   r%   r   r     s
   
 r   c                      ra   )DocstringSectionAttributesz,This class represents an attributes section.r   r,   Nr"   list[DocstringAttribute]rZ   r[   r   r   c                   rc   )zInitialize the section.

        Parameters:
            value: The section attributes.
            title: An optional title.
        Nrd   re   r%   r   r   r     rf   z#DocstringSectionAttributes.__init__r0   )r"   r   rZ   r[   r   r   )
r   r   r   r    r   
attributesr,   r`   r   r(   r   r   r%   r   r     rh   r   c                      ra   )DocstringSectionFunctionsz2This class represents a functions/methods section.r   r,   Nr"   list[DocstringFunction]rZ   r[   r   r   c                   rc   )zInitialize the section.

        Parameters:
            value: The section functions.
            title: An optional title.
        Nrd   re   r%   r   r   r     rf   z"DocstringSectionFunctions.__init__r0   )r"   r   rZ   r[   r   r   )
r   r   r   r    r   	functionsr,   r`   r   r(   r   r   r%   r   r     rh   r   c                      ra   )DocstringSectionClassesz(This class represents a classes section.r   r,   Nr"   list[DocstringClass]rZ   r[   r   r   c                   rc   zInitialize the section.

        Parameters:
            value: The section classes.
            title: An optional title.
        Nrd   re   r%   r   r   r     rf   z DocstringSectionClasses.__init__r0   )r"   r   rZ   r[   r   r   )
r   r   r   r    r   classesr,   r`   r   r(   r   r   r%   r   r     rh   r   c                      ra   )DocstringSectionTypeAliasesz-This class represents a type aliases section.r   r,   Nr"   list[DocstringTypeAlias]rZ   r[   r   r   c                   rc   r   rd   re   r%   r   r   r     rf   z$DocstringSectionTypeAliases.__init__r0   )r"   r   rZ   r[   r   r   )
r   r   r   r    r   type_aliasesr,   r`   r   r(   r   r   r%   r   r     rh   r   c                      ra   )DocstringSectionModulesz(This class represents a modules section.r   r,   Nr"   list[DocstringModule]rZ   r[   r   r   c                   rc   )zInitialize the section.

        Parameters:
            value: The section modules.
            title: An optional title.
        Nrd   re   r%   r   r   r     rf   z DocstringSectionModules.__init__r0   )r"   r   rZ   r[   r   r   )
r   r   r   r    r   modulesr,   r`   r   r(   r   r   r%   r   r     rh   r   c                      s4   e Zd ZU dZejZded< dd fddZ  Z	S )DocstringSectionDeprecatedz+This class represents a deprecated section.r   r,   Nr;   r   rg   rZ   r[   r   r   c                      t  | t||d| _dS )zInitialize the section.

        Parameters:
            version: The deprecation version.
            text: The deprecation text.
            title: An optional title.
        r   N)r$   r   r:   r"   )r   r;   rg   rZ   r%   r   r   r        z#DocstringSectionDeprecated.__init__r0   )r;   r   rg   r   rZ   r[   r   r   )
r   r   r   r    r   
deprecatedr,   r`   r   r(   r   r   r%   r   r     rh   r   c                      ra   )DocstringSectionAdmonitionz,This class represents an admonition section.r   r,   Nr   rg   rZ   r[   r   r   c                   r   )zInitialize the section.

        Parameters:
            kind: The admonition kind.
            text: The admonition text.
            title: An optional title.
        r   N)r$   r   r)   r"   )r   r,   rg   rZ   r%   r   r   r   	  r   z#DocstringSectionAdmonition.__init__r0   )r,   r   rg   r   rZ   r[   r   r   )
r   r   r   r    r   
admonitionr,   r`   r   r(   r   r   r%   r   r     rh   r   N)/
__future__r   typingr   griffe._internal.enumerationsr   griffe._internal.expressionsr   collections.abcr   r   r   r	   r
   r!   r)   r:   r>   rA   rB   rC   rD   rE   rH   rP   rR   rV   rW   rX   rY   rb   ri   rl   rn   rq   rt   rw   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   <module>   sT   (&		(