This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.
(func)
| 3 | |
| 4 | |
| 5 | def deprecated(func): |
| 6 | """This is a decorator which can be used to mark functions |
| 7 | as deprecated. It will result in a warning being emitted |
| 8 | when the function is used.""" |
| 9 | @functools.wraps(func) |
| 10 | def new_func(*args, **kwargs): |
| 11 | warnings.simplefilter('always', DeprecationWarning) # turn off filter |
| 12 | warnings.warn("Call to deprecated function {}.".format(func.__name__), |
| 13 | category=DeprecationWarning, |
| 14 | stacklevel=2) |
| 15 | warnings.simplefilter('default', DeprecationWarning) # reset filter |
| 16 | return func(*args, **kwargs) |
| 17 | return new_func |
nothing calls this directly
no outgoing calls
no test coverage detected