o
    h
                     @  s   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ er>d d	lmZ d d
lmZ e	jfdddZe	jfdddZdS )    )annotations)PyCF_ONLY_AST)suppress)TYPE_CHECKING)LogLevel)BuiltinModuleError)safe_get_annotation)logger)Expr)	Docstring	docstringr   offsetintmessagestr	log_levelr   returnNonec                 C  s"   t jfddd}|| ||| dS )az  Log a warning when parsing a docstring.

    This function logs a warning message by prefixing it with the filepath and line number.

    Parameters:
        docstring: The docstring object.
        offset: The offset in the docstring lines.
        message: The message to log.

    Returns:
        A function used to log parsing warnings if `name` was passed, else none.
    r   r   r   r   r   r   r   r   r   r   c              	   S  s|   z| j j}W n ttfy   d}Y n ty$   d| j jj d}Y nw tt|j	}|| d| j
p3d|  d|  d S )Nz<module>z	<module: >:r   z: )parentrelative_filepathAttributeError
ValueErrorr   modulenamegetattrr	   valuelineno)r   r   r   r   prefixlog r!   b/var/www/html/openai_agents/venv/lib/python3.10/site-packages/griffe/_internal/docstrings/utils.pywarn&   s   &zdocstring_warning.<locals>.warnN
r   r   r   r   r   r   r   r   r   r   )r   warning)r   r   r   r   r#   r!   r!   r"   docstring_warning   s   
r&   
annotation
str | Exprc                 C  sp   t tt) t| ddtdd}|jr&t|j|j|d}|p| W  d   S W d   | S 1 s1w   Y  | S )a  Parse a string into a true name or expression that can be resolved later.

    Parameters:
        annotation: The annotation to parse.
        docstring: The docstring in which the annotation appears.
            The docstring's parent is accessed to bind a resolver to the resulting name/expression.
        log_level: Log level to use to log a message.

    Returns:
        The string unchanged, or a new name or expression.
    eval    )modefilenameflagsoptimize)r   r   N)r   r   SyntaxErrorcompiler   bodyr   r   )r'   r   r   codename_or_exprr!   r!   r"   parse_docstring_annotation3   s$   
r5   Nr$   )r'   r   r   r   r   r   r   r(   )
__future__r   astr   
contextlibr   typingr   griffe._internal.enumerationsr   griffe._internal.exceptionsr   griffe._internal.expressionsr   griffe._internal.loggerr	   r
   griffe._internal.modelsr   r%   r&   errorr5   r!   r!   r!   r"   <module>   s   #