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)
| 18 | |
| 19 | |
| 20 | def deprecated(func): |
| 21 | """ |
| 22 | This is a decorator which can be used to mark functions |
| 23 | as deprecated. It will result in a warning being emitted |
| 24 | when the function is used. |
| 25 | """ |
| 26 | |
| 27 | def new_func(*args, **kwargs): |
| 28 | warnings.warn( |
| 29 | "Call to deprecated function {}.".format(func.__name__), |
| 30 | category=DeprecationWarning, |
| 31 | ) |
| 32 | return func(*args, **kwargs) |
| 33 | |
| 34 | new_func.__name__ = func.__name__ |
| 35 | new_func.__doc__ = func.__doc__ |
| 36 | new_func.__dict__.update(func.__dict__) |
| 37 | return new_func |