From c4d327907d1f9147847c949b794292fc53aa262a Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sun, 7 Dec 2014 09:39:12 -0800 Subject: [PATCH] Allow all deprecation helpers to take a stacklevel To make the deprecation helpers more uniform in what arguments/keyword arguments they take allow them all to take a stacklevel keyword argument (which by default is set to a good value that works). This allows those users of this helper to override the stacklevel in a uniform manner (if they so need to). Change-Id: Icbfc115aa2aea4a5c01b99dcfa2a5c4e4785c458 --- taskflow/utils/deprecation.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/taskflow/utils/deprecation.py b/taskflow/utils/deprecation.py index db9c3790..a108676a 100644 --- a/taskflow/utils/deprecation.py +++ b/taskflow/utils/deprecation.py @@ -161,7 +161,8 @@ def renamed_kwarg(old_name, new_name, message=None, def _moved_decorator(kind, new_attribute_name, message=None, - version=None, removal_version=None): + version=None, removal_version=None, + stacklevel=3): """Decorates a method/property that was moved to another location.""" def decorator(f): @@ -184,7 +185,7 @@ def _moved_decorator(kind, new_attribute_name, message=None, out_message = _generate_moved_message( prefix, message=message, version=version, removal_version=removal_version) - deprecation(out_message, stacklevel=3) + deprecation(out_message, stacklevel=stacklevel) return f(self, *args, **kwargs) return wrapper @@ -193,15 +194,16 @@ def _moved_decorator(kind, new_attribute_name, message=None, def moved_property(new_attribute_name, message=None, - version=None, removal_version=None): + version=None, removal_version=None, stacklevel=3): """Decorates a *instance* property that was moved to another location.""" return _moved_decorator('Property', new_attribute_name, message=message, - version=version, removal_version=removal_version) + version=version, removal_version=removal_version, + stacklevel=stacklevel) def moved_class(new_class, old_class_name, old_module_name, message=None, - version=None, removal_version=None): + version=None, removal_version=None, stacklevel=3): """Deprecates a class that was moved to another location. This will emit warnings when the old locations class is initialized, @@ -213,4 +215,4 @@ def moved_class(new_class, old_class_name, old_module_name, message=None, out_message = _generate_moved_message(prefix, message=message, version=version, removal_version=removal_version) - return MovedClassProxy(new_class, out_message, stacklevel=3) + return MovedClassProxy(new_class, out_message, stacklevel=stacklevel)