A library to handle automated deprecations
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.
pip install libdeprecation
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  —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.
|||Exposing application users to DeprecationWarnings that are emitted by lower-level code needlessly involves end-users in “how things are done.” It often leads to users raising issues about warnings they’re presented, which on one hand is done rightfully so, as it’s been presented to them as some sort of issue to resolve. However, at the same time, the warning could be well known and planned for. From either side, loud DeprecationWarnings can be seen as noise that isn’t necessary outside of development.|
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size libdeprecation-1.0-py3-none-any.whl (8.4 kB)||File type Wheel||Python version 3.6||Upload date||Hashes View|
|Filename, size libdeprecation-1.0.tar.gz (5.9 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for libdeprecation-1.0-py3-none-any.whl