diff options
Diffstat (limited to 'logilab')
-rw-r--r-- | logilab/common/deprecation.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/logilab/common/deprecation.py b/logilab/common/deprecation.py index 636b498..4da111b 100644 --- a/logilab/common/deprecation.py +++ b/logilab/common/deprecation.py @@ -385,7 +385,7 @@ def argument_renamed(old_name, new_name): return _wrap -def renamed(old_name, new_function): +def renamed(old_name, new_function, version=None): """use to tell that a callable has been renamed. It returns a callable wrapper, so that when its called a warning is printed @@ -397,7 +397,14 @@ def renamed(old_name, new_function): old_function() >>> """ - return _defaultdeprecator.renamed(old_name, new_function) + @wraps(new_function) + def wrapped(*args, **kwargs): + send_warning(( + f"{old_name} has been renamed and is deprecated, uses {new_function.__name__} " + f"instead" + ), stacklevel=3, version=version) + return new_function(*args, **kwargs) + return wrapped def class_renamed(old_name, new_class, message=None): |