
    g!                        d 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
 dd	lmZ dd
lmZ ddlmZ eee   ee
e   f   Z ed      Z G d de      Ze G d de	e                ZeZy)z"
Hook wrapper "result" utilities.
    )annotations)TracebackType)Callable)cast)final)Generic)Optional)Tuple)Type)TypeVar
ResultTypec                      e Zd ZdZy)HookCallErrorzHook was called incorrectly.N)__name__
__module____qualname____doc__     C/var/www/openai/venv/lib/python3.12/site-packages/pluggy/_result.pyr   r      s    &r   r   c                  v    e Zd ZdZdZ	 	 	 	 	 	 ddZedd       Zedd       Ze	dd       Z
ddZddZdd	Zy
)ResultzYAn object used to inspect and set the result in a :ref:`hook wrapper
    <hookwrappers>`._result
_exceptionc                     || _         || _        y:meta private:Nr   )selfresult	exceptions      r   __init__zResult.__init__!   s     #r   c                P    | j                   }|yt        |      ||j                  fS r   )r   type__traceback__)r   excs     r   excinfozResult.excinfo*   s,     oo;IsC$5$566r   c                    | j                   S )r   )r   )r   s    r   r!   zResult.exception3   s     r   c                `    d}dx}}	  |       } | ||      S # t         $ r}|}Y d}~d}~ww xY w)r   TN)BaseException)clsfunc__tracebackhide__r    r!   r&   s         r   	from_callzResult.from_call8   sF     !!!	VF 69%%  	I	s    	-(-c                     || _         d| _        y)a,  Force the result(s) to ``result``.

        If the hook was marked as a ``firstresult`` a single value should
        be set, otherwise set a (modified) list of results. Any exceptions
        found during invocation will be deleted.

        This overrides any previous result or exception.
        Nr   )r   r    s     r   force_resultzResult.force_resultC   s     r   c                     d| _         || _        y)zForce the result to fail with ``exception``.

        This overrides any previous result or exception.

        .. versionadded:: 1.1.0
        Nr   )r   r!   s     r   force_exceptionzResult.force_exceptionO   s     #r   c                    d}| j                   }|t        t        | j                        S |j	                  |j
                        )zGet the result(s) for this hook call.

        If the hook was marked as a ``firstresult`` only a single value
        will be returned, otherwise a list of results.
        T)r   r   r   r   with_tracebackr%   )r   r-   r&   s      r   
get_resultzResult.get_resultY   s@     !oo;
DLL11$$S%6%677r   N)r    zResultType | Noner!   BaseException | NonereturnNone)r7   z_ExcInfo | None)r7   r6   )r,   zCallable[[], ResultType]r7   zResult[ResultType])r    r   r7   r8   )r!   r*   r7   r8   )r7   r   )r   r   r   r   	__slots__r"   propertyr'   r!   classmethodr.   r0   r2   r5   r   r   r   r   r      sz     *I$!$ ($ 
	$ 7 7   & &
$8r   r   N)r   
__future__r   typesr   typingr   r   r   r   r	   r
   r   r   r*   _ExcInfor   	Exceptionr   r   _Resultr   r   r   <module>rB      s    #          m$mXm5LLM\"
'I ' I8WZ  I8 I8Z r   