Coder Social home page Coder Social logo

deprecation's Introduction

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.

Footnotes

  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.

deprecation's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.