From 754f6df5a7d59f762734d8648c89f99cefe685a5 Mon Sep 17 00:00:00 2001 From: Yasufumi Ogawa Date: Mon, 19 Oct 2020 06:51:33 +0000 Subject: [PATCH] Drop six support This update is to drop all of six support to move Closes-bug: #1900389 Change-Id: Ia6c61751203e98d432344dc9a52fe65bdb062af0 Signed-off-by: Yasufumi Ogawa --- lower-constraints.txt | 1 - requirements.txt | 1 - tackerclient/common/constants.py | 1 - tackerclient/common/serializer.py | 16 +++------------- tackerclient/common/utils.py | 3 +-- tackerclient/shell.py | 9 ++++----- tackerclient/tacker/v1_0/__init__.py | 4 +--- tackerclient/tacker/v1_0/nfvo/vim_utils.py | 1 + tackerclient/tests/unit/osc/v1/test_vnflcm.py | 3 +-- tackerclient/tests/unit/test_cli10.py | 14 ++++++-------- tackerclient/tests/unit/test_shell.py | 15 +++++++-------- tackerclient/v1_0/client.py | 1 - 12 files changed, 24 insertions(+), 45 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 776b3ceb..50d8ea4e 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -48,7 +48,6 @@ requests-mock==1.2.0 requestsexceptions==1.2.0 rfc3986==0.3.1 simplejson==3.5.1 -six==1.10.0 stestr==2.0.0 stevedore==1.20.0 testtools==2.2.0 diff --git a/requirements.txt b/requirements.txt index d5d0aced..da4a0aca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,6 @@ netaddr>=0.7.18 # BSD requests>=2.14.2 # Apache-2.0 python-keystoneclient>=3.8.0 # Apache-2.0 simplejson>=3.5.1 # MIT -six>=1.10.0 # MIT stevedore>=1.20.0 # Apache-2.0 Babel!=2.4.0,>=2.3.4 # BSD oslo.i18n>=3.15.3 # Apache-2.0 diff --git a/tackerclient/common/constants.py b/tackerclient/common/constants.py index e0737ff9..65500a4c 100644 --- a/tackerclient/common/constants.py +++ b/tackerclient/common/constants.py @@ -28,7 +28,6 @@ ATOM_LINK_NOTATION = "{%s}link" % ATOM_NAMESPACE TYPE_BOOL = "bool" TYPE_INT = "int" -TYPE_LONG = "long" TYPE_FLOAT = "float" TYPE_LIST = "list" TYPE_DICT = "dict" diff --git a/tackerclient/common/serializer.py b/tackerclient/common/serializer.py index b66e9c1a..7869fdae 100644 --- a/tackerclient/common/serializer.py +++ b/tackerclient/common/serializer.py @@ -18,7 +18,6 @@ from xml.etree import ElementTree as etree from xml.parsers import expat from oslo_serialization import jsonutils -import six from tackerclient.common import constants from tackerclient.common import exceptions as exception @@ -26,9 +25,6 @@ from tackerclient.i18n import _ LOG = logging.getLogger(__name__) -if six.PY3: - long = int - class ActionDispatcher(object): """Maps method name to local methods through action name.""" @@ -58,7 +54,7 @@ class JSONDictSerializer(DictSerializer): def default(self, data): def sanitizer(obj): - return six.text_type(obj) + return str(obj) return jsonutils.dumps(data, default=sanitizer) @@ -93,7 +89,7 @@ class XMLDictSerializer(DictSerializer): root_key = constants.VIRTUAL_ROOT_KEY root_value = None else: - link_keys = [k for k in six.iterkeys(data) or [] + link_keys = [k for k in data.keys() or [] if k.endswith('_links')] if link_keys: links = data.pop(link_keys[0], None) @@ -183,10 +179,6 @@ class XMLDictSerializer(DictSerializer): result.set( constants.TYPE_ATTR, constants.TYPE_INT) - elif isinstance(data, long): - result.set( - constants.TYPE_ATTR, - constants.TYPE_LONG) elif isinstance(data, float): result.set( constants.TYPE_ATTR, @@ -194,7 +186,7 @@ class XMLDictSerializer(DictSerializer): LOG.debug("Data %(data)s type is %(type)s", {'data': data, 'type': type(data)}) - result.text = six.text_type(data) + result.text = str(data) return result def _create_link_nodes(self, xml_doc, links): @@ -323,8 +315,6 @@ class XMLDeserializer(TextDeserializer): lambda x: x.lower() == 'true', constants.TYPE_INT: lambda x: int(x), - constants.TYPE_LONG: - lambda x: long(x), constants.TYPE_FLOAT: lambda x: float(x)} if attrType and attrType in converters: diff --git a/tackerclient/common/utils.py b/tackerclient/common/utils.py index e4cd8e27..c605cffe 100644 --- a/tackerclient/common/utils.py +++ b/tackerclient/common/utils.py @@ -24,7 +24,6 @@ import os from oslo_log import versionutils from oslo_utils import encodeutils from oslo_utils import importutils -import six from tackerclient.common import exceptions from tackerclient.i18n import _ @@ -141,7 +140,7 @@ def http_log_resp(_logger, resp, body): def _safe_encode_without_obj(data): - if isinstance(data, six.string_types): + if isinstance(data, str): return encodeutils.safe_encode(data) return data diff --git a/tackerclient/shell.py b/tackerclient/shell.py index 15560e4b..97e117e1 100644 --- a/tackerclient/shell.py +++ b/tackerclient/shell.py @@ -25,6 +25,10 @@ import itertools import logging import os import sys +from urllib import parse as urlparse + +from cliff import app +from cliff import commandmanager from keystoneclient.auth.identity import v2 as v2_auth from keystoneclient.auth.identity import v3 as v3_auth @@ -33,11 +37,6 @@ from keystoneclient import exceptions as ks_exc from keystoneclient import session from oslo_utils import encodeutils -from urllib import parse as urlparse - -from cliff import app -from cliff import commandmanager - from tackerclient.common import clientmanager from tackerclient.common import command as openstack_command from tackerclient.common import exceptions as exc diff --git a/tackerclient/tacker/v1_0/__init__.py b/tackerclient/tacker/v1_0/__init__.py index ea39d136..acf32a56 100644 --- a/tackerclient/tacker/v1_0/__init__.py +++ b/tackerclient/tacker/v1_0/__init__.py @@ -23,7 +23,6 @@ from cliff.formatters import table from cliff import lister from cliff import show from oslo_serialization import jsonutils -import six from tackerclient.common._i18n import _ from tackerclient.common import command @@ -354,8 +353,7 @@ class TackerCommandMeta(abc.ABCMeta): name, bases, cls_dict) -@six.add_metaclass(TackerCommandMeta) -class TackerCommand(command.OpenStackCommand): +class TackerCommand(command.OpenStackCommand, metaclass=TackerCommandMeta): api = 'nfv-orchestration' values_specs = [] diff --git a/tackerclient/tacker/v1_0/nfvo/vim_utils.py b/tackerclient/tacker/v1_0/nfvo/vim_utils.py index bdb0257f..e5511910 100644 --- a/tackerclient/tacker/v1_0/nfvo/vim_utils.py +++ b/tackerclient/tacker/v1_0/nfvo/vim_utils.py @@ -13,6 +13,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 as urlparse from tackerclient.common import exceptions diff --git a/tackerclient/tests/unit/osc/v1/test_vnflcm.py b/tackerclient/tests/unit/osc/v1/test_vnflcm.py index 5206dcab..48d8bfbb 100644 --- a/tackerclient/tests/unit/osc/v1/test_vnflcm.py +++ b/tackerclient/tests/unit/osc/v1/test_vnflcm.py @@ -20,7 +20,6 @@ from unittest import mock import ddt from oslo_utils.fixture import uuidsentinel -import six from tackerclient.common import exceptions from tackerclient.osc import utils as tacker_osc_utils @@ -448,7 +447,7 @@ class TestTerminateVnfLcm(TestVnfLcm): "delete vnf instance %(id)s" % {'timeout': 15, 'id': vnf_instance['id']}) - self.assertIn(expected_message, six.text_type(result)) + self.assertIn(expected_message, str(result)) self.assertNotCalled(mock_delete) def test_terminate_no_options(self): diff --git a/tackerclient/tests/unit/test_cli10.py b/tackerclient/tests/unit/test_cli10.py index d07b09d1..ee4c7f43 100644 --- a/tackerclient/tests/unit/test_cli10.py +++ b/tackerclient/tests/unit/test_cli10.py @@ -14,15 +14,13 @@ # under the License. # -from unittest import mock -import urllib - import contextlib import fixtures -import six +import io import sys import testtools - +from unittest import mock +import urllib from urllib import parse as urlparse from tackerclient.common import constants @@ -41,7 +39,7 @@ ENDURL = 'localurl' @contextlib.contextmanager def capture_std_streams(): - fake_stdout, fake_stderr = six.StringIO(), six.StringIO() + fake_stdout, fake_stderr = io.StringIO(), io.StringIO() stdout, stderr = sys.stdout, sys.stderr try: sys.stdout, sys.stderr = fake_stdout, fake_stderr @@ -318,7 +316,7 @@ class CLITestV10Base(testtools.TestCase): args.append("--tag") for tag in tags: args.append(tag) - if isinstance(tag, six.string_types): + if isinstance(tag, str): tag = urllib.quote(tag.encode('utf-8')) if query: query += "&tag=" + tag @@ -415,7 +413,7 @@ class CLITestV10Base(testtools.TestCase): args.append("--tag") for tag in tags: args.append(tag) - if isinstance(tag, six.string_types): + if isinstance(tag, str): tag = urllib.quote(tag.encode('utf-8')) if query: query += "&tag=" + tag diff --git a/tackerclient/tests/unit/test_shell.py b/tackerclient/tests/unit/test_shell.py index f7dec351..dcaa4620 100644 --- a/tackerclient/tests/unit/test_shell.py +++ b/tackerclient/tests/unit/test_shell.py @@ -14,18 +14,17 @@ # under the License. import argparse +import fixtures +import io import logging import os import re -from unittest import mock - -import six import sys - -import fixtures -from keystoneclient import session import testtools from testtools import matchers +from unittest import mock + +from keystoneclient import session from tackerclient.common import clientmanager from tackerclient import shell as openstack_shell @@ -63,8 +62,8 @@ class ShellTest(testtools.TestCase): clean_env = {} _old_env, os.environ = os.environ, clean_env.copy() try: - sys.stdout = six.StringIO() - sys.stderr = six.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() _shell = openstack_shell.TackerShell(DEFAULT_API_VERSION) _shell.run(argstr.split()) except SystemExit: diff --git a/tackerclient/v1_0/client.py b/tackerclient/v1_0/client.py index 3de95e36..19199a6b 100644 --- a/tackerclient/v1_0/client.py +++ b/tackerclient/v1_0/client.py @@ -19,7 +19,6 @@ import logging import time import requests - from urllib import parse as urlparse from tackerclient import client