Skip to content

Instantly share code, notes, and snippets.

@jeremysells
Created November 19, 2021 02:11
Show Gist options
  • Save jeremysells/c390d8f988f93c16a3288eec54c46567 to your computer and use it in GitHub Desktop.
Save jeremysells/c390d8f988f93c16a3288eec54c46567 to your computer and use it in GitHub Desktop.
deprecated_decorator.py
import logging
logger = logging.getLogger(__name__)
def deprecated(notes: str = ""):
# https://stackoverflow.com/questions/2536307/decorators-in-the-python-standard-lib-deprecated-specifically
# https://stackoverflow.com/questions/5929107/decorators-with-parameters
if notes != "":
notes = f" " + notes
def decorator(function):
def wrapper(*args, **kwargs):
logger.info("Call to deprecated function %s.%s", function.__name__, notes)
return function(*args, **kwargs)
return wrapper
return decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment