o
    #6d^                     @  s\  d dl mZ d dlmZmZ d dlmZ d dlmZ d dl	m
Z
mZmZmZmZmZmZmZmZmZmZmZ d dlmZ e
rEddlmZ neZed	Zed
ddef Zed0ddZed1ddZed2ddZed3ddZd4ddZG dd dZd5d d!Z	d6d7d&d'Z G d(d
 d
Z!G d)d de"Z#G d*d+ d+ee Z$G d,d- d-ee ed.Z%d/S )8    )annotations)ABCMetaabstractmethod)AbstractContextManager)TracebackType)TYPE_CHECKINGAnyAsyncContextManagerCallableContextManager	GeneratorGenericIterableListTypeVarUnionoverload)warn   )TaskInfoTDeprecatedAwaitableDeprecatedAwaitableFloatDeprecatedAwaitableList[T]__objr   returnc                      d S N r   r   r   jC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\anyio/_core/_compat.pymaybe_async$      r!   floatc                   r   r   r   r   r   r   r    r!   )   r"   list[T]c                   r   r   r   r   r   r   r    r!   .   r"   Nonec                   r   r   r   r   r   r   r    r!   3   r"   AnyDeprecatedAwaitable[T]!TaskInfo | float | list[T] | Nonec                   s
   |   S )a  
    Await on the given object if necessary.

    This function is intended to bridge the gap between AnyIO 2.x and 3.x where some functions and
    methods were converted from coroutine functions into regular functions.

    Do **not** try to use this for any other purpose!

    :return: the result of awaiting on the object if coroutine, or the object itself otherwise

    .. versionadded:: 2.2

    )_unwrapr   r   r   r    r!   8   s   c                   @  s*   e Zd ZdddZdddZdddZdS )_ContextManagerWrappercmContextManager[T]c                 C  s
   || _ d S r   )_cm)selfr*   r   r   r    __init__L   s   
z_ContextManagerWrapper.__init__r   r   c                   s   | j  S r   )r,   	__enter__r-   r   r   r    
__aenter__O   s   
z!_ContextManagerWrapper.__aenter__exc_typetype[BaseException] | Noneexc_valBaseException | Noneexc_tbTracebackType | Nonebool | Nonec                   s   | j |||S r   )r,   __exit__r-   r2   r4   r6   r   r   r    	__aexit__R   s   z _ContextManagerWrapper.__aexit__N)r*   r+   r   r   r2   r3   r4   r5   r6   r7   r   r8   )__name__
__module____qualname__r.   r1   r;   r   r   r   r    r)   K   s    

r)   r*   *ContextManager[T] | AsyncContextManager[T]AsyncContextManager[T]c                 C  s   t | ts	tdt| S )ar  
    Wrap a regular context manager as an async one if necessary.

    This function is intended to bridge the gap between AnyIO 2.x and 3.x where some functions and
    methods were changed to return regular context managers instead of async ones.

    :param cm: a regular or async context manager
    :return: an async context manager

    .. versionadded:: 2.2

    z&Given object is not an context manager)
