PYPI PACKAGE AUDIT v3.0.1 Enterprise-konform

Deprecated

Python-Decorator @deprecated zum Veralten von alten Python-Klassen, -Funktionen oder -Methoden.

PyPkgScore deprecated
Methodik & Kriterien ♥ Donate
855 / 1000
Schnellinstallation
pip install deprecated
1. Governance
150/200
2. PEP-Metadaten
200/200
3. Sicherheit
150/200
4. Doku & SEO
155/200
5. CI-Engineering
200/200
📣 Prüfung teilen: Teilen Sie diesen Bericht und die Vorschau in der aktuellen Sprache
Advertisement
PYPI-TELEMETRIE

Downloads & Community-Verbreitung

Letzte 30 Tage (ohne Spiegelserver)
Letzte 7 Tage
34633628
Letzte 30 Tage
152368619
Gesamt (180 Tage)
963162557
Metrik / Ökosystem Status / Wert Quelle
Downloads (30d / 180d) — PyPI Stats (without mirrors)
Trusted Publishing (PEP 740) ✕ Not detected PyPI Integrity / Sigstore
Django Packages — djangopackages.org
PyTech / PyPkgScore 855 / 1000 PyPkgScore Engine

Gesundheits- & Engineering-Analyse (5 Säulen)

1. Governance & Community150 / 200 ▾
LICENSE✓ 50 pts
SECURITY.md✕ 0 pts
CONTRIBUTING.md✓ 50 pts
CODE_OF_CONDUCT.md✓ 50 pts
2. PEP-Metadaten & Paketierung200 / 200 ▾
Wheel (.whl)✓ 50 pts
pyproject.toml✓ 50 pts
Project URLs✓ 50 pts
Trove Classifiers✓ 50 pts
3. Sicherheit & Lieferkette150 / 200 ▾
Null CVEs (OSV)✓ 60 pts
Trusted Publishing (OIDC)✕ 0 pts
Snyk / Audit Link✓ 40 pts
HTTPS-Repository✓ 50 pts
4. Dokumentation, SEO & Ökosystem155 / 200 ▾
Strukturierte README✓ 60 pts
Read the Docs✓ 50 pts
Django Packages✕ 0 pts
Webseite / Fachartikel✓ 45 pts
5. Engineering, CI & Qualität200 / 200 ▾
Automatisierte Tests✓ 65 pts
GitHub Actions CI✓ 65 pts
CHANGELOG.md✓ 35 pts
Env & Lockfile (uv)✓ 35 pts
Advertisement
README & DOCS

Offizielle Dokumentation & Nutzungsleitfaden — deprecated

PyPI Metadata v3.0.1
Vollständige Originaldokumentation anzeigen (Englisches README) ▾

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

pip install Deprecated

Deprecated requires Python 3.12+ and wrapt.

Usage

Decorate a deprecated function, method or class with @deprecated:

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:

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:

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).
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.
    """
    return x + y

The docstring of some_old_function ends with:

Version added:
    1.0.0

Deprecated:
    1.2.0: use another function

Why not warnings.deprecated?

Since Python 3.13, warnings.deprecated (PEP 702) emits a runtime warning and lets the type checkers report the use of deprecated objects. Deprecated complements it with version numbers, docstring updates (Sphinx, Google, NumPy), local warning filters and deprecated parameters. Both can be combined, see the white paper.

See the documentation for more details.

Authors

Deprecated was started by Marcos CARDOSO, building on the recipes shared in this Stack Overflow discussion by Leandro REGUEIRO, Patrizio BERTONI and Eric WIESER.

Laurent LAPORTE has been the main author and maintainer of the library for many years.