o
    }oi/                     @  s   d dl mZ d dlZd dlZd dlmZ d dlmZ d dlmZ d dlZd dl	m
Z
 d dlmZ d dlmZ erPd d	lmZ d d
lmZ edZedZedZdZdZd$ddZd%ddZ		d&d'dd Z		d&d(d"d#ZdS ))    )annotationsN)Any)TYPE_CHECKING)TypeVar)version)_get_docstring_indent)_validate_version)Callable)	ParamSpecFTFPCTa  

.. warning::
    Deprecated in v{d_ver}. This feature will be removed in the future. The removal of this
    feature is currently scheduled for v{r_ver}, but this schedule is subject to change.
    See https://github.com/optuna/optuna/releases/tag/v{d_ver}.
z{name} has been deprecated in v{d_ver}. This feature will be removed in v{r_ver}. See https://github.com/optuna/optuna/releases/tag/v{d_ver}.old_versionstrnew_versionreturnNonec                 C  s(   t | t |krtd| |d S )NzInvalid version relationship. The deprecated version must be smaller than the removed version, but (deprecated version, removed version) = ({}, {}) are specified.)r   parse
ValueErrorformat)r   r    r   F/home/ubuntu/.local/lib/python3.10/site-packages/optuna/_deprecated.py_validate_two_version*   s   r   textc                 C  s   dt |  d d S )Nz

z    
)textwrapindentstrip)r   r   r   r   _format_text3   s   r   deprecated_versionremoved_versionname
str | None0'Callable[[Callable[FP, FT]], Callable[FP, FT]]'c                   2   t   t  t  d fdd}|S )a5  Decorate function as deprecated.

    Args:
        deprecated_version:
            The version in which the target feature is deprecated.
        removed_version:
            The version in which the target feature will be removed.
        name:
            The name of the feature. Defaults to the function name. Optional.
        text:
            The additional text for the deprecation note. The default note is build using specified
            ``deprecated_version`` and ``removed_version``. If you want to provide additional
            information, please specify this argument yourself.

            .. note::
                The default deprecation note is as follows: "Deprecated in v{d_ver}. This feature
                will be removed in the future. The removal of this feature is currently scheduled
                for v{r_ver}, but this schedule is subject to change. See
                https://github.com/optuna/optuna/releases/tag/v{d_ver}."

            .. note::
                The specified text is concatenated after the default deprecation note.
    func'Callable[FP, FT]'r   c                   s|    j d u rd _ tjd}d ur|t7 }t j } j  t|| |  _ t	 d
 fdd	}|S )N d_verr_verargsr   kwargsr   'FT'c                    sP   t jdurnj d}dur|d 7 }tj|tdd | i |S )zDecorates a function as deprecated.

            This decorator is supposed to be applied to the deprecated function.
            Nr!   r)   r*       
stacklevel)_DEPRECATION_WARNING_TEMPLATEr   __name__warningswarnFutureWarning)r+   r,   message)r   r%   r!   r    r   r   r   wrapperc   s   z3deprecated_func.<locals>.decorator.<locals>.wrapper)r+   r   r,   r   r   r-   )
__doc___DEPRECATION_NOTE_TEMPLATEr   r   r   r   r   r   	functoolswraps)r%   noter   r9   r   r!   r    r   )r%   r   	decoratorY   s   

z"deprecated_func.<locals>.decoratorN)r%   r&   r   r&   r   r   r   r    r!   r   r@   r   r?   r   deprecated_func7   s
   
rC   'Callable[[CT], CT]'c                   r$   )a/  Decorate class as deprecated.

    Args:
        deprecated_version:
            The version in which the target feature is deprecated.
        removed_version:
            The version in which the target feature will be removed.
        name:
            The name of the feature. Defaults to the class name. Optional.
        text:
            The additional text for the deprecation note. The default note is build using specified
            ``deprecated_version`` and ``removed_version``. If you want to provide additional
            information, please specify this argument yourself.

            .. note::
                The default deprecation note is as follows: "Deprecated in v{d_ver}. This feature
                will be removed in the future. The removal of this feature is currently scheduled
                for v{r_ver}, but this schedule is subject to change. See
                https://github.com/optuna/optuna/releases/tag/v{d_ver}."

            .. note::
                The specified text is concatenated after the default deprecation note.
    cls'CT'r   c                   s   d fdd}|| S )NrE   rF   r   c                   s   t | d t | dt d fd	d
}t| d| | jdu r)d| _tjd}dur:|t7 }t| j}| j	 t
|| | | _| S )z|Decorates a class as deprecated.

            This decorator is supposed to be applied to the deprecated class.
            __init__r4   selfr   r+   r,   r   r   c                   sZ   t jd urnd}d ur|d 7 }tj|tdd  | g|R i | d S )Nr.   r/   r0   r1   )r3   r   r5   r6   r7   )rH   r+   r,   r8   )_original_init_original_namer   r!   r    r   r   r   wrapped_init   s   zJdeprecated_class.<locals>.decorator.<locals>.wrapper.<locals>.wrapped_initNr'   r(   )rH   r   r+   r   r,   r   r   r   )getattrr<   r=   setattrr:   r;   r   r   r   r   r   r   )rE   rK   r>   r   r?   )rI   rJ   r   r9      s   



z4deprecated_class.<locals>.decorator.<locals>.wrapperrE   rF   r   rF   r   )rE   r9   r?   r   r   r@      s   (z#deprecated_class.<locals>.decoratorNrN   rA   rB   r   r?   r   deprecated_classz   s
   
+rO   )r   r   r   r   r   r   )r   r   r   r   )NN)
r   r   r    r   r!   r"   r   r"   r   r#   )
r   r   r    r   r!   r"   r   r"   r   rD   )
__future__r   r<   r   typingr   r   r   r5   	packagingr   optuna._experimentalr   r   collections.abcr	   typing_extensionsr
   r   r   r   r;   r3   r   r   rC   rO   r   r   r   r   <module>   s6    


	F