o
    h                     @  s   d dl mZ d dlZd dlZd dlZd dlmZmZ ejdkr&d dlm	Z
 nd dlm	Z
 er@ejdkr:d dlmZ nd dlmZ g dZG d	d
 d
eZd(ddZddeddd)ddZ	dedddd*d!d"Ze
Z	 G d#d$ d$Ze ad+d&d'ZdS ),    )annotationsN)TYPE_CHECKINGLiteral)      )
deprecated)r      )LiteralString)AltairDeprecationWarningr   deprecated_static_onlydeprecated_warnc                   @  s   e Zd ZdS )r
   N)__name__
__module____qualname__ r   r   L/var/www/vscode/kcb/lib/python3.10/site-packages/altair/utils/deprecation.pyr
      s    r
   versionr	   alternativeLiteralString | Nonemessagereturnc                C  s6   d|  d}|r| d| d}|r| d| S |S )Nz
Deprecated since `altair=z`.z Use z	 instead.
r   )r   r   r   outputr   r   r   _format_message   s   r      )r   r   category
stacklevelr   %type[AltairDeprecationWarning] | Noner   intc                 C  s   t | ||}t|||dS )a  
    Indicate that a class, function or overload is deprecated.

    When this decorator is applied to an object, the type checker
    will generate a diagnostic on usage of the deprecated object.

    Parameters
    ----------
    version
        ``altair`` version the deprecation first appeared.
    alternative
        Suggested replacement class/method/function.
    message
        Additional message appended to ``version``, ``alternative``.
    category
        If the *category* is ``None``, no warning is emitted at runtime.
    stacklevel
        The *stacklevel* determines where the
        warning is emitted. If it is ``1`` (the default), the warning
        is emitted at the direct caller of the deprecated object; if it
        is higher, it is emitted further up the stack.
        Static type checker behavior is not affected by the *category*
        and *stacklevel* arguments.

    References
    ----------
    [PEP 702](https://peps.python.org/pep-0702/)
    r   r   )r   _deprecated)r   r   r   r   r   msgr   r   r   r   -   s   $r      )r   r   r   actiontype[AltairDeprecationWarning]r#   Literal['once'] | NoneNonec                C  sJ   t ||| }|du rtj|||d dS |dkr!t|||d dS t|)ar  
    Indicate that the current code path is deprecated.

    This should be used for non-trivial cases *only*. ``@deprecated`` should
    always be preferred as it is recognized by static type checkers.

    Parameters
    ----------
    message
        Explanation of the deprecated behaviour.

        .. note::
            Unlike ``@deprecated``, this is *not* optional.

    version
        ``altair`` version the deprecation first appeared.
    alternative
        Suggested replacement argument/method/function.
    category
        The runtime warning type emitted.
    stacklevel
        How far up the call stack to make this warning appear.
        A value of ``2`` attributes the warning to the caller
        of the code calling ``deprecated_warn()``.

    References
    ----------
    [warnings.warn](https://docs.python.org/3/library/warnings.html#warnings.warn)
    Nr   once)r   warningswarn
_warn_onceNotImplementedError)r   r   r   r   r   r#   r!   r   r   r   r   U   s   &r   c                   @  s4   e Zd ZdddZddd	Zdd
dZdddZdS )_WarningsMonitorr   r&   c                 C  s   i | _ t | _d S N)_warned	threadingLock_lockselfr   r   r   __init__   s   z_WarningsMonitor.__init__keyr	   boolc                C  s4   | j  || jv W  d    S 1 sw   Y  d S r-   r1   r.   r3   r5   r   r   r   __contains__   s   $z_WarningsMonitor.__contains__c                C  s6   | j  d| j|< W d    d S 1 sw   Y  d S )NTr7   r8   r   r   r   hit      "z_WarningsMonitor.hitc                 C  s6   | j  | j  W d    d S 1 sw   Y  d S r-   )r1   r.   clearr2   r   r   r   r<      r;   z_WarningsMonitor.clearN)r   r&   )r5   r	   r   r6   )r5   r	   r   r&   )r   r   r   r4   r9   r:   r<   r   r   r   r   r,      s
    


r,   r!   c               C  s.   | t v rd S t |  tj| ||d d d S )Nr   r   )_warnings_monitorr:   r(   r)   )r!   r   r   r   r   r   r*      s   
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   r   r#   r%   r   r&   )r!   r	   r   r$   r   r   r   r&   )
__future__r   sysr/   r(   typingr   r   version_infor   r    typing_extensionsr	   __all__DeprecationWarningr
   r   r   r   r,   r=   r*   r   r   r   r   <module>   s<    


,/"