diff --git a/debtcollector/_utils.py b/debtcollector/_utils.py index 80bada7..6e4ff08 100644 --- a/debtcollector/_utils.py +++ b/debtcollector/_utils.py @@ -19,8 +19,6 @@ import inspect import types import warnings -import six - try: _TYPE_TYPE = types.TypeType except AttributeError: @@ -91,14 +89,7 @@ def generate_message(prefix, postfix=None, message=None, def get_assigned(decorator): """Helper to fix/workaround https://bugs.python.org/issue3445""" - if six.PY3: - return functools.WRAPPER_ASSIGNMENTS - else: - assigned = [] - for attr_name in functools.WRAPPER_ASSIGNMENTS: - if hasattr(decorator, attr_name): - assigned.append(attr_name) - return tuple(assigned) + return functools.WRAPPER_ASSIGNMENTS def get_class_name(obj, fully_qualified=True): @@ -108,7 +99,7 @@ def get_class_name(obj, fully_qualified=True): Else, fully qualified name of the type of the object is returned. For builtin types, just name is returned. """ - if not isinstance(obj, six.class_types): + if not isinstance(obj, type): obj = type(obj) try: built_in = obj.__module__ in _BUILTIN_MODULES @@ -129,7 +120,7 @@ def get_method_self(method): if not inspect.ismethod(method): return None try: - return six.get_method_self(method) + return getattr(method, '__self__') except AttributeError: return None @@ -142,7 +133,7 @@ def get_callable_name(function): method_self = get_method_self(function) if method_self is not None: # This is a bound method. - if isinstance(method_self, six.class_types): + if isinstance(method_self, type): # This is a bound class method. im_class = method_self else: diff --git a/debtcollector/moves.py b/debtcollector/moves.py index 27c10e2..519a9b3 100644 --- a/debtcollector/moves.py +++ b/debtcollector/moves.py @@ -14,9 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. +import functools import inspect -import six import wrapt from debtcollector import _utils @@ -76,7 +76,7 @@ def moved_function(new_func, old_func_name, old_module_name, message=message, version=version, removal_version=removal_version) - @six.wraps(new_func, assigned=_utils.get_assigned(new_func)) + @functools.wraps(new_func, assigned=_utils.get_assigned(new_func)) def old_new_func(*args, **kwargs): _utils.deprecation(out_message, stacklevel=stacklevel, category=category) @@ -183,7 +183,7 @@ def moved_class(new_class, old_class_name, old_module_name, def decorator(f): - @six.wraps(f, assigned=_utils.get_assigned(f)) + @functools.wraps(f, assigned=_utils.get_assigned(f)) def wrapper(self, *args, **kwargs): _utils.deprecation(out_message, stacklevel=stacklevel, category=category) diff --git a/debtcollector/removals.py b/debtcollector/removals.py index aa416ed..ea44c67 100644 --- a/debtcollector/removals.py +++ b/debtcollector/removals.py @@ -15,7 +15,6 @@ import functools import inspect -import six import wrapt from debtcollector import _utils @@ -270,7 +269,7 @@ def removed_class(cls_name, replacement=None, message=None, def _wrap_it(old_init, out_message): - @six.wraps(old_init, assigned=_utils.get_assigned(old_init)) + @functools.wraps(old_init, assigned=_utils.get_assigned(old_init)) def new_init(self, *args, **kwargs): _utils.deprecation(out_message, stacklevel=stacklevel, category=category) @@ -315,7 +314,7 @@ def removed_module(module, replacement=None, message=None, """ if inspect.ismodule(module): module_name = _get_qualified_name(module) - elif isinstance(module, six.string_types): + elif isinstance(module, str): module_name = module else: _qual, type_name = _utils.get_qualified_name(type(module)) diff --git a/requirements.txt b/requirements.txt index ae353a3..8e9f61c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,4 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 importlib_metadata>=1.7.0;python_version<'3.8' # Apache-2.0 -six>=1.10.0 # MIT wrapt>=1.7.0 # BSD License