python-Deprecated
Port variant v15
Summary Implements @deprecated decorator (3.15)
Package version 3.0.1
Homepage https://github.com/laurent-laporte-pro/deprecated
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v14
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 13 NOV 2026, 13:25:52 UTC
Port created 21 NOV 2021, 04:14:38 UTC
Subpackage Descriptions
single # Deprecated Decorator ![Deprecated: a price tag reading "@deprecated, best before: next major"] Python `@deprecated` decorator to deprecate old python classes, functions or methods. [license] [GitHub release] [PyPI] [GitHub Workflow Status] [Coveralls branch] [Read the Docs (version)] Removing a function from a library breaks the code of its users. Deprecating it first gives them time to migrate: the Deprecated library marks classes, functions, methods and parameters as deprecated, emits a warning that points at the calling code, and can document the deprecation in the docstring. ## Installation `shell pip install Deprecated ` Deprecated requires Python 3.12+ and [wrapt]. ## Usage Decorate a deprecated function, method or class with `@deprecated`: ```python from deprecated import deprecated @deprecated(reason="use new_function", version="2.1.0") def some_old_function(x, y): return x + y some_old_function(1, 2) ``` Each call emits a warning located at the calling line: ```text example.py:9: DeprecationWarning: Call to deprecated function (or staticmethod) some_old_function. (use new_function) -- Deprecated since version 2.1.0. ``` `@deprecated` can also be used without arguments, and accepts other options: `category` (e.g. `FutureWarning` instead of `DeprecationWarning`), `action` (a local warning filter, e.g. `"error"`) and `extra_stacklevel` (for wrappers of deprecated functions). To deprecate a *parameter* rather than the whole function, use `@deprecated_params`: ```python from deprecated import deprecated_params @deprecated_params("color", reason="'color' is ignored, use 'style'") def draw(shape, color=None, style=None): ... ``` Calling `draw("circle", color="red")` emits `DeprecationWarning: 'color' is ignored, use 'style'`. ## Documenting the life cycle The Deprecated library can also document the life cycle of your functions and classes: the `@deprecated`, `@versionadded` and `@versionchanged` decorators update the docstring, according to your docstring format: - `deprecated.sphinx`: reStructuredText directives (`.. deprecated:: 1.2.0`), - `deprecated.google`: Google style sections (`Deprecated:`), - `deprecated.numpy`: NumPy style sections (`Deprecated` underlined with hyphens). ```python from deprecated.google import deprecated from deprecated.google import versionadded @deprecated(reason="use another function", version="1.2.0") @versionadded(version="1.0.0") def some_old_function(x, y): """Add two numbers. Args: x: first number. y: second number. """
Configuration Switches (platform-specific settings discarded)
PY314 OFF Build using Python 3.14 PY315 ON Build using Python 3.15
Package Dependencies by Type
Build (only) python315:dev:std
python-pip:single:v15
autoselect-python:single:std
Build and Runtime python315:primary:std
Runtime (only) python-wrapt:single:v15
Download groups
main mirror://PYPIWHL/82/f0/07de837adfa09d592747b82fd74316e88285d2d7057551f30e4b5ef81bd8
Distribution File Information
eda314c115e8bc0fe52b90a6869e19240ac3cedb7449adfdba5981cf9ef693e1 22191 python-src/deprecated-3.0.1-py3-none-any.whl
Ports that require python-Deprecated:v15
No other ports depend on this one.