
    g
                        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Ze	j*                  f	 	 	 	 	 	 	 ddZy)    )annotations)PyCF_ONLY_AST)suppress)TYPE_CHECKING)LogLevel)BuiltinModuleError)safe_get_annotation)logger)Expr)	Docstringc                B    t         j                  fdd} || |||       y)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.
    c                2   	 | j                   j                  }t        t        |j                        } || d| j                  xs d|z    d|        y # t        t        f$ r d}Y Ot        $ r' d| j                   j
                  j                   d}Y }w xY w)Nz<module>z	<module: >:r   z: )parentrelative_filepathAttributeError
ValueErrorr   modulenamegetattrr
   valuelineno)	docstringoffsetmessage	log_levelprefixlogs         M/var/www/openai/venv/lib/python3.12/site-packages/_griffe/docstrings/utils.pywarnzdocstring_warning.<locals>.warn&   s    	A%%77F
 fioo.vha)).Q67r'CD 
+ 	 F! 	A !1!1!8!8!=!= >a@F	As   A B',BBN
r   r   r   intr   strr   r   returnNone)r   warning)r   r   r   r   r!   s        r    docstring_warningr(      s%    & U]TdTd E 	FGY/    c                    t        t        t              5  t        | ddt        d      }|j
                  r1t        |j
                  |j                  |      }|xs | cddd       S 	 ddd       | S # 1 sw Y   | S xY w)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   )
annotationr   r   codename_or_exprs        r    parse_docstring_annotationr8   3   s      

 z=[\]99.		 ''#L
  -:
 

 
 
 s   AA22A<Nr"   )r5   r$   r   r   r   r   r%   z
str | Expr)
__future__r   astr   
contextlibr   typingr   _griffe.enumerationsr   _griffe.exceptionsr   _griffe.expressionsr	   _griffe.loggerr
   r   _griffe.modelsr   r'   r(   errorr8    r)   r    <module>rD      s    #     ) 1 3 !(( #**	000 0 	0
 
0F #..  	r)   