fsl.utils.deprecated
This module provides the deprecated()
function, a simple decorator
for deprecating functions and methods.
The warn()
function can also be called directly, to emit a
DeprecationWarning
- fsl.utils.deprecated._warned_cache = {'/test.venv/lib/python3.10/site-packages/fsl/utils/filetree/__init__.py:331'}
Used by to keep track of whether a warning has already been emitted for the use of a deprecated item.
- fsl.utils.deprecated.resetWarningCache()[source]
Clears the internal warning cache, so that the same line of code may emit another deprecation warning.
- fsl.utils.deprecated._buildMessageFormat(vin=None, rin=None, msg=None)[source]
Builds a deprecation warning message from the arguments.
- Parameters:
vin – Optional version - the warning message will mention that the function is deprecated from this version.
rin – Optional version - the warning message will mention that the function will be removed in this version.
msg – Optional message to use in the warning.
- Returns:
A format string which needs to be formatted with a
{name}
.
- fsl.utils.deprecated._buildWarningSourceIdentity(stacklevel=2)[source]
Creates a string to be used as an identifier for the calling code.
- Parameters:
stacklevel – How far up the calling stack the calling code is.
- Returns:
A string which can be used as an identifier for the calling code.
- fsl.utils.deprecated.warn(name, vin=None, rin=None, msg=None, stacklevel=1)[source]
Emit a deprecation warning.
- Parameters:
name – Name of the thing (class, function, module, etc) that is deprecated.
vin – Optional version - the warning message will mention that the function is deprecated from this version.
rin – Optional version - the warning message will mention that the function will be removed in this version.
msg – Optional message to use in the warning.
stacklevel – How far up the stack the calling code is.
- fsl.utils.deprecated.deprecated(vin=None, rin=None, msg=None)[source]
Decorator to mark a function or method as deprecated. A
DeprecationWarning
is raised via the standardwarnings
module.- Parameters:
vin – Optional version - the warning message will mention that the function is deprecated from this version.
rin – Optional version - the warning message will mention that the function will be removed in this version.
msg – Optional message to use in the warning.