From 43cf12e2955e5e746b41659114896e41f234eefc Mon Sep 17 00:00:00 2001 From: Victor Garcia Reolid Date: Thu, 11 May 2023 13:35:23 +0200 Subject: [PATCH 1/3] fix: deprecated decorator wasn't returning the value of the moved callable. Signed-off-by: Victor Garcia Reolid --- flexmeasures/utils/coding_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 583bd2846406240c3f0a93a225c003914782edca Mon Sep 17 00:00:00 2001 From: Victor Garcia Reolid Date: Thu, 11 May 2023 13:42:40 +0200 Subject: [PATCH 2/3] fix: update test to check that the decorator is returning Signed-off-by: Victor Garcia Reolid --- flexmeasures/utils/tests/test_coding_utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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` From 06953e14d90dace56e5bcfc72185d9a87a68c6a1 Mon Sep 17 00:00:00 2001 From: Victor Garcia Reolid Date: Thu, 11 May 2023 14:22:47 +0200 Subject: [PATCH 3/3] docs: add changelog entry Signed-off-by: Victor Garcia Reolid --- documentation/changelog.rst | 7 +++++++ 1 file changed, 7 insertions(+) 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 ============================