o
    h)                     @  s  U d Z ddlmZ ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
Z
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ZejdkrVddlmZ ejjZdWddZG dd dejZejZded< dXddZdXddZ dYd!d"Z!dZd[d&d'Z"d\d)d*Z#d+dd,d]d3d4Z$d^d5d6Z%d7d8 e&d9D Z'e'(e)d:d;e)d<d=e)d>d?i d_dBdCZ*dDdE Z+dFdG Z,d`dJdKZ-dadLdMZ.dbdOdPZ/dcdSdTZ0G dUdV dVZ1dS )dz"Python version compatibility code.    )annotations)CallableN)	Parameter)	Signature)Path)Any)Final)NoReturn      )Formatpathstr | os.PathLike[str]returnLEGACY_PATHc                 C  s   t | S )zBInternal wrapper to prepare lazy proxies for legacy_path instances)r   )r    r   O/var/www/html/openai_agents/venv/lib/python3.10/site-packages/_pytest/compat.pylegacy_path#   s   r   c                   @  s   e Zd ZdZdS )
NotSetTyper   N)__name__
__module____qualname__tokenr   r   r   r   r   +   s    r   r   NOTSETfuncobjectboolc                 C  s   t | p
t| ddS )az  Return True if func is a coroutine function (a function defined with async
    def syntax, and doesn't contain yield), or a function decorated with
    @asyncio.coroutine.

    Note: copied and modified from Python 3.5's builtin coroutines.py to avoid
    importing asyncio directly, which in turns also initializes the "logging"
    module as a side-effect (see issue #8).
    _is_coroutineF)inspectiscoroutinefunctiongetattrr   r   r   r   r    1   s   	r    c                 C  s   t | pt| S )zZReturn True if the given function seems to be an async function or
    an async generator.)r    r   isasyncgenfunctionr"   r   r   r   is_async_function=   s   r$   objCallable[..., Any]r   c                 C  s$   t jdkrtj| tjdS t| S )z0Return signature without evaluating annotations.r
   )annotation_format)sysversion_infor   	signaturer   STRINGr%   r   r   r   r*   C   s   

r*   curdirstr | os.PathLike[str] | Nonestrc                 C  sl   t | } tt| }| jj}|d ur-z||}W n	 ty#   Y n
w | d|d  S | d|d  S )N:   )get_real_funcr   r   getfile__code__co_firstlinenorelative_to
ValueError)functionr-   fnlinenorelfnr   r   r   getlocationJ   s   r<   intc                   sX   t | dd}|s
dS t tjddt  t tjddt t fdd|D S )	z>Return number of arguments used up by mock arguments (if any).	patchingsNr   mockDEFAULTzunittest.mockc                   s*   g | ]}|j s|j u s|ju r|qS r   )attribute_namenew.0pmock_sentinelut_mock_sentinelr   r   
<listcomp>b   s    z'num_mock_patch_args.<locals>.<listcomp>)r!   r(   modulesgetr   len)r8   r>   r   rF   r   num_mock_patch_argsX   s   rM    )nameclsr8   Callable[..., object]rO   rP   type | Nonetuple[str, ...]c             
   C  s   z	t | j }W n& ttfy/ } zddlm} |d| d| dd W Y d}~nd}~ww tdd	 |D }|s>| j}t	d
d	 |D sZ|rZt
tj||ddtsZ|dd }t| drg|t| d }|S )a   Return the names of a function's mandatory arguments.

    Should return the names of all function arguments that:
    * Aren't bound to an instance or type as in instance or class methods.
    * Don't have default values.
    * Aren't bound with functools.partial.
    * Aren't replaced with mocks.

    The cls arguments indicate that the function should be treated as a bound
    method even though it's not unless the function is a static method.

    The name parameter should be the original name in which the function was collected.
    r   )failz!Could not determine arguments of z: F)pytraceNc                 s  s:    | ]}|j tju s|j tju r|jtju r|jV  qd S Nkindr   POSITIONAL_OR_KEYWORDKEYWORD_ONLYdefaultemptyrO   rC   r   r   r   	<genexpr>   s    z"getfuncargnames.<locals>.<genexpr>c                 s  s    | ]	}|j tju V  qd S rV   )rX   r   POSITIONAL_ONLYrC   r   r   r   r]      s    )r[   r1   __wrapped__)r*   
