o
    Ưh                     @  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 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)TypeVar
ResultTypec                   @  s   e Zd ZdZdS )HookCallErrorzHook was called incorrectly.N)__name__
__module____qualname____doc__ r   r   K/var/www/Befach/backend/venv/lib/python3.10/site-packages/pluggy/_result.pyr      s    r   c                   @  sf   e Zd ZdZdZdd	d
ZedddZed ddZe	d!ddZ
d"ddZd#ddZd$ddZdS )%ResultzYAn object used to inspect and set the result in a :ref:`hook wrapper
    <hookwrappers>`._result
_exception
_tracebackresultResultType | None	exceptionBaseException | NonereturnNonec                 C  s*   || _ || _|dur|j| _dS d| _dS :meta private:Nr   r   __traceback__r   )selfr   r   r   r   r   __init__   s   zResult.__init___ExcInfo | Nonec                 C  s"   | j }|du r	dS t||| jfS r   )r   typer   )r!   excr   r   r   excinfo*   s   zResult.excinfoc                 C  s   | j S )r   )r   )r!   r   r   r   r   3   s   zResult.exceptionfuncCallable[[], ResultType]Result[ResultType]c              
   C  sJ   d}d }}z| }W n t y } z|}W Y d}~nd}~ww | ||S )r   TN)BaseException)clsr'   __tracebackhide__r   r   r%   r   r   r   	from_call8   s   

zResult.from_callr
   c                 C  s   || _ d| _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*   c                 C  s*   d| _ || _|dur|j| _d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_exceptionP   s   zResult.force_exceptionc                 C  s.   d}| j }| j}|du rtt| j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
   r   with_traceback)r!   r,   r%   tbr   r   r   
get_result[   s   
zResult.get_resultN)r   r   r   r   r   r   )r   r#   )r   r   )r'   r(   r   r)   )r   r
   r   r   )r   r*   r   r   )r   r
   )r   r   r   r   	__slots__r"   propertyr&   r   classmethodr-   r.   r/   r2   r   r   r   r   r      s    



r   N)r   
__future__r   typesr   typingr   r   r   r   r   r	   tupler$   r*   _ExcInfor
   	Exceptionr   r   _Resultr   r   r   r   <module>   s    R