Skip to content

Deprecated module

Reference to the deprecated.py module.

deprecated

Utilities for handling deprecated functionality within the Nextmv Python SDK.

This module provides tools to mark functions, methods, or features as deprecated, emitting appropriate warnings to users. These warnings inform users that the functionality will be removed in a future release and suggest alternative approaches.

The main purpose of this module is to help with the smooth transition when API changes are necessary, giving users time to update their code before functionality is removed completely.

NextmvDeprecationWarning

Bases: DeprecationWarning

Deprecation warning emitted by the Nextmv SDK.

deprecated

deprecated(name: str, reason: str) -> None

Mark functionality as deprecated with a warning message.

This function emits a DeprecationWarning when called, indicating that the functionality will be removed in a future release.

PARAMETER DESCRIPTION

name

The name of the function, method, or feature being deprecated.

TYPE: str

reason

The reason why the functionality is being deprecated, possibly with suggestions for alternative approaches.

TYPE: str

Examples:

>>> def some_function():
...     deprecated("feature_x", "Use feature_y instead")
...     # function implementation
Source code in nextmv-py/nextmv/nextmv/deprecated.py
def deprecated(name: str, reason: str) -> None:
    """
    Mark functionality as deprecated with a warning message.

    This function emits a DeprecationWarning when called, indicating that
    the functionality will be removed in a future release.

    Parameters
    ----------
    name : str
        The name of the function, method, or feature being deprecated.
    reason : str
        The reason why the functionality is being deprecated, possibly
        with suggestions for alternative approaches.

    Examples
    --------
    >>> def some_function():
    ...     deprecated("feature_x", "Use feature_y instead")
    ...     # function implementation
    """

    warnings.warn(
        f"{name}: {reason}. This functionality will be removed in the next major release.",
        category=NextmvDeprecationWarning,
        stacklevel=3,
    )