{"id":2852,"library":"zope-deprecation","title":"Zope Deprecation Infrastructure","description":"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.","status":"active","version":"6.0","language":"en","source_language":"en","source_url":"https://github.com/zopefoundation/zope.deprecation","tags":["deprecation","warnings","zope","backward-compatibility"],"install":[{"cmd":"pip install zope.deprecation","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"deprecated","correct":"from zope.deprecation import deprecated"},{"symbol":"deprecate","correct":"from zope.deprecation import deprecate"},{"symbol":"moved","correct":"from zope.deprecation import moved"},{"symbol":"Suppressor","correct":"from zope.deprecation import Suppressor"}],"quickstart":{"code":"from zope.deprecation import deprecate, moved\nimport warnings\n\n# Deprecating a function\n@deprecate('Use new_function instead of old_function.')\ndef old_function():\n    return \"This is an old function.\"\n\n# Deprecating a module that has moved\n# In old_module.py (assuming it was moved to new_package.new_module)\n# This would be placed in the *original* location of the module:\n# from zope.deprecation import moved\n# moved(\"new_package.new_module\", \"2.0\")\n\n# Example usage with warnings enabled\nwarnings.simplefilter('always')\n\nprint(old_function()) # This will emit a DeprecationWarning\n\n# You can also suppress warnings for specific blocks\nwith Suppressor():\n    print(old_function()) # No warning will be emitted here","lang":"python","description":"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`."},"warnings":[{"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.","message":"Version 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.","severity":"breaking","affected_versions":"6.0 and later"},{"fix":"Upgrade to Python 3.9 or newer. The current version (6.0) requires Python >=3.9.","message":"Python 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.","severity":"breaking","affected_versions":"5.0 and later"},{"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`.","message":"Mixing 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"By default, `DeprecationWarning`s are often ignored. For `zope.deprecation` to be effective, you might need to configure Python's warnings system to display them.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}