Skip to main content

A simple module that turns DeprecationWarning into errors when your library version or requirements change

It is notoriously difficult to keep track of deprecated function and clean dead code regularly release after release. In particular, when marking a function as deprecated, it is common to forgot mentioning the timeline of deprecation.

This forces you to actually pass a simple specification of when the deprecation should happen, and dead code be removed.

Use case

Deprecate component of your own library.

Let’s say the current version of reaper have bad API, I intend to remove for 0.5, but want to keep around for the time being. I can use the following:

from reaper import deprecate

@deprecate("reaper", ">=0.5.0")
def throw_warnings(predicate, category, version, message):
    """
    This is too hard to use !
    """
    pass

This will show a DeprecationWarning to user calling the function in any version from 0.1.x to 0.4.x, and raise a DeprecationException to any user using 0.5.0-dev, or above.

Future Plans

  • Allow to raise early on Continuous Integration system to catch using deprecated API early in development process, and still allowing you to use code locally.

  • Ability to do the same base on time/date

  • versions which is not a decorator/ context manager

  • ability to mark version of dependency supported, and warn/raise when the minimal dependency list change:

if deprecate(`tornado`, `<=4.3.1`):
    #do stuff
else:
    # do other stuff

The first branch (or actually the predicate) should warn/raise as soon as something like tornado>=4.4 appears in requirements.txt, that some dead code has been found.

Release files for reaper 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for reaper 0.0.1
File Interpreter ABI Platform
reaper-0.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / reaper-0.0.1-py2.py3-none-any.whl

Download URL reaper-0.0.1-py2.py3-none-any.whl
Size 8.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f6de4d55ed5a9569023266382c7f8389957c547ee219ea98c4f255022090023c
BLAKE2b-256 checksum
How to use checksums
2f9fc36d68eacdb7a8fc460d1731151c03484c41060117cf30b017ffcc73da5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page