a
    e	g!                     @  s   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 deZeG dd de	e ZeZdS )z"
Hook wrapper "result" utilities.
    )annotations)TracebackType)Callable)cast)final)Generic)Optional)Tuple)Type)TypeVar
ResultTypec                   @  s   e Zd ZdZdS )HookCallErrorzHook was called incorrectly.N)__name__
__module____qualname____doc__ r   r   Q/var/www/html/llm_bihealth/app/venv/lib/python3.9/site-packages/pluggy/_result.pyr      s   r   c                   @  s   e Zd ZdZdZddddddZed	d
ddZedd
ddZe	dddddZ
dddddZdddddZdd
ddZdS )ResultzYAn object used to inspect and set the result in a :ref:`hook wrapper
    <hookwrappers>`._result
_exceptionzResultType | NonezBaseException | NoneNone)result	exceptionreturnc                 C  s   || _ || _dS :meta private:Nr   )selfr   r   r   r   r   __init__!   s    zResult.__init__z_ExcInfo | None)r   c                 C  s&   | j }|du rdS t|||jfS dS r   )r   type__traceback__)r   excr   r   r   excinfo*   s    zResult.excinfoc                 C  s   | j S )r   )r   )r   r   r   r   r   3   s    zResult.exceptionzCallable[[], ResultType]zResult[ResultType])funcr   c              
   C  sJ   d}d }}z
| }W n( t y> } z|}W Y d}~n
d}~0 0 | ||S )r   TN)BaseException)clsr$   __tracebackhide__r   r   r"   r   r   r   	from_call8   s    
zResult.from_callr   )r   r   c                 C  s   || _ d| _dS )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   r   r   r   force_resultC   s    	zResult.force_resultr%   )r   r   c                 C  s   d| _ || _dS )zForce the result to fail with ``exception``.

        This overrides any previous result or exception.

        .. versionadded:: 1.1.0
        Nr   )r   r   r   r   r   force_exceptionO   s    zResult.force_exceptionc                 C  s.   d}| j }|du rtt| jS ||jdS )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.
        TN)r   r   r   r   with_tracebackr!   )r   r'   r"   r   r   r   
get_resultY   s
    zResult.get_resultN)r   r   r   r   	__slots__r   propertyr#   r   classmethodr(   r)   r*   r,   r   r   r   r   r      s   	

r   N)r   
__future__r   typesr   typingr   r   r   r   r   r	   r
   r   r%   Z_ExcInfor   	Exceptionr   r   Z_Resultr   r   r   r   <module>   s    M