Deprecated

hivecore.decorator.deprecated(reason: str | None = None)

A decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.

Parameters:

reason (Optional[str], optional) – The reason why this function/class is deprecated

Raises:

TypeError – This error will probably happen you pass a reason that is not a string type. Not passing it will also work.

Returns:

A function or a class type.

Return type:

Callable

Basic Example

from hivecore.decorator import deprecated

@deprecated
def old_sum(*numbers):
    total = 0
    for number in numbers:
        total = total + number
    return total

def new_sum(*numbers):
    return sum(*numbers)

Example Custom Message

from hivecore.decorator import deprecated

@deprecated("An old implementation for sum, not as efficient for big len(numbers).")
def old_sum(*numbers):
    total = 0
    for number in numbers:
        total = total + number
    return total

def new_sum(*numbers):
    return sum(*numbers)