8 """Flags a method as deprecated. 10 instructions: A human-friendly string of instructions, such 11 as: 'Please migrate to add_proxy() ASAP.' 14 '''This is a decorator which can be used to mark functions 15 as deprecated. It will result in a warning being emitted 16 when the function is used.''' 17 @functools.wraps(func)
18 def wrapper(*args, **kwargs):
19 message =
'Call to deprecated function {}. {}'.format(
23 warnings.warn(message, category=DeprecatedWarning, stacklevel=2)
25 return func(*args, **kwargs)
27 instructions_doc =
'Deprecated: ' + instructions
28 if wrapper.__doc__
is None:
29 wrapper.__doc__ = instructions_doc
31 wrapper.__doc__ = wrapper.__doc__.rstrip() +
'\n\n' + instructions_doc
def deprecated(instructions)