Skip to content

Commit

Permalink
deprecated: Apply functools.wrap to retain meta-data of wrapped function
Browse files Browse the repository at this point in the history
  • Loading branch information
opcode81 committed Mar 2, 2024
1 parent a8b69b7 commit 25ea617
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Improvements/Changes

* `utils.cache`:
* `util.cache`:
* Add new base class `KeyValueCache` alongside `PersistentKeyValueCache`
* Add `InMemoryKeyValueCache`
* Implement `PickleCached` via nested functions instead of a class to improve IDE support
Expand All @@ -15,6 +15,7 @@
* `MultiDataEvaluationUtil`: Add option to supply test data (without using splitting)
* `dft`:
* `DFTNormalisation.RuleTemplate`: Add attributes `fit` and `array_valued`
* `util.deprecation`: Apply `functools.wrap` to retain meta-data of wrapped function

### Fixes

Expand Down
3 changes: 2 additions & 1 deletion src/sensai/util/deprecation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import warnings
import logging

from functools import wraps

log = logging.getLogger(__name__)

Expand All @@ -13,6 +13,7 @@ def deprecated(message):
:return: decorated function
"""
def deprecated_decorator(func):
@wraps(func)
def deprecated_func(*args, **kwargs):
msg = "{} is a deprecated function. {}".format(func.__name__, message)
if logging.Logger.root.hasHandlers():
Expand Down

0 comments on commit 25ea617

Please sign in to comment.