summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-03-08 16:02:59 +0000
committerGerrit Code Review <review@openstack.org>2021-03-08 16:02:59 +0000
commit8e804292db6922516e8a6fd52d14dcd64396d00c (patch)
treedc917fcfb5c55a13aec7f62afd2c7c1e436bbb3a
parentd2b3351a57ae054cbd7cdef2c8e0bca5f22ae0b0 (diff)
parentcea1f674ae1ce545c0cac209b423ac9d626f0c68 (diff)
downloadpython-cinderclient-8e804292db6922516e8a6fd52d14dcd64396d00c.tar.gz
Merge "Remove all usage of six library"
-rw-r--r--cinderclient/apiclient/base.py5
-rw-r--r--cinderclient/base.py8
-rw-r--r--cinderclient/client.py13
-rw-r--r--cinderclient/shell.py7
-rw-r--r--cinderclient/shell_utils.py4
-rw-r--r--cinderclient/tests/functional/base.py6
-rw-r--r--cinderclient/tests/functional/test_snapshot_create_cli.py4
-rw-r--r--cinderclient/tests/functional/test_volume_create_cli.py9
-rw-r--r--cinderclient/tests/functional/test_volume_extend_cli.py12
-rw-r--r--cinderclient/tests/unit/test_api_versions.py3
-rw-r--r--cinderclient/tests/unit/test_base.py15
-rw-r--r--cinderclient/tests/unit/test_client.py7
-rw-r--r--cinderclient/tests/unit/test_shell.py4
-rw-r--r--cinderclient/tests/unit/test_utils.py15
-rw-r--r--cinderclient/tests/unit/utils.py5
-rw-r--r--cinderclient/tests/unit/v2/fakes.py2
-rw-r--r--cinderclient/tests/unit/v2/test_availability_zone.py24
-rw-r--r--cinderclient/tests/unit/v2/test_shell.py2
-rw-r--r--cinderclient/tests/unit/v3/test_messages.py2
-rw-r--r--cinderclient/tests/unit/v3/test_shell.py11
-rw-r--r--cinderclient/tests/unit/v3/test_volumes.py3
-rw-r--r--cinderclient/utils.py37
-rw-r--r--cinderclient/v2/shell.py6
-rw-r--r--cinderclient/v3/group_types.py2
-rw-r--r--cinderclient/v3/groups.py2
-rw-r--r--cinderclient/v3/shell.py27
-rw-r--r--cinderclient/v3/volume_types.py2
-rw-r--r--lower-constraints.txt1
-rw-r--r--requirements.txt1
-rwxr-xr-xtools/colorizer.py3
-rw-r--r--tools/install_venv.py3
-rwxr-xr-xtools/lintstack.py2
32 files changed, 83 insertions, 164 deletions
diff --git a/cinderclient/apiclient/base.py b/cinderclient/apiclient/base.py
index f1febe3..c0bcd24 100644
--- a/cinderclient/apiclient/base.py
+++ b/cinderclient/apiclient/base.py
@@ -27,7 +27,7 @@ import abc
import copy
from requests import Response
-import six
+
from cinderclient.apiclient import exceptions
from cinderclient import utils
@@ -199,8 +199,7 @@ class BaseManager(HookableMixin):
return self.client.delete(url)
-@six.add_metaclass(abc.ABCMeta)
-class ManagerWithFind(BaseManager):
+class ManagerWithFind(BaseManager, metaclass=abc.ABCMeta):
"""Manager with additional `find()`/`findall()` methods."""
@abc.abstractmethod
diff --git a/cinderclient/base.py b/cinderclient/base.py
index 40ce381..f86a3a8 100644
--- a/cinderclient/base.py
+++ b/cinderclient/base.py
@@ -23,8 +23,6 @@ import contextlib
import hashlib
import os
-import six
-
from cinderclient.apiclient import base as common_base
from cinderclient import exceptions
from cinderclient import utils
@@ -153,7 +151,7 @@ class Manager(common_base.HookableMixin):
if offset:
query_params['offset'] = offset
- query_params = utils.unicode_key_value_to_string(query_params)
+ query_params = query_params
# Transform the dict to a sequence of two-element tuples in fixed
# order, then the encoded string will be consistent in Python 2&3.
@@ -188,7 +186,7 @@ class Manager(common_base.HookableMixin):
if not sort:
return None
- if isinstance(sort, six.string_types):
+ if isinstance(sort, str):
# Convert the string into a list for consistent validation
sort = [s for s in sort.split(',') if s]
@@ -352,7 +350,7 @@ class Manager(common_base.HookableMixin):
self.api.client.delete_with_base_url(url)
-class ManagerWithFind(six.with_metaclass(abc.ABCMeta, Manager)):
+class ManagerWithFind(Manager, metaclass=abc.ABCMeta):
"""
Like a `Manager`, but with additional `find()`/`findall()` methods.
"""
diff --git a/cinderclient/client.py b/cinderclient/client.py
index ffc491f..2d7b80d 100644
--- a/cinderclient/client.py
+++ b/cinderclient/client.py
@@ -24,7 +24,8 @@ import logging
import os
import pkgutil
import re
-import six
+import urllib
+from urllib import parse as urlparse
from keystoneauth1 import access
from keystoneauth1 import adapter
@@ -34,8 +35,6 @@ from oslo_utils import encodeutils
from oslo_utils import importutils
from oslo_utils import strutils
import requests
-from six.moves import urllib
-import six.moves.urllib.parse as urlparse
from cinderclient._i18n import _
from cinderclient import api_versions
@@ -131,7 +130,7 @@ def get_server_version(url, insecure=False, cacert=None):
current_version = '2.0'
except exceptions.ClientException as e:
logger.warning("Error in server version query:%s\n"
- "Returning APIVersion 2.0", six.text_type(e.message))
+ "Returning APIVersion 2.0", str(e.message))
return (api_versions.APIVersion(min_version),
api_versions.APIVersion(current_version))
@@ -239,7 +238,7 @@ class SessionClient(adapter.LegacyJsonAdapter):
version = get_volume_api_from_url(self.get_endpoint())
except exceptions.UnsupportedVersion as e:
msg = (_("Service catalog returned invalid url.\n"
- "%s") % six.text_type(e))
+ "%s") % str(e))
raise exceptions.UnsupportedVersion(msg)
return version
@@ -496,10 +495,10 @@ class HTTPClient(object):
except exceptions.UnsupportedVersion as e:
if self.management_url == self.os_endpoint:
msg = (_("Invalid url was specified in --os-endpoint %s")
- % six.text_type(e))
+ % str(e))
else:
msg = (_("Service catalog returned invalid url.\n"
- "%s") % six.text_type(e))
+ "%s") % str(e))
raise exceptions.UnsupportedVersion(msg)
diff --git a/cinderclient/shell.py b/cinderclient/shell.py
index ff8c4c4..9e9cfb1 100644
--- a/cinderclient/shell.py
+++ b/cinderclient/shell.py
@@ -32,8 +32,7 @@ from keystoneauth1 import session
from oslo_utils import encodeutils
from oslo_utils import importutils
import requests
-import six
-import six.moves.urllib.parse as urlparse
+from urllib import parse as urlparse
import cinderclient
from cinderclient._i18n import _
@@ -395,7 +394,7 @@ class OpenStackCinderShell(object):
else:
msg = (_(" (Supported until API version %(end)s)")
% {"end": end_version.get_string()})
- return six.text_type(msg)
+ return str(msg)
def _find_actions(self, subparsers, actions_module, version,
do_help, input_args):
@@ -1026,7 +1025,7 @@ def main():
sys.exit(130)
except Exception as e:
logger.debug(e, exc_info=1)
- print("ERROR: %s" % six.text_type(e), file=sys.stderr)
+ print("ERROR: %s" % str(e), file=sys.stderr)
sys.exit(1)
diff --git a/cinderclient/shell_utils.py b/cinderclient/shell_utils.py
index b5db281..cd8f162 100644
--- a/cinderclient/shell_utils.py
+++ b/cinderclient/shell_utils.py
@@ -201,7 +201,7 @@ def print_resource_filter_list(filters):
def quota_show(quotas):
- quotas_info_dict = utils.unicode_key_value_to_string(quotas._info)
+ quotas_info_dict = quotas._info
quota_dict = {}
for resource in quotas_info_dict.keys():
good_name = False
@@ -216,7 +216,7 @@ def quota_show(quotas):
def quota_usage_show(quotas):
quota_list = []
- quotas_info_dict = utils.unicode_key_value_to_string(quotas._info)
+ quotas_info_dict = quotas._info
for resource in quotas_info_dict.keys():
good_name = False
for name in _quota_resources:
diff --git a/cinderclient/tests/functional/base.py b/cinderclient/tests/functional/base.py
index 3d2e2f8..2f03475 100644
--- a/cinderclient/tests/functional/base.py
+++ b/cinderclient/tests/functional/base.py
@@ -10,10 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+import configparser
import os
import time
-import six
from tempest.lib.cli import base
from tempest.lib.cli import output_parser
from tempest.lib import exceptions
@@ -38,7 +38,7 @@ def credentials():
os.environ.get('OS_PROJECT_NAME'))
auth_url = os.environ.get('OS_AUTH_URL')
- config = six.moves.configparser.RawConfigParser()
+ config = configparser.RawConfigParser()
if config.read(_CREDS_FILE):
username = username or config.get('admin', 'user')
password = password or config.get('admin', 'pass')
@@ -101,7 +101,7 @@ class ClientTestBase(base.ClientTestBase):
obj = {}
items = self.parser.listing(output)
for item in items:
- obj[item['Property']] = six.text_type(item['Value'])
+ obj[item['Property']] = str(item['Value'])
return obj
def object_cmd(self, object_name, cmd):
diff --git a/cinderclient/tests/functional/test_snapshot_create_cli.py b/cinderclient/tests/functional/test_snapshot_create_cli.py
index 7ef5dfd..4c0bd12 100644
--- a/cinderclient/tests/functional/test_snapshot_create_cli.py
+++ b/cinderclient/tests/functional/test_snapshot_create_cli.py
@@ -10,7 +10,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-import six
+
from cinderclient.tests.functional import base
@@ -47,7 +47,7 @@ class CinderSnapshotTests(base.ClientTestBase):
'snapshot',
params='--metadata test_metadata=test_date {0}'.format(
self.volume['id']))
- self.assertEqual(six.text_type({u'test_metadata': u'test_date'}),
+ self.assertEqual(str({'test_metadata': 'test_date'}),
snapshot['metadata'])
self.object_delete('snapshot', snapshot['id'])
self.check_object_deleted('snapshot', snapshot['id'])
diff --git a/cinderclient/tests/functional/test_volume_create_cli.py b/cinderclient/tests/functional/test_volume_create_cli.py
index deae383..9c9fc0d 100644
--- a/cinderclient/tests/functional/test_volume_create_cli.py
+++ b/cinderclient/tests/functional/test_volume_create_cli.py
@@ -11,7 +11,6 @@
# under the License.
import ddt
-import six
from tempest.lib import exceptions
from cinderclient.tests.functional import base
@@ -32,9 +31,9 @@ class CinderVolumeNegativeTests(base.ClientTestBase):
)
@ddt.unpack
def test_volume_create_with_incorrect_size(self, value, ex_text):
-
- six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
- self.object_create, 'volume', params=value)
+ self.assertRaisesRegex(exceptions.CommandFailed,
+ ex_text, self.object_create,
+ 'volume', params=value)
class CinderVolumeTests(base.ClientTestBase):
@@ -96,5 +95,5 @@ class CinderVolumeTestsWithParameters(base.ClientTestBase):
"""
volume = self.object_create(
'volume', params='--metadata test_metadata=test_date 1')
- self.assertEqual(six.text_type({u'test_metadata': u'test_date'}),
+ self.assertEqual(str({'test_metadata': 'test_date'}),
volume['metadata'])
diff --git a/cinderclient/tests/functional/test_volume_extend_cli.py b/cinderclient/tests/functional/test_volume_extend_cli.py
index 8dd557a..6a5c99c 100644
--- a/cinderclient/tests/functional/test_volume_extend_cli.py
+++ b/cinderclient/tests/functional/test_volume_extend_cli.py
@@ -11,8 +11,6 @@
# under the License.
import ddt
-import six
-
from tempest.lib import exceptions
from cinderclient.tests.functional import base
@@ -39,9 +37,8 @@ class CinderVolumeExtendNegativeTests(base.ClientTestBase):
)
@ddt.unpack
def test_volume_extend_with_incorrect_size(self, value, ex_text):
-
- six.assertRaisesRegex(
- self, exceptions.CommandFailed, ex_text, self.cinder, 'extend',
+ self.assertRaisesRegex(
+ exceptions.CommandFailed, ex_text, self.cinder, 'extend',
params='{0} {1}'.format(self.volume['id'], value))
@ddt.data(
@@ -52,7 +49,6 @@ class CinderVolumeExtendNegativeTests(base.ClientTestBase):
)
@ddt.unpack
def test_volume_extend_with_incorrect_volume_id(self, value, ex_text):
-
- six.assertRaisesRegex(
- self, exceptions.CommandFailed, ex_text, self.cinder, 'extend',
+ self.assertRaisesRegex(
+ exceptions.CommandFailed, ex_text, self.cinder, 'extend',
params='{0} 2'.format(value))
diff --git a/cinderclient/tests/unit/test_api_versions.py b/cinderclient/tests/unit/test_api_versions.py
index 0f86900..d8aad76 100644
--- a/cinderclient/tests/unit/test_api_versions.py
+++ b/cinderclient/tests/unit/test_api_versions.py
@@ -16,7 +16,6 @@
from unittest import mock
import ddt
-import six
from cinderclient import api_versions
from cinderclient import client as base_client
@@ -273,4 +272,4 @@ class DiscoverVersionTestCase(utils.TestCase):
v2_client = base_client.Client('2.0')
ex = self.assertRaises(exceptions.UnsupportedVersion,
api_versions.get_highest_version, v2_client)
- self.assertIn('Invalid client version 2.0 to get', six.text_type(ex))
+ self.assertIn('Invalid client version 2.0 to get', str(ex))
diff --git a/cinderclient/tests/unit/test_base.py b/cinderclient/tests/unit/test_base.py
index 1b54549..6ec2ca6 100644
--- a/cinderclient/tests/unit/test_base.py
+++ b/cinderclient/tests/unit/test_base.py
@@ -15,7 +15,6 @@
from unittest import mock
import requests
-import six
from cinderclient import api_versions
from cinderclient.apiclient import base as common_base
@@ -111,20 +110,6 @@ class BaseTest(utils.TestCase):
r1 = base.Resource(manager, {'id': 1})
self.assertEqual(version, r1.api_version)
- @mock.patch('cinderclient.utils.unicode_key_value_to_string',
- side_effect=lambda x: x)
- def test_build_list_url_failed(self, fake_encode):
- # NOTE(mdovgal): This test is reasonable only for py27 version,
- # due to issue with parse.urlencode method only in py27
- if six.PY2:
- arguments = dict(resource_type = 'volumes',
- search_opts = {'all_tenants': 1,
- 'name': u'ффф'})
- manager = base.Manager(None)
- self.assertRaises(UnicodeEncodeError,
- manager._build_list_url,
- **arguments)
-
def test__list_no_link(self):
api = mock.Mock()
api.client.get.return_value = (mock.sentinel.resp,
diff --git a/cinderclient/tests/unit/test_client.py b/cinderclient/tests/unit/test_client.py
index 6770f24..d92e1f2 100644
--- a/cinderclient/tests/unit/test_client.py
+++ b/cinderclient/tests/unit/test_client.py
@@ -20,7 +20,6 @@ import fixtures
from keystoneauth1 import adapter
from keystoneauth1 import exceptions as keystone_exception
from oslo_serialization import jsonutils
-import six
from cinderclient import api_versions
import cinderclient.client
@@ -136,7 +135,7 @@ class ClientTest(utils.TestCase):
request_id = "req-f551871a-4950-4225-9b2c-29a14c8f075e"
mock_response = utils.TestResponse({
"status_code": 202,
- "text": six.b(json.dumps(resp)),
+ "text": json.dumps(resp).encode("latin-1"),
"headers": {"x-openstack-request-id": request_id},
})
@@ -176,7 +175,7 @@ class ClientTest(utils.TestCase):
mock_response = utils.TestResponse({
"status_code": 400,
- "text": six.b(json.dumps(resp)),
+ "text": json.dumps(resp).encode("latin-1"),
})
# 'request' method of Adaptor will return 400 response
@@ -202,7 +201,7 @@ class ClientTest(utils.TestCase):
mock_response = utils.TestResponse({
"status_code": 413,
- "text": six.b(json.dumps(resp)),
+ "text": json.dumps(resp).encode("latin-1"),
})
# 'request' method of Adaptor will return 413 response
diff --git a/cinderclient/tests/unit/test_shell.py b/cinderclient/tests/unit/test_shell.py
index c8a6375..8c5df11 100644
--- a/cinderclient/tests/unit/test_shell.py
+++ b/cinderclient/tests/unit/test_shell.py
@@ -12,6 +12,7 @@
# limitations under the License.
import argparse
+import io
import re
import sys
import unittest
@@ -24,7 +25,6 @@ from keystoneauth1.exceptions import DiscoveryFailure
from keystoneauth1.identity.generic.password import Password as ks_password
from keystoneauth1 import session
import requests_mock
-from six import moves
from testtools import matchers
import cinderclient
@@ -64,7 +64,7 @@ class ShellTest(utils.TestCase):
def shell(self, argstr):
orig = sys.stdout
try:
- sys.stdout = moves.StringIO()
+ sys.stdout = io.StringIO()
_shell = shell.OpenStackCinderShell()
_shell.main(argstr.split())
except SystemExit:
diff --git a/cinderclient/tests/unit/test_utils.py b/cinderclient/tests/unit/test_utils.py
index 1243b0a..a9636db 100644
--- a/cinderclient/tests/unit/test_utils.py
+++ b/cinderclient/tests/unit/test_utils.py
@@ -12,12 +12,11 @@
# limitations under the License.
import collections
+import io
import sys
from unittest import mock
import ddt
-import six
-from six import moves
from cinderclient import api_versions
from cinderclient.apiclient import base as common_base
@@ -151,7 +150,7 @@ class CaptureStdout(object):
"""Context manager for capturing stdout from statements in its block."""
def __enter__(self):
self.real_stdout = sys.stdout
- self.stringio = moves.StringIO()
+ self.stringio = io.StringIO()
sys.stdout = self.stringio
return self
@@ -309,16 +308,6 @@ class PrintListTestCase(test_utils.TestCase):
+---+-----+
""", cso.read())
- def test_unicode_key_value_to_string(self):
- src = {u'key': u'\u70fd\u7231\u5a77'}
- expected = {'key': '\xe7\x83\xbd\xe7\x88\xb1\xe5\xa9\xb7'}
- if six.PY2:
- self.assertEqual(expected, utils.unicode_key_value_to_string(src))
- else:
- # u'xxxx' in PY3 is str, we will not get extra 'u' from cli
- # output in PY3
- self.assertEqual(src, utils.unicode_key_value_to_string(src))
-
class PrintDictTestCase(test_utils.TestCase):
diff --git a/cinderclient/tests/unit/utils.py b/cinderclient/tests/unit/utils.py
index 8f4e9ac..680062e 100644
--- a/cinderclient/tests/unit/utils.py
+++ b/cinderclient/tests/unit/utils.py
@@ -18,7 +18,6 @@ from unittest import mock
import fixtures
import requests
from requests_mock.contrib import fixture as requests_mock_fixture
-import six
import testtools
@@ -92,9 +91,9 @@ class FixturedTestCase(TestCase):
if body:
req_data = self.requests.last_request.body
- if isinstance(req_data, six.binary_type):
+ if isinstance(req_data, bytes):
req_data = req_data.decode('utf-8')
- if not isinstance(body, six.string_types):
+ if not isinstance(body, str):
# json load if the input body to match against is not a string
req_data = json.loads(req_data)
self.assertEqual(body, req_data)
diff --git a/cinderclient/tests/unit/v2/fakes.py b/cinderclient/tests/unit/v2/fakes.py
index 0dd269e..99a87d0 100644
--- a/cinderclient/tests/unit/v2/fakes.py
+++ b/cinderclient/tests/unit/v2/fakes.py
@@ -14,7 +14,7 @@
from datetime import datetime
-import six.moves.urllib.parse as urlparse
+from urllib import parse as urlparse
from cinderclient import client as base_client
from cinderclient.tests.unit import fakes
diff --git a/cinderclient/tests/unit/v2/test_availability_zone.py b/cinderclient/tests/unit/v2/test_availability_zone.py
index 8c2e1eb..e9b5d02 100644
--- a/cinderclient/tests/unit/v2/test_availability_zone.py
+++ b/cinderclient/tests/unit/v2/test_availability_zone.py
@@ -14,8 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import six
-
from cinderclient.v2 import availability_zones
from cinderclient.v2 import shell
@@ -44,8 +42,8 @@ class AvailabilityZoneTest(utils.FixturedTestCase):
self.assertEqual(2, len(zones))
- l0 = [six.u('zone-1'), six.u('available')]
- l1 = [six.u('zone-2'), six.u('not available')]
+ l0 = ['zone-1', 'available']
+ l1 = ['zone-2', 'not available']
z0 = shell.treeizeAvailabilityZone(zones[0])
z1 = shell.treeizeAvailabilityZone(zones[1])
@@ -66,15 +64,15 @@ class AvailabilityZoneTest(utils.FixturedTestCase):
self.assertEqual(3, len(zones))
- l0 = [six.u('zone-1'), six.u('available')]
- l1 = [six.u('|- fake_host-1'), six.u('')]
- l2 = [six.u('| |- cinder-volume'),
- six.u('enabled :-) 2012-12-26 14:45:25')]
- l3 = [six.u('internal'), six.u('available')]
- l4 = [six.u('|- fake_host-1'), six.u('')]
- l5 = [six.u('| |- cinder-sched'),
- six.u('enabled :-) 2012-12-26 14:45:24')]
- l6 = [six.u('zone-2'), six.u('not available')]
+ l0 = ['zone-1', 'available']
+ l1 = ['|- fake_host-1', '']
+ l2 = ['| |- cinder-volume',
+ 'enabled :-) 2012-12-26 14:45:25']
+ l3 = ['internal', 'available']
+ l4 = ['|- fake_host-1', '']
+ l5 = ['| |- cinder-sched',
+ 'enabled :-) 2012-12-26 14:45:24']
+ l6 = ['zone-2', 'not available']
z0 = shell.treeizeAvailabilityZone(zones[0])
z1 = shell.treeizeAvailabilityZone(zones[1])
diff --git a/cinderclient/tests/unit/v2/test_shell.py b/cinderclient/tests/unit/v2/test_shell.py
index f6f6355..f54846e 100644
--- a/cinderclient/tests/unit/v2/test_shell.py
+++ b/cinderclient/tests/unit/v2/test_shell.py
@@ -18,7 +18,7 @@ from unittest import mock
import ddt
import fixtures
from requests_mock.contrib import fixture as requests_mock_fixture
-from six.moves.urllib import parse
+from urllib import parse
from cinderclient import client
from cinderclient import exceptions
diff --git a/cinderclient/tests/unit/v3/test_messages.py b/cinderclient/tests/unit/v3/test_messages.py
index 262a777..9f22996 100644
--- a/cinderclient/tests/unit/v3/test_messages.py
+++ b/cinderclient/tests/unit/v3/test_messages.py
@@ -9,9 +9,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
+from urllib import parse
import ddt
-from six.moves.urllib import parse
from cinderclient import api_versions
from cinderclient.tests.unit import utils
diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py
index 314259d..82e3943 100644
--- a/cinderclient/tests/unit/v3/test_shell.py
+++ b/cinderclient/tests/unit/v3/test_shell.py
@@ -39,12 +39,11 @@
# return original(manager, name_or_id, **kwargs)
from unittest import mock
+from urllib import parse
import ddt
import fixtures
from requests_mock.contrib import fixture as requests_mock_fixture
-import six
-from six.moves.urllib import parse
import cinderclient
from cinderclient import api_versions
@@ -322,7 +321,7 @@ class ShellTest(utils.TestCase):
self.assert_call_contained(
parse.urlencode(
{'extra_specs':
- {six.text_type('key'): six.text_type('value')}}))
+ {'key': 'value'}}))
self.assert_call_contained(parse.urlencode({'is_public': None}))
def test_type_list_public(self):
@@ -1150,11 +1149,7 @@ class ShellTest(utils.TestCase):
self.run_command, '--os-volume-api-version 3.32 '
'service-set-log')
set_levels_mock.assert_not_called()
- # Different error message from argparse library in Python 2 and 3
- if six.PY3:
- msg = 'the following arguments are required: <log-level>'
- else:
- msg = 'too few arguments'
+ msg = 'the following arguments are required: <log-level>'
error_mock.assert_called_once_with(msg)
@ddt.data('debug', 'DEBUG', 'info', 'INFO', 'warning', 'WARNING', 'error',
diff --git a/cinderclient/tests/unit/v3/test_volumes.py b/cinderclient/tests/unit/v3/test_volumes.py
index 79206f6..e5b3f21 100644
--- a/cinderclient/tests/unit/v3/test_volumes.py
+++ b/cinderclient/tests/unit/v3/test_volumes.py
@@ -14,6 +14,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
+from urllib import parse
import ddt
@@ -24,8 +25,6 @@ from cinderclient.tests.unit.v3 import fakes
from cinderclient.v3 import volume_snapshots
from cinderclient.v3 import volumes
-from six.moves.urllib import parse
-
@ddt.ddt
class VolumesTest(utils.TestCase):
diff --git a/cinderclient/utils.py b/cinderclient/utils.py
index 3b00967..8919fc6 100644
--- a/cinderclient/utils.py
+++ b/cinderclient/utils.py
@@ -12,15 +12,14 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-import collections
+import collections
import os
import sys
+from urllib import parse
import uuid
import prettytable
-import six
-from six.moves.urllib import parse
import stevedore
from cinderclient import exceptions
@@ -156,7 +155,7 @@ def print_list(objs, fields, exclude_unavailable=False, formatters=None,
data = getattr(o, field_name, '')
if data is None:
data = '-'
- if isinstance(data, six.string_types) and "\r" in data:
+ if isinstance(data, str) and "\r" in data:
data = data.replace("\r", " ")
row.append(data)
rows.append(row)
@@ -172,7 +171,6 @@ def print_list(objs, fields, exclude_unavailable=False, formatters=None,
for part in row:
count = count + 1
if isinstance(part, dict):
- part = unicode_key_value_to_string(part)
row[count - 1] = part
pt.add_row(row)
@@ -183,24 +181,6 @@ def print_list(objs, fields, exclude_unavailable=False, formatters=None,
_print(pt, order_by)
-def _encode(src):
- """remove extra 'u' in PY2."""
- if six.PY2 and isinstance(src, six.text_type):
- return src.encode('utf-8')
- return src
-
-
-def unicode_key_value_to_string(src):
- """Recursively converts dictionary keys to strings."""
- if isinstance(src, dict):
- return dict((_encode(k),
- _encode(unicode_key_value_to_string(v)))
- for k, v in src.items())
- if isinstance(src, list):
- return [unicode_key_value_to_string(item) for item in src]
- return _encode(src)
-
-
def build_query_param(params, sort=False):
"""parse list to url query parameters"""
@@ -249,10 +229,9 @@ def print_dict(d, property="Property", formatters=None):
r = list(r)
if r[0] in formatters:
- r[1] = unicode_key_value_to_string(r[1])
if isinstance(r[1], dict):
r[1] = _pretty_format_dict(r[1])
- if isinstance(r[1], six.string_types) and "\r" in r[1]:
+ if isinstance(r[1], str) and "\r" in r[1]:
r[1] = r[1].replace("\r", " ")
pt.add_row(r)
_print(pt, property)
@@ -343,10 +322,4 @@ def _load_entry_point(ep_name, name=None):
def get_function_name(func):
- if six.PY2:
- if hasattr(func, "im_class"):
- return "%s.%s" % (func.im_class, func.__name__)
- else:
- return "%s.%s" % (func.__module__, func.__name__)
- else:
- return "%s.%s" % (func.__module__, func.__qualname__)
+ return "%s.%s" % (func.__module__, func.__qualname__)
diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py
index d41e014..e3f8682 100644
--- a/cinderclient/v2/shell.py
+++ b/cinderclient/v2/shell.py
@@ -20,7 +20,6 @@ import copy
import os
from oslo_utils import strutils
-import six
from cinderclient import base
from cinderclient import exceptions
@@ -295,7 +294,7 @@ def do_create(cs, args):
# NOTE(vish): multiple copies of same hint will
# result in a list of values
if key in hints:
- if isinstance(hints[key], six.string_types):
+ if isinstance(hints[key], str):
hints[key] = [hints[key]]
hints[key] += [value]
else:
@@ -1113,8 +1112,7 @@ def do_migrate(cs, args):
args.lock_volume)
print("Request to migrate volume %s has been accepted." % (volume.id))
except Exception as e:
- print("Migration for volume %s failed: %s." % (volume.id,
- six.text_type(e)))
+ print("Migration for volume %s failed: %s." % (volume.id, e))
@utils.arg('volume', metavar='<volume>',
diff --git a/cinderclient/v3/group_types.py b/cinderclient/v3/group_types.py
index 74ea9b7..696f02b 100644
--- a/cinderclient/v3/group_types.py
+++ b/cinderclient/v3/group_types.py
@@ -16,7 +16,7 @@
"""Group Type interface."""
-from six.moves.urllib import parse
+from urllib import parse
from cinderclient import api_versions
from cinderclient import base
diff --git a/cinderclient/v3/groups.py b/cinderclient/v3/groups.py
index e42f750..310006c 100644
--- a/cinderclient/v3/groups.py
+++ b/cinderclient/v3/groups.py
@@ -137,7 +137,7 @@ class GroupManager(base.ManagerWithFind):
:param group_id: The ID of the group to get.
:rtype: :class:`Group`
"""
- query_params = utils.unicode_key_value_to_string(kwargs)
+ query_params = kwargs
query_string = utils.build_query_param(query_params, sort=True)
return self._get("/groups/%s" % group_id + query_string,
diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py
index 3065352..6d7d1eb 100644
--- a/cinderclient/v3/shell.py
+++ b/cinderclient/v3/shell.py
@@ -19,7 +19,6 @@ import collections
import os
from oslo_utils import strutils
-import six
import cinderclient
from cinderclient import api_versions
@@ -60,7 +59,7 @@ def do_list_filters(cs, args):
@utils.arg('--filters',
action=AppendFilters,
- type=six.text_type,
+ type=str,
nargs='*',
start_version='3.52',
metavar='<key=value>',
@@ -142,7 +141,7 @@ def do_type_list(cs, args):
'Default=None.') % ', '.join(base.SORT_KEY_VALUES)))
@utils.arg('--filters',
action=AppendFilters,
- type=six.text_type,
+ type=str,
nargs='*',
start_version='3.33',
metavar='<key=value>',
@@ -291,7 +290,7 @@ def do_backup_restore(cs, args):
help='Show detailed information about pools.')
@utils.arg('--filters',
action=AppendFilters,
- type=six.text_type,
+ type=str,
nargs='*',
start_version='3.33',
metavar='<key=value>',
@@ -419,7 +418,7 @@ RESET_STATE_RESOURCES = {'volume': utils.find_volume,
help='Display information from single tenant (Admin only).')
@utils.arg('--filters',
action=AppendFilters,
- type=six.text_type,
+ type=str,
nargs='*',
start_version='3.33',
metavar='<key=value>',
@@ -697,7 +696,7 @@ def do_create(cs, args):
# NOTE(vish): multiple copies of same hint will
# result in a list of values
if key in hints:
- if isinstance(hints[key], six.string_types):
+ if isinstance(hints[key], str):
hints[key] = [hints[key]]
hints[key] += [value]
else:
@@ -816,7 +815,7 @@ def do_summary(cs, args):
@api_versions.wraps('3.11')
@utils.arg('--filters',
action=AppendFilters,
- type=six.text_type,
+ type=str,
nargs='*',
start_version='3.52',
metavar='<key=value>',
@@ -1099,7 +1098,7 @@ def do_migrate(cs, args):
print("Request to migrate volume %s has been accepted." % (volume.id))
except Exception as e:
print("Migration for volume %s failed: %s." % (volume.id,
- six.text_type(e)))
+ str(e)))
@api_versions.wraps('3.9')
@@ -1406,7 +1405,7 @@ def do_manageable_list(cs, args):
help='Shows details for all tenants. Admin only.')
@utils.arg('--filters',
action=AppendFilters,
- type=six.text_type,
+ type=str,
nargs='*',
start_version='3.33',
metavar='<key=value>',
@@ -1718,7 +1717,7 @@ def do_group_list_replication_targets(cs, args):
"%s" % FILTER_DEPRECATED)
@utils.arg('--filters',
action=AppendFilters,
- type=six.text_type,
+ type=str,
nargs='*',
start_version='3.33',
metavar='<key=value>',
@@ -1970,7 +1969,7 @@ def do_revert_to_snapshot(cs, args):
"%s" % FILTER_DEPRECATED)
@utils.arg('--filters',
action=AppendFilters,
- type=six.text_type,
+ type=str,
nargs='*',
start_version='3.33',
metavar='<key=value>',
@@ -2110,7 +2109,7 @@ def do_message_delete(cs, args):
"%s" % FILTER_DEPRECATED)
@utils.arg('--filters',
action=AppendFilters,
- type=six.text_type,
+ type=str,
nargs='*',
start_version='3.33',
metavar='<key=value>',
@@ -2239,7 +2238,7 @@ def do_snapshot_list(cs, args):
help='Display information from single tenant (Admin only).')
@utils.arg('--filters',
action=AppendFilters,
- type=six.text_type,
+ type=str,
nargs='*',
start_version='3.33',
metavar='<key=value>',
@@ -2639,7 +2638,7 @@ def do_transfer_create(cs, args):
start_version='3.59')
@utils.arg('--filters',
action=AppendFilters,
- type=six.text_type,
+ type=str,
nargs='*',
start_version='3.52',
metavar='<key=value>',
diff --git a/cinderclient/v3/volume_types.py b/cinderclient/v3/volume_types.py
index c55a4a4..e82fbb3 100644
--- a/cinderclient/v3/volume_types.py
+++ b/cinderclient/v3/volume_types.py
@@ -15,7 +15,7 @@
"""Volume Type interface."""
-from six.moves.urllib import parse
+from urllib import parse
from cinderclient.apiclient import base as common_base
from cinderclient import base
diff --git a/lower-constraints.txt b/lower-constraints.txt
index d0c0ef7..947303a 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -52,7 +52,6 @@ requests-mock==1.2.0
requests==2.23.0
rfc3986==1.4.0
simplejson==3.5.1
-six==1.15.0
stestr==3.0.1
stevedore==3.2.2
tempest==26.0.0
diff --git a/requirements.txt b/requirements.txt
index f5445f4..1a5d13d 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,7 +5,6 @@ pbr>=5.5.0 # Apache-2.0
PrettyTable>=0.7.2 # BSD
keystoneauth1>=4.2.1 # Apache-2.0
simplejson>=3.5.1 # MIT
-six>=1.15.0 # MIT
oslo.i18n>=5.0.1 # Apache-2.0
oslo.utils>=4.7.0 # Apache-2.0
requests>=2.23.0 # Apache-2.0
diff --git a/tools/colorizer.py b/tools/colorizer.py
index 7824b8c..2a667b4 100755
--- a/tools/colorizer.py
+++ b/tools/colorizer.py
@@ -46,7 +46,6 @@ import subunit
import sys
import unittest
-import six
import testtools
@@ -277,7 +276,7 @@ class NovaTestResult(testtools.TestResult):
self.stopTestRun()
def stopTestRun(self):
- for cls in list(six.iterkeys(self.results)):
+ for cls in list(self.results.keys()):
self.writeTestCase(cls)
self.stream.writeln()
self.writeSlowTests()
diff --git a/tools/install_venv.py b/tools/install_venv.py
index 03fe5af..4ff48a2 100644
--- a/tools/install_venv.py
+++ b/tools/install_venv.py
@@ -18,11 +18,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+import configparser
import os
import sys
-from six.moves import configparser
-
import install_venv_common as install_venv
diff --git a/tools/lintstack.py b/tools/lintstack.py
index 2697776..e0cfc28 100755
--- a/tools/lintstack.py
+++ b/tools/lintstack.py
@@ -16,13 +16,13 @@
"""pylint error checking."""
+from io import StringIO
import json
import re
import sys
from pylint import lint
from pylint.reporters import text
-from six.moves import cStringIO as StringIO
ignore_codes = [
# Note(maoy): E1103 is error code related to partial type inference