Skip to content

input4mips_validation.deprecation#

input4mips_validation.deprecation #

Deprecation support

raise_deprecation_warning(name, removed_in, use_instead, stacklevel=3) #

Raise a deprecation warning

Parameters:

Name Type Description Default
name str

Name of the callable being deprecated

required
removed_in str

Version in which the callable will be removed

required
use_instead str

Instructions on what to use instead of the deprecated callable

required
stacklevel int

Stack level to show with the warning

3
Source code in src/input4mips_validation/deprecation.py
def raise_deprecation_warning(
    name: str, removed_in: str, use_instead: str, stacklevel: int = 3
) -> None:
    """
    Raise a deprecation warning

    Parameters
    ----------
    name
        Name of the callable being deprecated

    removed_in
        Version in which the callable will be removed

    use_instead
        Instructions on what to use instead of the deprecated callable

    stacklevel
        Stack level to show with the warning
    """
    message = (
        f"{name} will be removed in {removed_in}. Instead, please use {use_instead}."
    )
    warnings.warn(message, DeprecationWarning, stacklevel=stacklevel)