Skip to main content

A library to handle automated deprecations

Project description

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.


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

deprecation-2.0.6.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

deprecation-2.0.6-py2.py3-none-any.whl (6.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file deprecation-2.0.6.tar.gz.

File metadata

  • Download URL: deprecation-2.0.6.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5+

File hashes

Hashes for deprecation-2.0.6.tar.gz
Algorithm Hash digest
SHA256 68071e5ae7cd7e9da6c7dffd750922be4825c7c3a6780d29314076009cc39c35
MD5 7fc1b0592c47d90306dfdcb6ea46d8c8
BLAKE2b-256 cd35ab3995718c7b12d6a5e69f40540fe1df0b505cca5ee6af169d23ab9d0b00

See more details on using hashes here.

File details

Details for the file deprecation-2.0.6-py2.py3-none-any.whl.

File metadata

  • Download URL: deprecation-2.0.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5+

File hashes

Hashes for deprecation-2.0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fecd0f05024126466ba7e5309b905f09fce7d25d67e4648f7ec5488f9e764310
MD5 a387ad04c3c4b7d6d1e64936246e44a6
BLAKE2b-256 32e901ffbaf3540ad54476cd7066439d629f1dd73b851cc5c0993ce2c12e1cdd

See more details on using hashes here.

Supported by

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