Skip to content

workbench_algorithms.utils.deprecate

Utilities for deprecation.

deprecate

deprecate(
    until: str | None = None, warn_msg: str | None = None
) -> Callable

Can be used to deprecate a function which should not be used anymore.

Parameters:

Name Type Description Default
until str | None

At what version is the old function location deprecated? Example: '3.0.0'

None
warn_msg str | None

Provide a specific warning message. Defaults to a generic message.

None

Returns:

Type Description
Callable

The wrapped function.

Example:

@deprecate(until='3.0.0', warn_msg='some_func will be deprecated, use xxx instead')
def some_func(*args, **kwargs):
    pass

deprecate_location

deprecate_location(
    new_path: str, until: str = None, warn_msg: str = None
) -> Callable

Can be used as a wrapper when moving a function to indicate that the current location will be deprecated.

Parameters:

Name Type Description Default
new_path str

import-path to the new function Example: 'package.module.function'

required
until optional

at what version is the old function location deprecated Example: '3.0.0'

None
warn_msg optional

provide a specific warning message

None

Returns:

Type Description
callable

The wrapped function.

Example
@deprecate_location('new_module.some_func')
def some_func(*args, **kwargs):
    pass

get_deprecations_from

get_deprecations_from(version: str = None) -> Iterable[str]

Returns the deprecation decorators remaining after the specified version.

NOTE deprecations are only included if the module they live in is loaded.

Parameters:

Name Type Description Default
version str

include deprecations at and before this version Example: '3.0.0' Default: all

None

Yields:

Type Description
str

the path to the deprecated function.