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 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:

View File

@ -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)

View File

@ -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))

View File

@ -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