Skip to content

Instantly share code, notes, and snippets.

@sils
Created June 10, 2016 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sils/d66af494eaa630ae2683a6e2db0f1b14 to your computer and use it in GitHub Desktop.
Save sils/d66af494eaa630ae2683a6e2db0f1b14 to your computer and use it in GitHub Desktop.
import logging
from functools import wraps
def bear_deprecated(old_name, new_name):
"""
Emits a deprecation warning when this decorator is executed.
>>> @module_deprecated("a", "b")
... def a():
... return 2
WARNING:root:'a' is deprecated. Use 'b' instead!
>>> a()
2
:param old_name:
:param new_name:
:return:
"""
logging.warning("'{}' is deprecated. Use '{}' instead!".format(old_name,
new_name))
return wraps
@adtac
Copy link

adtac commented Aug 17, 2016

shouldn't the warning be emitted when the function is called?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment