Wrapper to manage deprecations
Project description
deprecation
Fork of Brian Curtin's deprecation
library, updated primarily for use in the
snakebids library.
The following README is copied from the original library, with relevant modifications. The linked documentation is generally applicable, although installation instructions will refer back to the original library.
README
The deprecated 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
@deprecateddecorator can be told when it's time to entirely remove the code, which causes@fail_if_not_removedto raise anAssertionError, causing either your unittest or py.test tests to fail.
See http://deprecation.readthedocs.io/ for the full documentation.
Installation
pip install pvandyken.deprecated
Usage
from pvandyken import deprecated
@deprecated.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
-Wflag or thePYTHONWARNINGSenvironment 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-inDeprecationWarning. 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.
[^1]: 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.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pvandyken_deprecated-0.0.1.tar.gz.
File metadata
- Download URL: pvandyken_deprecated-0.0.1.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.10.7 Linux/5.15.90.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd4d0cf9e76c6bc143898e553c92cf9cad332c0bd9bba07ed14f5ad454e11b51
|
|
| MD5 |
63f6f1504b62cb193d5f4f4d0b317cd1
|
|
| BLAKE2b-256 |
4c620bd4079527bde9082ef1afb7f06cee13c820dc6134887a93ee6218333c65
|
File details
Details for the file pvandyken_deprecated-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pvandyken_deprecated-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.10.7 Linux/5.15.90.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52b0eaf4008b1066cba9ae2031ff7a4a2cb74682b9084c0658a5e449464f224e
|
|
| MD5 |
62ba37867ecc6db7d683bc315a99d720
|
|
| BLAKE2b-256 |
8f3aaa56adb4fde85cbe6e4883a909b0b6ba4f2bc8c3bfb5443fa7be73764f3e
|