o
    Ñ­j  ã                   @  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/html/CropPilot/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 )z�Force 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 | |¡‚)z®Get 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