Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/alex-ber/AlexBerUtils/llms.txt

Use this file to discover all available pages before exploring further.

The warning module provides the @deprecated decorator for marking functions as deprecated and the OptionalNumpyWarning class used to signal that NumPy is unavailable.

deprecated

Decorator that marks a function as deprecated. Issues a configurable warning on every call.
from alexber.utils.warning import deprecated

@deprecated(version='1.0', reason="Use `new_function` instead.", for_removal=True)
def old_function(x, y):
    """Returns the sum of two numbers."""
    return x + y

result = old_function(3, 4)
# DeprecationWarning: old_function is deprecated since version 1.0: Use `new_function` instead. and is marked for removal.
version
str | None
default:"None"
The version since which the function is considered deprecated. Included in the warning message if provided.
reason
str | None
default:"None"
Human-readable explanation for the deprecation (e.g. "Use new_func() instead."). Appended to the warning message.
for_removal
bool
default:"False"
If True, the warning message ends with "and is marked for removal.". If False, it ends with "and will be removed in a future version.".
warning_class
type[Warning]
default:"DeprecationWarning"
The warning class to issue. Override with PendingDeprecationWarning, FutureWarning, or a custom subclass as appropriate.
Returns: A decorator that wraps the target function, preserving its __name__, __doc__, and other attributes via functools.wraps.

Warning message format

The constructed message follows this template:
{func.__name__} is deprecated [since version {version}][: {reason}] and [is marked for removal | will be removed in a future version].

OptionalNumpyWarning

A custom Warning subclass issued by alexber.utils.randoms when NumPy is not installed and the module falls back to the standard random library.
import warnings
from alexber.utils.warning import OptionalNumpyWarning

# Suppress the warning if you intentionally run without NumPy:
warnings.filterwarnings('ignore', category=OptionalNumpyWarning)

from alexber.utils.randoms import Sampler
OptionalNumpyWarning is issued at import time of alexber.utils.randoms, not at sampling time. Suppress it before importing randoms if you deliberately work without NumPy.

Build docs developers (and LLMs) love