Install & Compatibility
Where this runs
tested against v0.11.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.144s · 18.7MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.126s · 19MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
deprecated
✓ from deprecate import deprecated
deprecated_class
✓ from deprecate import deprecated_class
deprecated_instance
✓ from deprecate import deprecated_instance
void
✓ from deprecate import void
Helper function to silence IDE warnings about unused parameters in deprecated functions when a 'target' is specified.
This quickstart demonstrates how to use the `@deprecated` decorator with and without a `target` function. When a `target` is provided, calls are forwarded to the new function, and the `void` helper silences IDE warnings. When `target=None`, the deprecated function's own body is executed after a warning is issued. Warnings are initially suppressed for clean output but re-enabled to show the deprecation messages.
import warnings
from deprecate import deprecated, void
# Suppress DeprecationWarning for cleaner output in example, will re-enable later
warnings.simplefilter('ignore', DeprecationWarning)
# NEW/FUTURE API — renamed to be more explicit about what it computes
def compute_sum(a: int = 0, b: int = 3) -> int:
"""Computes the sum of two numbers."""
return a + b
# OLD API — 'addition' was the original name before the rename
@deprecated(target=compute_sum, deprecated_in="1.0", remove_in="2.0", template_mgs="{name} is deprecated, use {target_path} instead.")
def addition(a: int, b: int = 5) -> int:
"""Adds two numbers (deprecated)."""
# The body of 'addition' is never executed because 'target' is specified.
# The 'void' helper is used here to silence IDE warnings about 'a' and 'b' being unused.
return void(a, b)
# Deprecating a function with no direct target (its own body runs)
@deprecated(target=None, deprecated_in="0.5", remove_in="0.8", template_mgs="Method {name} is deprecated and will be removed.")
def old_method(value: str) -> str:
"""An old method that will be removed."""
return f"Processing: {value}"
# Example usage:
print("--- Using deprecated function with target ---")
print(f"Result of addition(1, 2): {addition(1, 2)}")
print(f"Result of addition(10): {addition(10)}")
print("\n--- Using deprecated function with no target ---")
print(f"Result of old_method('test'): {old_method('test')}")
# To demonstrate the warning, re-enable DeprecationWarnings
print("\n--- Enabling warnings to show deprecation output ---")
warnings.simplefilter('default', DeprecationWarning)
print(f"Result of addition(3, 4): {addition(3, 4)}")
print(f"Result of old_method('another test'): {old_method('another test')}")
Errors
Common errors & fixes
ImportError: cannot import name 'deprecated' from 'deprecate'
The `pydeprecate` library is installed as `pydeprecate`, but the main decorator is imported from the `deprecate` package, not `pydeprecate` directly.
fixEnsure you import from the `deprecate` package: `from deprecate import deprecated`
TypeError: Cannot apply @deprecated to class 'MyClass'. For class-level deprecation use @deprecated_class() from deprecate.proxy.
The `@deprecated` decorator is designed for functions and methods, not entire classes. To deprecate a class, a different decorator or approach is required.
fixUse the `@deprecated_class` decorator from `deprecate.proxy` for class-level deprecation: `from deprecate.proxy import deprecated_class`
Deprecation warnings not showing
By default, Python's `DeprecationWarning` (which `pydeprecate` emits) is often hidden or shown only once in many environments to prevent log spam. `pydeprecate` also defaults to showing warnings once per function.
fixTo ensure warnings are visible, you can use `warnings.simplefilter('always', DeprecationWarning)` in your code, run Python with the `-Wd` flag, or configure `pydeprecate`'s `num_warns` parameter (e.g., `@deprecated(num_warns=None)`) to show warnings unlimited times. ERROR: <module>.<function> has invalid args: ['<arg_name>']
This error is reported by `pydeprecate`'s validation tools (e.g., `find_deprecation_wrappers` or `validate_deprecation_wrapper`) when `args_mapping` contains keys that do not correspond to actual arguments in the deprecated function's signature.
fixReview the `args_mapping` dictionary in your `@deprecated` decorator to ensure all old argument names specified as keys exist in the function being deprecated.
Upgrade
Version history
0.11.0latest on PyPI · released Jul 17, 2026
Audit
Dependencies
No dependency data recorded yet.