parametersvaluesr7   	TypeError_pytest.outcomesrT   tupler   any
isinstancer   getattr_staticstaticmethodhasattrrM   )r8   rO   rP   r`   erT   	arg_namesr   r   r   getfuncargnamesk   s4   	
rl   c                 C  s   t dd t| j D S )Nc                 s  s4    | ]}|j tjtjfv r|jtjur|jV  qd S rV   rW   rC   r   r   r   r]      s    z(get_default_arg_names.<locals>.<genexpr>)rd   r*   r`   ra   )r8   r   r   r   get_default_arg_names   s   rm   c                 C  s(   i | ]}|t d dvr|d|dqS )       z\x02x)range)rD   ir   r   r   
<dictcomp>   s    "rs      	z\tz\r
z\nvalbytes | strc                 C  s2   t | tr| dd}n| dd}|tS )a	  If val is pure ASCII, return it as an str, otherwise, escape
    bytes objects into a sequence of escaped bytes:

    b'\xc3\xb4\xc5\xd6' -> r'\xc3\xb4\xc5\xd6'

    and escapes strings into a sequence of escaped unicode ids, e.g.:

    r'4\nV\U00043efa\x0eMXWB\x1e\u3028\u15fd\xcd\U0007d944'

    Note:
       The obvious "v.decode('unicode-escape')" will return
       valid UTF-8 unicode if it finds them in bytes, but we
       want to return escaped bytes for any byte, even if they match
       a UTF-8 string.
    asciibackslashreplaceunicode_escape)rf   bytesdecodeencode	translate$_non_printable_ascii_translate_table)rx   retr   r   r   ascii_escaped   s   

r   c                 C  s    t | } t| tjr| j} | S )z{Get the real function object of the (possibly) wrapped object by
    :func:`functools.wraps`, or :func:`functools.partial`.)r   unwraprf   	functoolspartialr   r,   r   r   r   r2      s   
r2   c                 C  s    z| j W S  ty   |  Y S w rV   )__func__AttributeErrorr"   r   r   r   	getimfunc   s
   r   r   r[   c                 C  s2   ddl m} zt| ||W S  |y   | Y S w )aR  Like getattr but return default upon any Exception or any OutcomeException.

    Attribute access can potentially fail for 'evil' Python objects.
    See issue #214.
    It catches OutcomeException because of #2490 (issue #580), new outcomes
    are derived from BaseException instead of Exception (for more details
    check #2707).
    r   )TEST_OUTCOME)rc   r   r!   )r   rO   r[   r   r   r   r   safe_getattr   s   	r   c                 C  s"   zt | W S  ty   Y dS w )z0Ignore any exception via isinstance on Python 3.F)r   isclass	Exceptionr,   r   r   r   safe_isclass   s
   r   
int | Nonec                  C  s4   t jdks
t jdkrdS d} t }|| kr|S dS )zReturn the current process's real user id or None if it could not be
    determined.

    :return: The user id or None if it could not be determined.
    win32
emscriptenN)r(   platformosgetuid)ERRORuidr   r   r   get_user_id  s
   	r   valuer	   c                 C  s   J d|  dt | j d)NFzUnhandled value: z ())typer   )r   r   r   r   assert_never8  s   r   c                   @  s.   e Zd ZdZdddZddd	Zdd
dZdS )CallableBoola'  
    A bool-like object that can also be called, returning its true/false value.

    Used for backwards compatibility in cases where something was supposed to be a method
    but was implemented as a simple attribute by mistake (see `TerminalReporter.isatty`).

    Do not use in new code.
    r   r   r   Nonec                 C  s
   || _ d S rV   _value)selfr   r   r   r   __init__F  s   
zCallableBool.__init__c                 C     | j S rV   r   r   r   r   r   __bool__I     zCallableBool.__bool__c                 C  r   rV   r   r   r   r   r   __call__L  r   zCallableBool.__call__N)r   r   r   r   )r   r   )r   r   r   __doc__r   r   r   r   r   r   r   r   <  s
    
	
r   )r   r   r   r   )r   r   r   r   )r%   r&   r   r   rV   )r-   r.   r   r/   )r   r=   )r8   rQ   rO   r/   rP   rR   r   rS   )r8   r&   r   rS   )rx   ry   r   r/   )r   r   rO   r/   r[   r   r   r   )r%   r   r   r   )r   r   )r   r	   r   r	   )2r   
__future__r   collections.abcr   enumr   r   r   r   r   pathlibr   r(   typingr   r   r	   pyr)   annotationlibr   r   localr   r   Enumr   r   r   __annotations__r    r$   r*   r<   rM   rl   rm   rq   r   updateordr   r2   r   r   r   r   r   r   r   r   r   r   <module>   sX   






D





4