Registry / serialization / zope-deprecation

zope-deprecation

JSON →
library6.0pypypi✓ verified 23d ago

zope.deprecation provides utilities for marking modules, classes, functions, methods, and properties as deprecated in Python projects. It helps manage backward compatibility by issuing warnings when deprecated code is used. The current version is 6.0, and it generally sees a few releases per year, often tied to Python version support updates or internal Zope Foundation infrastructure changes.

pip install zope.deprecation
INSTALL
IMPORT
SIG · ZOPE-DEPRECATION
Z
zope-deprecation
serializationpythonv6.0
Install
1.8s avg
Import
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v6.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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.000s · 18MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

deprecated
from zope.deprecation import deprecated
deprecate
from zope.deprecation import deprecate
moved
from zope.deprecation import moved
Suppressor
from zope.deprecation import Suppressor

This quickstart demonstrates how to use the `@deprecate` decorator for functions and mentions `moved` for module relocations. It also shows how to enable warnings and temporarily suppress them using `Suppressor`.

from zope.deprecation import deprecate, moved import warnings # Deprecating a function @deprecate('Use new_function instead of old_function.') def old_function(): return "This is an old function." # Deprecating a module that has moved # In old_module.py (assuming it was moved to new_package.new_module) # This would be placed in the *original* location of the module: # from zope.deprecation import moved # moved("new_package.new_module", "2.0") # Example usage with warnings enabled warnings.simplefilter('always') print(old_function()) # This will emit a DeprecationWarning # You can also suppress warnings for specific blocks with Suppressor(): print(old_function()) # No warning will be emitted here
Debug
Known issues
breakingVersion 6.0 replaced `pkg_resources` namespace package handling with PEP 420 native namespace packages. Projects relying on the older `pkg_resources` mechanism for `zope` namespace package declarations might need adjustment.
fix
Ensure your project's `pyproject.toml` or `setup.cfg` correctly declares namespace packages according to PEP 420. If you encounter `ModuleNotFoundError`, a clean reinstall of all `zope` related packages in a new virtual environment is often recommended.
affects: 6.0 and later
breakingPython 3.7 and 3.8 are no longer supported as of version 5.1. Version 5.0 also dropped support for Python 2.7, 3.4, 3.5, and 3.6.
fix
Upgrade to Python 3.9 or newer. The current version (6.0) requires Python >=3.9.
affects: 5.0 and later
gotchaMixing installation methods (e.g., `python setup.py develop` with `pip install`) for namespace packages like `zope.deprecation` can lead to `ModuleNotFoundError` due to how different systems handle namespace package discovery.
fix
Always use a single, consistent tool for installing Python packages, preferably `pip` with virtual environments. If issues arise, perform a clean uninstall of all related packages and reinstall using only `pip`.
affects: All versions
gotchaBy default, `DeprecationWarning`s are often ignored. For `zope.deprecation` to be effective, you might need to configure Python's warnings system to display them.
fix
Use `warnings.simplefilter('always', DeprecationWarning)` in your code, or run Python with the `-Wa` or `-Wd` flag (e.g., `python -Wd your_script.py`) to ensure deprecation warnings are displayed.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'zope.deprecation'
The `zope.deprecation` package is not installed in your current Python environment.
fix
pip install zope.deprecation
TypeError: deprecate() missing 1 required positional argument: 'name'
You attempted to use `zope.deprecation.deprecate` as a decorator without providing its required `name` argument, or mistakenly used it where `zope.deprecation.deprecated` should be used for functions/methods.
fix
Use `@deprecated('your deprecation message')` as the decorator for functions and methods, or call `zope.deprecation.deprecate(obj, 'obj_name')` for classes or modules.
ImportError: cannot import name 'implementer' from 'zope.deprecation'
`implementer` is a utility from the `zope.interface` package, not `zope.deprecation`. You are attempting to import a name from the wrong Zope package.
fix
Import `implementer` from `zope.interface` instead. Ensure `zope.interface` is installed if you intend to use it.
Upgrade
Version history
6.0latest on PyPI · released Sep 12, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
38 hits · last 30 days
node
34
Resources
zope-deprecation — pip install zope-deprecation · libregistry