o
    `۷i                     @   s  d dl Z d dlZd dlmZ d dlmZmZmZmZm	Z	m
Z
mZ d dlmZ d dlmZ ededef dZeeZd	Z	dddd
ddedee dee dee	eee f  deddfddZe	dddddddee dee de	eee f deegef f
ddZeddddedee dee de	eee f deegef f
ddZ	dddddee dee dee de	eee f deegef f
ddZdS )    N)wraps)AnyCallableOptionalTypeVarUnioncastoverload)log_once)_mark_annotatedF.)bound   )helperror
stackleveloldnewr   r   r   returnc                C   sj   d | |r
d |n|rd| nd}|r(t|ts$t|tr$||t|tjd| d |d dS )	a'  Warns (via the `logger` object) or throws a deprecation warning/error.

    Args:
        old: A description of the "thing" that is to be deprecated.
        new: A description of the new "thing" that replaces it.
        help: An optional help text to tell the user, what to
            do instead of using `old`.
        error: Whether or which exception to raise. If True, raise ValueError.
            If False, just warn. If `error` is-a subclass of Exception,
            raise that Exception.
        stacklevel: The stacklevel to use for the warning message.
            Use 2 to point to where this function is called, 3+ to point
            further up the stack.

    Raises:
        ValueError: If `error=True`.
        Exception: Of type `error`, iff `error` is a sub-class of `Exception`.
    z`{}` has been deprecated.{}z Use `{}` instead.  zDeprecationWarning: z( This will raise an error in the future!)r   N)format
isinstancebool
issubclass	Exception
ValueErrorloggerwarning)r   r   r   r   r   msg r!   M/home/ubuntu/vllm_env/lib/python3.10/site-packages/ray/_common/deprecation.pydeprecation_warning   s    

r#   )r   r   c                C      d S Nr!   r   r   r   r   r!   r!   r"   
DeprecatedB      r'   c                C   r$   r%   r!   r&   r!   r!   r"   r'   M   r(   c                   s    dt dt f fdd}|S )a  Decorator for documenting a deprecated class, method, or function.

    Automatically adds a `deprecation.deprecation_warning(old=...,
    error=False)` to not break existing code at this point to the decorated
    class' constructor, method, or function.

    In a next major release, this warning should then be made an error
    (by setting error=True), which means at this point that the
    class/method/function is no longer supported, but will still inform
    the user about the deprecation event.

    In a further major release, the class, method, function should be erased
    entirely from the codebase.


    .. testcode::
        :skipif: True

        from ray._common.deprecation import Deprecated
        # Deprecated class: Patches the constructor to warn if the class is
        # used.
        @Deprecated(new="NewAndMuchCoolerClass", error=False)
        class OldAndUncoolClass:
            ...

        # Deprecated class method: Patches the method to warn if called.
        class StillCoolClass:
            ...
            @Deprecated(new="StillCoolClass.new_and_much_cooler_method()",
                        error=False)
            def old_and_uncool_method(self, uncool_arg):
                ...

        # Deprecated function: Patches the function to warn if called.
        @Deprecated(new="new_and_much_cooler_function", error=False)
        def old_and_uncool_function(*uncool_args):
            ...
    objr   c                    sj   t  r j fdd}| _t   S  fdd}t r0t |}tt|S )Nc                     s4   t pjrtpj dd | i |S N   )r   r   r   r   r   r
   __name__r#   argskwargs)r   r   r   r)   obj_initr   r!   r"   patched_init   s   z0Deprecated.<locals>._inner.<locals>.patched_initc                     s4   t pjrtpj dd | i |S r*   r,   r.   )r   r   r   r)   r   r!   r"   _ctor   s   z)Deprecated.<locals>._inner.<locals>._ctor)inspectisclass__init__r   callabler   r   r   )r)   r2   r3   r   r   r   r   )r)   r1   r"   _inner   s   

zDeprecated.<locals>._inner)r   )r   r   r   r   r9   r!   r8   r"   r'   X   s   ./r%   )r4   logging	functoolsr   typingr   r   r   r   r   r   r	   ray.utilr
   ray.util.annotationsr   r   	getLoggerr-   r   DEPRECATED_VALUEstrr   typer   intr#   r'   r!   r!   r!   r"   <module>   s    $

,
