diff --git a/documentation/changelog.rst b/documentation/changelog.rst index acf39dfd5..823f2a867 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -25,6 +25,13 @@ Infrastructure / Support .. warning:: The setting `FLEXMEASURES_PLUGIN_PATHS` has been deprecated since v0.7. It has now been sunset. Please replace it with :ref:`plugin-config`. +v0.13.1 | May XX, 2023 +======================= +Bugfixes +--------- +* `@deprecated` not returning the output of the decorated function [see `PR #678 `_] + + v0.13.0 | May 1, 2023 ============================ diff --git a/flexmeasures/utils/coding_utils.py b/flexmeasures/utils/coding_utils.py index e3264c671..7856c87d3 100644 --- a/flexmeasures/utils/coding_utils.py +++ b/flexmeasures/utils/coding_utils.py @@ -166,7 +166,7 @@ def wrapper(*args, **kwargs): f"The method or function {func.__name__} is deprecated and it is expected to be sunset in version {version}. Please, switch to using {inspect.getmodule(alternative).__name__}:{alternative.__name__} to suppress this warning." ) - func(*args, **kwargs) + return func(*args, **kwargs) return wrapper diff --git a/flexmeasures/utils/tests/test_coding_utils.py b/flexmeasures/utils/tests/test_coding_utils.py index 78706d16c..5e2c972bc 100644 --- a/flexmeasures/utils/tests/test_coding_utils.py +++ b/flexmeasures/utils/tests/test_coding_utils.py @@ -2,7 +2,7 @@ def other_function(): - pass + return 1 def test_deprecated_decorator(caplog, app): @@ -10,11 +10,11 @@ def test_deprecated_decorator(caplog, app): # defining a function that is deprecated @deprecated(other_function, "v14") def deprecated_function(): - pass + return other_function() caplog.clear() - deprecated_function() # calling a deprecated function + value = deprecated_function() # calling a deprecated function print(caplog.records) assert len(caplog.records) == 1 # only 1 warning being printed @@ -25,3 +25,7 @@ def deprecated_function(): assert "v14" in str( caplog.records[0].message ) # checking that the message is correct + + assert ( + value == 1 + ) # check that the decorator is returning the value of `other_function`