Skip to content

deprecation

deprecated(message)

Decorator to mark a function as deprecated.

Parameters:

  • message (str) –

    Message to be displayed when the function is called.

Returns:

Source code in quadra/utils/deprecation.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def deprecated(message: str) -> Callable:
    """Decorator to mark a function as deprecated.

    Args:
        message: Message to be displayed when the function is called.

    Returns:
        Decoratored function.
    """

    def deprecated_decorator(func_or_class: Callable) -> Callable:
        """Decorator to mark a function as deprecated."""

        @functools.wraps(func_or_class)
        def wrapper(*args, **kwargs):
            """Wrapper function to display a warning message."""
            warning_msg = f"{func_or_class.__name__} is deprecated. {message}"
            logger.warning(warning_msg)
            return func_or_class(*args, **kwargs)

        return wrapper

    return deprecated_decorator