Decorator¶
This submodule provide decorators.
- biom3d.utils.decorators.deprecated(reason: str = 'This function is deprecated.') Callable[source]¶
Mark functions as deprecated.
When the decorated function is called, a DeprecationWarning is issued with the given reason. This helps inform developers and users that the function is outdated and may be removed in future versions.
- Parameters:
reason (str, default="This function is deprecated."nal) – Explanation or message indicating why the function is deprecated, or what to use instead.
- Returns:
A decorator that wraps the given function and issues a deprecation warning when called.
- Return type:
callable
Examples
>>> @deprecated("Use 'new_function' instead.") ... def old_function(): ... pass
>>> old_function() ... # DeprecationWarning: Call to deprecated function old_function(). Use 'new_function' instead.
Notes
The warning is raised using warnings.warn with category DeprecationWarning.
Stack level is set to 2 to show the warning at the caller’s level.