Skip to main content

Wrapper to manage deprecations

Project description

deprecation

Documentation Status

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:

  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 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.

  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.

[^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

pvandyken_deprecated-0.0.4.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pvandyken_deprecated-0.0.4-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file pvandyken_deprecated-0.0.4.tar.gz.

File metadata

  • Download URL: pvandyken_deprecated-0.0.4.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.0 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for pvandyken_deprecated-0.0.4.tar.gz
Algorithm Hash digest
SHA256 ea174be2fd36495fef0e4818c080eccbc6ec9a8ddc177cb9d859cd0044b1b5b0
MD5 e55c87c6ce3b6c550f37e31ae05476f1
BLAKE2b-256 d19e18bf58a3535d79868e16b7f4dfd92d7df0368a9ae7405913d68b9856aba9

See more details on using hashes here.

File details

Details for the file pvandyken_deprecated-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pvandyken_deprecated-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.0 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for pvandyken_deprecated-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6e58ea8ef598211f539c3eab415bf39001b4276999e19a4354ffa82be83990a0
MD5 47fe3950ac3a669ef4fff490d8ef1898
BLAKE2b-256 1a61a32704fc4d278af117f8c8a3cbc59d5f0764a94b560c66be43d2bd1dcdc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page