deprecation-alias
raw JSON → 0.4.0 verified Mon Apr 27 auth: no python
A wrapper around the 'deprecation' library that provides support for deprecated aliases of functions, methods, and classes. Current version 0.4.0, requires Python >=3.6.1. Maintained by domdfcoding, releases are infrequent.
pip install deprecation-alias Common errors
error ImportError: cannot import name 'deprecated_alias' from 'deprecation_alias' ↓
cause The library is not installed or an older version that didn't export the symbol.
fix
Install or upgrade: pip install --upgrade deprecation-alias
error ModuleNotFoundError: No module named 'deprecation' ↓
cause The 'deprecation' library is a required dependency but not automatically installed.
fix
Install it: pip install deprecation
error TypeError: deprecated_alias() got an unexpected keyword argument 'deprecated_in' ↓
cause The signature of deprecated_alias changed; 'deprecated_in' was introduced in a later version (likely 0.3.0).
fix
Check the version: pip show deprecation-alias; if <0.3.0, upgrade: pip install --upgrade deprecation-alias
Warnings
breaking The 'deprecated_alias' decorator requires the 'deprecation' library to be installed separately; it is not an automatic dependency of 'deprecation-alias'. ↓
fix Ensure 'deprecation' is in your project dependencies: pip install deprecation or add to requirements.txt.
gotcha The 'DeprecatedAlias' class is intended for use with classes, but using it incorrectly can lead to unexpected behavior (e.g., missing __init__). ↓
fix Review the documentation for proper usage. For classes, consider using @deprecated_alias on the class itself.
gotcha When using 'deprecated_alias', the 'new_name' parameter must match an existing function/class name; otherwise, no alias is created, and the original function is still called. ↓
fix Verify that the target name exists in the same module scope as the decorator.
Imports
- deprecated_alias
from deprecation_alias import deprecated_alias - DeprecatedAlias
from deprecation_alias import DeprecatedAlias
Quickstart
from deprecation_alias import deprecated_alias
@deprecated_alias(new_name='new_func', deprecated_in='2.0', removed_in='3.0')
def old_func():
"""Old function that is now an alias."""
return 'result'
# Calling old_func will emit a deprecation warning
print(old_func())