o
    $i                     @   s   d dl Z d dlZd dlmZmZ d dlmZ d dlmZ e	e
ZdZ	dddddded	ee d
ee deeeef  deddfddZddddddZdS )    N)OptionalUnion)log_once)_mark_annotated   )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   T/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/_common/deprecation.pydeprecation_warning   s    

r   )r   r   c                   s    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):
            ...
    c                    sP   t  r j fdd}| _t   S  fdd}|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   objobj_initr   r   r   patched_initj   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   )r#   r%   r&   r	   r   r   r   )r#   r$   r   _innerd   s   
zDeprecated.<locals>._innerr   )r   r   r   r	   r+   r   r*   r   
Deprecated<   s   ()r,   )N)r'   loggingtypingr   r   ray.utilr   ray.util.annotationsr   	getLoggerr   r   DEPRECATED_VALUEstrr   r   intr   r,   r   r   r   r   <module>   s4    

,