Remove six

debtcollector is one of the few remaining OpenStack libraries still
using six. Like the other libraries that have since removed it,
debtcollector no longer actually needs this since it only supports
Python 3. Remove the library.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Ia16572985a46afe39b53a199ebabb695cd05ae2d
This commit is contained in:
Stephen Finucane 2021-11-04 10:40:42 +00:00
parent aa426abafe
commit d0b61a66b5
4 changed files with 9 additions and 20 deletions

View File

@ -19,8 +19,6 @@ import inspect
import types import types
import warnings import warnings
import six
try: try:
_TYPE_TYPE = types.TypeType _TYPE_TYPE = types.TypeType
except AttributeError: except AttributeError:
@ -91,14 +89,7 @@ def generate_message(prefix, postfix=None, message=None,
def get_assigned(decorator): def get_assigned(decorator):
"""Helper to fix/workaround https://bugs.python.org/issue3445""" """Helper to fix/workaround https://bugs.python.org/issue3445"""
if six.PY3: return functools.WRAPPER_ASSIGNMENTS
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)
def get_class_name(obj, fully_qualified=True): 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. Else, fully qualified name of the type of the object is returned.
For builtin types, just name is returned. For builtin types, just name is returned.
""" """
if not isinstance(obj, six.class_types): if not isinstance(obj, type):
obj = type(obj) obj = type(obj)
try: try:
built_in = obj.__module__ in _BUILTIN_MODULES built_in = obj.__module__ in _BUILTIN_MODULES
@ -129,7 +120,7 @@ def get_method_self(method):
if not inspect.ismethod(method): if not inspect.ismethod(method):
return None return None
try: try:
return six.get_method_self(method) return getattr(method, '__self__')
except AttributeError: except AttributeError:
return None return None
@ -142,7 +133,7 @@ def get_callable_name(function):
method_self = get_method_self(function) method_self = get_method_self(function)
if method_self is not None: if method_self is not None:
# This is a bound method. # This is a bound method.
if isinstance(method_self, six.class_types): if isinstance(method_self, type):
# This is a bound class method. # This is a bound class method.
im_class = method_self im_class = method_self
else: else:

View File

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import functools
import inspect import inspect
import six
import wrapt import wrapt
from debtcollector import _utils from debtcollector import _utils
@ -76,7 +76,7 @@ def moved_function(new_func, old_func_name, old_module_name,
message=message, version=version, message=message, version=version,
removal_version=removal_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): def old_new_func(*args, **kwargs):
_utils.deprecation(out_message, stacklevel=stacklevel, _utils.deprecation(out_message, stacklevel=stacklevel,
category=category) category=category)
@ -183,7 +183,7 @@ def moved_class(new_class, old_class_name, old_module_name,
def decorator(f): def decorator(f):
@six.wraps(f, assigned=_utils.get_assigned(f)) @functools.wraps(f, assigned=_utils.get_assigned(f))
def wrapper(self, *args, **kwargs): def wrapper(self, *args, **kwargs):
_utils.deprecation(out_message, stacklevel=stacklevel, _utils.deprecation(out_message, stacklevel=stacklevel,
category=category) category=category)

View File

@ -15,7 +15,6 @@
import functools import functools
import inspect import inspect
import six
import wrapt import wrapt
from debtcollector import _utils from debtcollector import _utils
@ -270,7 +269,7 @@ def removed_class(cls_name, replacement=None, message=None,
def _wrap_it(old_init, out_message): 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): def new_init(self, *args, **kwargs):
_utils.deprecation(out_message, stacklevel=stacklevel, _utils.deprecation(out_message, stacklevel=stacklevel,
category=category) category=category)
@ -315,7 +314,7 @@ def removed_module(module, replacement=None, message=None,
""" """
if inspect.ismodule(module): if inspect.ismodule(module):
module_name = _get_qualified_name(module) module_name = _get_qualified_name(module)
elif isinstance(module, six.string_types): elif isinstance(module, str):
module_name = module module_name = module
else: else:
_qual, type_name = _utils.get_qualified_name(type(module)) _qual, type_name = _utils.get_qualified_name(type(module))

View File

@ -4,5 +4,4 @@
pbr!=2.1.0,>=2.0.0 # Apache-2.0 pbr!=2.1.0,>=2.0.0 # Apache-2.0
importlib_metadata>=1.7.0;python_version<'3.8' # 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 wrapt>=1.7.0 # BSD License