A library to handle automated deprecations
Project description
deprecation
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:
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.
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.
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.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file deprecation-2.0.7.tar.gz
.
File metadata
- Download URL: deprecation-2.0.7.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0392f676a6146f0238db5744d73e786a43510d54033f80994ef2f4c9df192ed |
|
MD5 | 21182865ffc725ee93cc45d119a002a9 |
|
BLAKE2b-256 | cd948d9d6303f5ddcbf40959fc2b287479bd9a201ea9483373d9b0882ae7c3ad |
File details
Details for the file deprecation-2.0.7-py2.py3-none-any.whl
.
File metadata
- Download URL: deprecation-2.0.7-py2.py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc9b4f252b7aca8165ce2764a71da92a653b5ffbf7a389461d7a640f6536ecb2 |
|
MD5 | c52b20f1eafb56366072ae5bf7b9d8e0 |
|
BLAKE2b-256 | b92ad5084a8781398cea745c01237b95d9762c382697c63760a95cc6a814ad3a |