a
    'ñ»j  ã                   @  s¸  d dl mZ d dlZd dlmZmZmZmZmZm	Z	m
Z
mZmZmZ d dlZddlmZmZ erzd dlmZmZ edƒZndd	„ Zg d
¢Zeddd�ZedƒZedddddœdd„ƒZedddddœdd„ƒZdddddœdd„Zedddddœdd„ƒZedddddœdd„ƒZdddddœd d„Zejd!d!dd"�G d#d$„ d$eje	e ƒƒZeejdd!dd%�G d&d'„ d'ee e	e ƒƒƒZeejdd!dd%�G d(d„ dee
 ƒƒƒZeee ef Z dS ))é    )ÚannotationsN)
ÚTYPE_CHECKINGÚAsyncGeneratorÚ	AwaitableÚCallableÚ	GeneratorÚGenericÚNoReturnÚTypeVarÚUnionÚoverloadé   )ÚAlreadyUsedErrorÚremove_tb_frames)Ú	ParamSpecÚfinalÚArgsTc                 C  s   | S ©N© )Úfuncr   r   ú3E:\soccer\ml_env\Lib\site-packages\outcome/_impl.pyr      s    r   )ÚErrorÚOutcomeÚMaybeÚValueÚacaptureÚcaptureÚValueTT)Ú	covariantÚResultTzCallable[ArgsT, NoReturn]z
ArgsT.argszArgsT.kwargsr   )Úsync_fnÚargsÚkwargsÚreturnc                 O  s   d S r   r   ©r    r!   r"   r   r   r   r   $   s    r   zCallable[ArgsT, ResultT]zValue[ResultT] | Errorc                 O  s   d S r   r   r$   r   r   r   r   .   s    c              
   O  sP   zt | |i |¤ŽƒW S  tyJ } zt|dƒ}t|ƒW  Y d}~S d}~0 0 dS )zŒRun ``sync_fn(*args, **kwargs)`` and capture the result.

    Returns:
      Either a :class:`Value` or :class:`Error` as appropriate.

    r   N©r   ÚBaseExceptionr   r   )r    r!   r"   Úexcr   r   r   r   7   s
    
z$Callable[ArgsT, Awaitable[NoReturn]])Úasync_fnr!   r"   r#   c                 Ï  s   d S r   r   ©r(   r!   r"   r   r   r   r   I   s    r   z#Callable[ArgsT, Awaitable[ResultT]]c                 Ï  s   d S r   r   r)   r   r   r   r   R   s    c              
   Ï  sV   zt | |i |¤ŽI dH ƒW S  tyP } zt|dƒ}t|ƒW  Y d}~S d}~0 0 dS )z“Run ``await async_fn(*args, **kwargs)`` and capture the result.

    Returns:
      Either a :class:`Value` or :class:`Error` as appropriate.

    Nr   r%   )r(   r!   r"   r'   r   r   r   r   [   s
    
F)ÚreprÚinitÚslotsc                   @  sx   e Zd ZU dZejdddd�Zded< ddœdd	„Ze	j
d
dœdd„ƒZe	j
dddœdd„ƒZe	j
dddœdd„ƒZdS )r   a;  An abstract class representing the result of a Python computation.

    This class has two concrete subclasses: :class:`Value` representing a
    value, and :class:`Error` representing an exception.

    In addition to the methods described below, comparison operators on
    :class:`Value` and :class:`Error` objects (``==``, ``<``, etc.) check that
    the other object is also a :class:`Value` or :class:`Error` object
    respectively, and then compare the contained objects.

    :class:`Outcome` objects are hashable if the contained objects are
    hashable.

    F)ÚdefaultÚeqr+   ÚboolÚ
_unwrappedÚNone©r#   c                 C  s   | j r
t‚t | dd¡ d S )Nr0   T)r0   r   ÚobjectÚ__setattr__©Úselfr   r   r   Ú_set_unwrapped   s    zOutcome._set_unwrappedr   c                 C  s   dS )zºReturn or raise the contained value or exception.

        These two lines of code are equivalent::

           x = fn(*args)
           x = outcome.capture(fn, *args).unwrap()

        Nr   r5   r   r   r   Úunwrap„   s    zOutcome.unwrapú"Generator[ResultT, ValueT, object]r   ©Úgenr#   c                 C  s   dS )zÑSend or throw the contained value or exception into the given
        generator object.

        Args:
          gen: A generator object supporting ``.send()`` and ``.throw()``
              methods.

        Nr   ©r6   r;   r   r   r   Úsend�   s    zOutcome.sendúAsyncGenerator[ResultT, ValueT]©Úagenr#   c                 Ã  s   dS )záSend or throw the contained value or exception into the given async
        generator object.

        Args:
          agen: An async generator object supporting ``.asend()`` and
              ``.athrow()`` methods.

        Nr   ©r6   r@   r   r   r   Úasendš   s    zOutcome.asendN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚattrÚibr0   Ú__annotations__r7   ÚabcÚabstractmethodr8   r=   rB   r   r   r   r   r   m   s   


r   )Úfrozenr*   r,   c                   @  s^   e Zd ZU dZe ¡ Zded< ddœdd„Zddœdd	„Z	d
ddœdd„Z
dddœdd„ZdS )r   zFConcrete :class:`Outcome` subclass representing a regular value.

    r   ÚvalueÚstrr2   c                 C  s   d| j ›d�S )NzValue(ú))rM   r5   r   r   r   Ú__repr__°   s    zValue.__repr__c                 C  s   |   ¡  | jS r   )r7   rM   r5   r   r   r   r8   ³   s    zValue.unwrapr9   r   r:   c                 C  s   |   ¡  | | j¡S r   )r7   r=   rM   r<   r   r   r   r=   ·   s    z
Value.sendr>   r?   c                 Ã  s   |   ¡  | | j¡I d H S r   )r7   rB   rM   rA   r   r   r   rB   »   s    zValue.asendN)rC   rD   rE   rF   rG   rH   rM   rI   rP   r8   r=   rB   r   r   r   r   r   ¦   s   
r   c                   @  sj   e Zd ZU dZejej e¡d�Z	de
d< ddœdd„Zd	dœd
d„Zdddœdd„Zdddœdd„ZdS )r   zIConcrete :class:`Outcome` subclass representing a raised exception.

    )Ú	validatorr&   ÚerrorrN   r2   c                 C  s   d| j ›d�S )NzError(rO   )rR   r5   r   r   r   rP   Ì   s    zError.__repr__r	   c                 C  s&   |   ¡  | j}z|‚W ~~ n~~ 0 d S r   )r7   rR   )r6   Zcaptured_errorr   r   r   r8   Ï   s
    zError.unwrapz$Generator[ResultT, NoReturn, object]r   r:   c                 C  s   |   ¡  | | j¡S r   )r7   ÚthrowrR   r<   r   r   r   r=   å   s    z
Error.sendz!AsyncGenerator[ResultT, NoReturn]r?   c                 Ã  s   |   ¡  | | j¡I d H S r   )r7   ÚathrowrR   rA   r   r   r   rB   é   s    zError.asendN)rC   rD   rE   rF   rG   rH   Z
validatorsZinstance_ofr&   rR   rI   rP   r8   r=   rB   r   r   r   r   r   À   s   

ÿ)!Ú
__future__r   rJ   Útypingr   r   r   r   r   r   r	   r
   r   r   rG   Z_utilr   r   Ztyping_extensionsr   r   r   Ú__all__r   r   r   r   ÚsÚABCr   r   r   r   r   r   r   r   Ú<module>   s<   0
	8-