Skip to content

Instantly share code, notes, and snippets.

@rwirth
rwirth / util.py
Last active August 25, 2017 04:39 — forked from kgriffs/util.py
Deprecated decorator for Python. Uses clever introspection to set a helpful filename and lineno in the warning message, even in complex cases like code being executed via execfile. The warning is properly registered and repeated only once for each 'offending' line (by default).
import functools
import inspect
import warnings
# NOTE(kgriffs): We don't want our deprecations to be ignored by default,
# so create our own type.
class DeprecatedWarning(UserWarning):
pass