Skip to main content

deprecation

Documentation Status https://travis-ci.org/briancurtin/deprecation.svg?branch=master https://codecov.io/gh/briancurtin/deprecation/branch/master/graph/badge.svg

The deprecation library provides a deprecated decorator and a fail_if_not_removed decorator for your tests. Together, the two enable the automation of several things:

  1. The docstring of a deprecated method gets the deprecation details appended to the end of it. If you generate your API docs direct from your source, you don’t need to worry about writing your own notification. You also don’t need to worry about forgetting to write it. It’s done for you.

  2. Rather than having code live on forever because you only deprecated it but never actually moved on from it, you can have your tests tell you when it’s time to remove the code. The @deprecated decorator can be told when it’s time to entirely remove the code, which causes @fail_if_not_removed to raise an AssertionError, causing either your unittest or py.test tests to fail.

See http://deprecation.readthedocs.io/ for the full documentation.

Installation

pip install deprecation

Usage

import deprecation

@deprecation.deprecated(deprecated_in="1.0", removed_in="2.0",
                        current_version=__version__,
                        details="Use the bar function instead")
def foo():
    """Do some stuff"""
    return 1

…but doesn’t Python ignore DeprecationWarning?

Yes, by default since 2.7—and for good reason [1] —and this works fine with that.

  1. It often makes sense for you to run your tests with a -W flag or the PYTHONWARNINGS environment variable so you catch warnings in development and handle them appropriately. The warnings raised by this library show up there, as they’re subclasses of the built-in DeprecationWarning. See the Command Line and Environment Variable documentation for more details.

  2. Even if you don’t enable those things, the behavior of this library remains the same. The docstrings will still be updated and the tests will still fail when they need to. You’ll get the benefits regardless of what Python cares about DeprecationWarning.


Release files for deprecation 2.1.0

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

Source distribution (sdist)

Source distribution for deprecation 2.1.0
File Size Uploaded
deprecation-2.1.0.tar.gz 173.8 kB Details

Built distribution (wheel)

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

Total release size: 185.0 kB

Release files / deprecation-2.1.0.tar.gz

Download URL deprecation-2.1.0.tar.gz
Size 173.8 kB
Tags Source
SHA-256 checksum
How to use checksums
72b3bde64e5d778694b0cf68178aed03d15e15477116add3fb773e581f9518ff
BLAKE2b-256 checksum
How to use checksums
5ad38ae2869247df154b64c1884d7346d412fed0c49df84db635aab2d1c40e62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1rc1

Release files / deprecation-2.1.0-py2.py3-none-any.whl

Download URL deprecation-2.1.0-py2.py3-none-any.whl
Size 11.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a10811591210e1fb0e768a8c25517cabeabcba6f0bf96564f8ff45189f90b14a
BLAKE2b-256 checksum
How to use checksums
02c3253a89ee03fc9b9682f1541728eb66db7db22148cd94f89ab22528cd1e1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1rc1

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.7

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0

2 release files

1.2

2 release files

1.1

2 release files

1.0.1

2 release files

1.0

2 release files

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