isinstancer   	TypeErrorr)   )r*   r   r   r    maybe_async_cm[   s   
rE   	awaitableAnyDeprecatedAwaitable[Any]
stacklevelintc                 C  s(   t d| j d| j dt|d d d S )NzAwaiting on z/() is deprecated. Use "await anyio.maybe_async(z}(...)) if you have to support both AnyIO 2.x and 3.x, or just remove the "await" if you are completely migrating to AnyIO 3+.r   )rH   )r   _nameDeprecationWarning)rF   rH   r   r   r    _warn_deprecationp   s   

rL   c                   @  s4   e Zd ZdddZdddZdd
dZdddZdS )r   func"Callable[..., DeprecatedAwaitable]c                 C  s   |j  d|j | _d S N.r?   r@   rJ   )r-   rM   r   r   r    r.   }      zDeprecatedAwaitable.__init__r   Generator[None, None, None]c                 c  s    t |  d S r   )rL   r0   r   r   r    	__await__   s   zDeprecatedAwaitable.__await__tuple[type[None], tuple[()]]c                 C  s   t d dfS )Nr   )typer0   r   r   r    
__reduce__   s   zDeprecatedAwaitable.__reduce__r%   c                 C     d S r   r   r0   r   r   r    r(      s   zDeprecatedAwaitable._unwrapN)rM   rN   )r   rS   )r   rU   )r   r%   )r>   r?   r@   r.   rT   rW   r(   r   r   r   r    r   |   s
    


c                      sF   e Zd Zd fddZddd	ZdddZdddZdddZ  ZS )r   xr#   rM   'Callable[..., DeprecatedAwaitableFloat]r   c                   s   t  | |S r   )super__new__)clsrY   rM   	__class__r   r    r\      s   z DeprecatedAwaitableFloat.__new__c                 C  s   |j  d|j | _d S rO   rQ   )r-   rY   rM   r   r   r    r.      rR   z!DeprecatedAwaitableFloat.__init__Generator[None, None, float]c                 c      t |  	 t| S r   )rL   r#   r0   r   r   r    rT         z"DeprecatedAwaitableFloat.__await__ tuple[type[float], tuple[float]]c                 C     t t | ffS r   r#   r0   r   r   r    rW         z#DeprecatedAwaitableFloat.__reduce__c                 C     t | S r   re   r0   r   r   r    r(         z DeprecatedAwaitableFloat._unwrap)rY   r#   rM   rZ   r   r   )rY   r#   rM   rZ   )r   r`   )r   rc   )r   r#   )	r>   r?   r@   r\   r.   rT   rW   r(   __classcell__r   r   r^   r    r      s    


c                      s@   e Zd Z	dd fddZdd
dZdddZdddZ  ZS )DeprecatedAwaitableListr   iterableIterable[T]rM   )Callable[..., DeprecatedAwaitableList[T]]c                  s$   t  | |j d|j | _d S rO   )r[   r.   r?   r@   rJ   )r-   rk   rM   r^   r   r    r.      s   z DeprecatedAwaitableList.__init__r   Generator[None, None, list[T]]c                 c  ra   r   )rL   listr0   r   r   r    rT      rb   z!DeprecatedAwaitableList.__await__$tuple[type[list[T]], tuple[list[T]]]c                 C  rd   r   ro   r0   r   r   r    rW      rf   z"DeprecatedAwaitableList.__reduce__r$   c                 C  rg   r   rq   r0   r   r   r    r(      rh   zDeprecatedAwaitableList._unwrap)r   )rk   rl   rM   rm   )r   rn   )r   rp   )r   r$   )r>   r?   r@   r.   rT   rW   r(   ri   r   r   r^   r    rj      s    
	
rj   c                   @  s<   e Zd ZedddZedddZdddZdddZdS )DeprecatedAsyncContextManagerr   r   c                 C  rX   r   r   r0   r   r   r    r/      s   z'DeprecatedAsyncContextManager.__enter__r2   r3   r4   r5   r6   r7   r8   c                 C  rX   r   r   r:   r   r   r    r9      s   z&DeprecatedAsyncContextManager.__exit__c                   s    t d| jj dt |  S )NzUsing z as an async context manager has been deprecated. Use "async with anyio.maybe_async_cm(yourcontextmanager) as foo:" if you have to support both AnyIO 2.x and 3.x, or just remove the "async" from "async with" if you are completely migrating to AnyIO 3+.)r   r_   r>   rK   r/   r0   r   r   r    r1      s   z(DeprecatedAsyncContextManager.__aenter__c                   s   |  |||S r   )r9   r:   r   r   r    r;      s   z'DeprecatedAsyncContextManager.__aexit__Nr<   r=   )r>   r?   r@   r   r/   r9   r1   r;   r   r   r   r    rr      s    

rr   )	metaclassN)r   r   r   r   )r   r   r   r#   )r   r   r   r$   )r   r   r   r%   )r   r&   r   r'   )r*   rA   r   rB   )r   )rF   rG   rH   rI   r   r%   )&
__future__r   abcr   r   
contextlibr   typesr   typingr   r   r	   r
   r   r   r   r   r   r   r   r   warningsr   Z_testingr   objectr   ZAnyDeprecatedAwaitabler!   r)   rE   rL   r   r#   r   rj   rr   r   r   r   r    <module>   sD    8

