o
    Ye                      @  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   2usr/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resultResultType | None	exceptionBaseException | NonereturnNonec                 C  s   || _ || _dS :meta private:Nr   )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   type__traceback__)r    excr   r   r   excinfo)   s   zResult.excinfoc                 C  s   | j S )r   )r   )r    r   r   r   r   2   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_call7   s   

zResult.from_callr   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_resultB   s   	
zResult.force_resultr*   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_exceptionN   s   
zResult.force_exceptionc                 C  s*   d}| j }|du rtt| jS ||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.
        TN)r   r   r   r   with_tracebackr$   )r    r,   r%   r   r   r   
get_resultX   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/   r1   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