Remove six library from dependencies

Since we're not testing or supporting Python 2 anymore, we can
convert six calls to Python 3 and get rid of it.

Change-Id: I474c01ab6ed60aecf16524935f2866e76a66569a
This commit is contained in:
Riccardo Pittau 2020-05-02 11:57:33 +02:00
parent 20b922357e
commit a55d153635
11 changed files with 11 additions and 40 deletions

View File

@ -83,7 +83,6 @@ requestsexceptions==1.2.0
rfc3986==0.3.1
Routes==2.3.1
simplejson==3.5.1
six==1.10.0
smmap==0.9.0
snowballstemmer==1.2.1
Sphinx==1.6.2

View File

@ -16,7 +16,6 @@
from keystoneauth1 import exceptions as ksa_exceptions
from keystoneauth1 import session as ksa_session
import simplejson as json
import six
from osc_lib import exceptions
from osc_lib.i18n import _
@ -90,7 +89,7 @@ class BaseAPI(object):
:return: The modified endpoint
"""
if isinstance(endpoint, six.string_types):
if isinstance(endpoint, str):
return endpoint.rstrip('/')
else:
return endpoint

View File

@ -18,7 +18,6 @@ import logging
from openstack.config import exceptions as sdk_exceptions
from openstack.config import loader as config
from oslo_utils import strutils
import six
LOG = logging.getLogger(__name__)
@ -158,7 +157,7 @@ class OSC_Config(config.OpenStackConfig):
if LOG.isEnabledFor(logging.DEBUG):
LOG.debug("auth_config_hook(): %s",
strutils.mask_password(six.text_type(config)))
strutils.mask_password(str(config)))
return config
def _validate_auth(self, config, loader, fixed_argparse=None):

View File

@ -17,12 +17,10 @@
import copy
import logging
import sys
from openstack.config import loader as config # noqa
from openstack import connection
from oslo_utils import strutils
import six
from osc_lib.api import auth
from osc_lib import exceptions
@ -48,8 +46,7 @@ class ClientCache(object):
except AttributeError as err:
# Make sure the failure propagates. Otherwise, the plugin just
# quietly isn't there.
new_err = exceptions.PluginAttributeError(err)
six.reraise(new_err.__class__, new_err, sys.exc_info()[2])
raise exceptions.PluginAttributeError(err) from err
return self._handle

View File

@ -18,7 +18,6 @@ import logging
from cliff import command
from cliff import lister
from cliff import show
import six
from osc_lib import exceptions
from osc_lib.i18n import _
@ -33,8 +32,7 @@ class CommandMeta(abc.ABCMeta):
return super(CommandMeta, mcs).__new__(mcs, name, bases, cls_dict)
@six.add_metaclass(CommandMeta)
class Command(command.Command):
class Command(command.Command, metaclass=CommandMeta):
def run(self, parsed_args):
self.log.debug('run(%s)', parsed_args)

View File

@ -17,7 +17,6 @@
"""Command-line interface to the OpenStack APIs"""
import getpass
import locale
import logging
import sys
import traceback
@ -28,7 +27,6 @@ from cliff import complete
from cliff import help
from oslo_utils import importutils
from oslo_utils import strutils
import six
from osc_lib.cli import client_config as cloud_config
from osc_lib import clientmanager
@ -522,12 +520,6 @@ class OpenStackShell(app.App):
def main(argv=None):
if argv is None:
argv = sys.argv[1:]
if six.PY2:
# Emulate Py3, decode argv into Unicode based on locale so that
# commands always see arguments as text instead of binary data
encoding = locale.getpreferredencoding()
if encoding:
argv = map(lambda arg: arg.decode(encoding), argv)
return OpenStackShell().run(argv)

View File

@ -17,7 +17,6 @@ import sys
from unittest import mock
from keystoneauth1 import fixture
import six
AUTH_TOKEN = "foobar"
@ -178,7 +177,7 @@ class FakeResource(object):
self._loaded = loaded
def _add_details(self, info):
for (k, v) in six.iteritems(info):
for (k, v) in info.items():
setattr(self, k, v)
def _add_methods(self, methods):
@ -189,7 +188,7 @@ class FakeResource(object):
@value. When users access the attribute with (), @value will be
returned, which looks like a function call.
"""
for (name, ret) in six.iteritems(methods):
for (name, ret) in methods.items():
method = mock.MagicMock(return_value=ret)
setattr(self, name, method)

View File

@ -27,7 +27,6 @@ from openstack.config import cloud_region
from openstack.config import defaults
from oslo_utils import importutils
from requests_mock.contrib import fixture
import six
import testtools
from osc_lib import clientmanager
@ -121,11 +120,7 @@ class TestCase(testtools.TestCase):
with super(TestCase, self).subTest(*args, **kwargs):
yield
except TypeError:
# NOTE(elhararb): subTest is supported by unittest only from PY3.4
if six.PY2:
yield
else:
raise
raise
except AttributeError:
# TODO(elhararb): remove this except clause when subTest is
# enabled in testtools

View File

@ -18,7 +18,6 @@ from unittest import mock
import uuid
from cliff import columns as cliff_columns
import six
from osc_lib.cli import format_columns
from osc_lib import exceptions
@ -206,11 +205,7 @@ class TestUtils(test_utils.TestCase):
item4 = {'a': 1}
items = [item1, item2, item3, item4]
sort_str = 'a'
expect_items = [item3, item4, item1, item2]
if six.PY2:
self.assertEqual(expect_items, utils.sort_items(items, sort_str))
else:
self.assertRaises(TypeError, utils.sort_items, items, sort_str)
self.assertRaises(TypeError, utils.sort_items, items, sort_str)
def test_sort_items_with_different_type_int(self):
item1 = {'a': 2}

View File

@ -24,7 +24,6 @@ import warnings
from cliff import columns as cliff_columns
from oslo_utils import importutils
import six
from osc_lib import exceptions
from osc_lib.i18n import _
@ -51,7 +50,7 @@ def backward_compat_col_lister(column_headers, columns, column_map):
# volume v1, convert it to a list in order to change
# the column name.
column_headers = list(column_headers)
for old_col, new_col in six.iteritems(column_map):
for old_col, new_col in column_map.items():
if old_col in columns:
LOG.warning(_('The column "%(old_column)s" was deprecated, '
'please use "%(new_column)s" replace.') % {
@ -79,7 +78,7 @@ def backward_compat_col_showone(show_object, columns, column_map):
return show_object
show_object = copy.deepcopy(show_object)
for old_col, new_col in six.iteritems(column_map):
for old_col, new_col in column_map.items():
if old_col in columns:
LOG.warning(_('The column "%(old_column)s" was deprecated, '
'please use "%(new_column)s" replace.') % {
@ -316,7 +315,7 @@ def format_dict(data, prefix=None):
# is completely handled in the terminal case.
output = output + format_dict(data[s], prefix=key_str) + ", "
elif data[s] is not None:
output = output + key_str + "='" + six.text_type(data[s]) + "', "
output = output + key_str + "='" + str(data[s]) + "', "
else:
output = output + key_str + "=, "
return output[:-2]

View File

@ -2,7 +2,6 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pbr!=2.1.0,>=2.0.0 # Apache-2.0
six>=1.10.0 # MIT
cliff!=2.9.0,>=2.8.0 # Apache-2.0
keystoneauth1>=3.14.0 # Apache-2.0