Skip to content

Commit 81258ab

Browse files
committed
Do not show deprecated messages when updating the OM but only when calling deprecated functions/methods
1 parent a9a6c2d commit 81258ab

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: src/dsf/utils.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import inspect
12
import re
23
import warnings
34

@@ -25,8 +26,10 @@ def decorator(func):
2526
"""This is a decorator which can be used to mark functions as deprecated.
2627
It will result in a warning being emitted when the function is used."""
2728
def deprecated_func(*args, **kwargs):
28-
warnings.warn(f"Call to deprecated function {func.__name__}(). {instructions}",
29-
DeprecatedWarning, stacklevel=2)
29+
# Do not show DeprecatedWarning on ObjectModel update (function called by update_from_json)
30+
if inspect.currentframe().f_back.f_code.co_name not in ['_update_from_json', 'update_from_json']:
31+
warnings.warn(f"Call to deprecated function {func.__name__}(). {instructions}",
32+
DeprecatedWarning, stacklevel=2)
3033
return func(*args, **kwargs)
3134
return deprecated_func
3235
return decorator

0 commit comments

Comments
 (0)