| Conditions | 3 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | """ |
||
| 9 | def backport(func): |
||
| 10 | """ |
||
| 11 | Backport a function name into an old style for compatibility. |
||
| 12 | |||
| 13 | The docstring is updated to reflect that the new function returned is |
||
| 14 | deprecated and that the other function is preferred. |
||
| 15 | A DeprecationWarning is also raised for using this function. |
||
| 16 | |||
| 17 | If the script is run with an optimization flag then the real function |
||
| 18 | will be returned without being wrapped. |
||
| 19 | """ |
||
| 20 | if not __debug__: |
||
| 21 | return func |
||
| 22 | |||
| 23 | @_functools.wraps(func) |
||
| 24 | def deprecated_function(*args, **kargs): |
||
|
|
|||
| 25 | _warnings.warn('This function name is deprecated', |
||
| 26 | DeprecationWarning, 2) |
||
| 27 | return func(*args, **kargs) |
||
| 28 | deprecated_function.__doc__ = None |
||
| 29 | return deprecated_function |
||
| 30 | |||
| 32 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.