From 5774a62cb43c0057e49311581795bded8dc3b751 Mon Sep 17 00:00:00 2001 From: Hugo Brito Date: Thu, 20 Jun 2024 14:00:15 -0300 Subject: [PATCH] Remove the six library This commit removes the six library from the repo, as the only supported Python version is 3.9. Test Plan: PASS: Success on tox command. Story: 2011149 Task: 50395 Change-Id: I44942ba91791c3ea541c7642107b48e8b2b2d457 Signed-off-by: Hugo Brito --- .git-blame-ignore-revs | 22 +++++++++++++++++++ distributedcloud-client/.pylintrc | 4 ++-- .../dcmanagerclient/api/client.py | 4 +--- .../dcmanagerclient/api/v1/client.py | 3 +-- .../dcmanagerclient/commands/v1/base.py | 10 +++------ .../commands/v1/subcloud_manager.py | 3 +-- .../dcmanagerclient/tests/base_shell_test.py | 6 ++--- .../tests/v1/test_subcloud_manager.py | 6 ++--- distributedcloud-client/requirements.txt | 1 - 9 files changed, 36 insertions(+), 23 deletions(-) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..c05a56a6 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,22 @@ +# git hyper-blame master ignore list. +# +# This file contains a list of git hashes of revisions to be ignored by git +# hyper-blame. These revisions are considered "unimportant" in that they are +# unlikely to be what you are interested in when blaming. +# +# Instructions: +# - Only large (generally automated) reformatting or renaming commits should be +# added to this list. Do not put things here just because you feel they are +# trivial or unimportant. If in doubt, do not put it on this list. +# - Precede each revision with a comment containing the first line of its log. +# For bulk work over many commits, place all commits in a block with a single +# comment at the top describing the work done in those commits. +# - Only put full 40-character hashes on this list (not short hashes or any +# other revision reference). +# - Append to the bottom of the file (revisions should be in chronological order +# from oldest to newest). +# - Because you must use a hash, you need to append to this list in a follow-up +# commit to the actual reformatting commit that you are trying to ignore. + +# Format all Python files with Black formatter +b5cbd9480cef12fee05ae6cf68aaae5aaa931969 diff --git a/distributedcloud-client/.pylintrc b/distributedcloud-client/.pylintrc index b96bd368..c8cff074 100644 --- a/distributedcloud-client/.pylintrc +++ b/distributedcloud-client/.pylintrc @@ -92,7 +92,7 @@ ignore-mixin-members=yes # List of module names for which member attributes should not be checked # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis -ignored-modules=distutils,eventlet.green.subprocess,six,six.moves +ignored-modules=distutils,eventlet.green.subprocess # List of classes names for which member attributes should not be checked # (useful for classes with attributes dynamically set). @@ -224,4 +224,4 @@ valid-classmethod-first-arg=cls [EXCEPTIONS] # Exceptions that will emit a warning when being caught. Defaults to # "Exception" -overgeneral-exceptions=Exception +overgeneral-exceptions=builtins.Exception diff --git a/distributedcloud-client/dcmanagerclient/api/client.py b/distributedcloud-client/dcmanagerclient/api/client.py index 497c7c5d..eb4bc8ad 100644 --- a/distributedcloud-client/dcmanagerclient/api/client.py +++ b/distributedcloud-client/dcmanagerclient/api/client.py @@ -14,8 +14,6 @@ # limitations under the License. # -import six - from dcmanagerclient.api.v1 import client as client_v1 @@ -39,7 +37,7 @@ def client( session=None, **kwargs ): - if dcmanager_url and not isinstance(dcmanager_url, six.string_types): + if dcmanager_url and not isinstance(dcmanager_url, str): raise RuntimeError("DC Manager url should be a string.") return client_v1.Client( diff --git a/distributedcloud-client/dcmanagerclient/api/v1/client.py b/distributedcloud-client/dcmanagerclient/api/v1/client.py index 7e5e9752..eb17b78a 100644 --- a/distributedcloud-client/dcmanagerclient/api/v1/client.py +++ b/distributedcloud-client/dcmanagerclient/api/v1/client.py @@ -18,7 +18,6 @@ import keystoneauth1.identity.generic as auth_plugin import osprofiler.profiler -import six from keystoneauth1 import session as ks_session from dcmanagerclient.api import httpclient @@ -74,7 +73,7 @@ class Client: **kwargs, ): """DC Manager communicates with Keystone to fetch necessary values.""" - if dcmanager_url and not isinstance(dcmanager_url, six.string_types): + if dcmanager_url and not isinstance(dcmanager_url, str): raise RuntimeError("DC Manager url should be a string.") if auth_url or session: diff --git a/distributedcloud-client/dcmanagerclient/commands/v1/base.py b/distributedcloud-client/dcmanagerclient/commands/v1/base.py index 2029229c..c511a2a2 100644 --- a/distributedcloud-client/dcmanagerclient/commands/v1/base.py +++ b/distributedcloud-client/dcmanagerclient/commands/v1/base.py @@ -18,12 +18,10 @@ import abc -import six from osc_lib.command import command -@six.add_metaclass(abc.ABCMeta) -class DCManagerLister(command.Lister): +class DCManagerLister(command.Lister, metaclass=abc.ABCMeta): @abc.abstractmethod def _get_format_function(self): raise NotImplementedError @@ -52,8 +50,7 @@ class DCManagerLister(command.Lister): return f() -@six.add_metaclass(abc.ABCMeta) -class DCManagerShowOne(command.ShowOne): +class DCManagerShowOne(command.ShowOne, metaclass=abc.ABCMeta): @abc.abstractmethod def _get_format_function(self): raise NotImplementedError @@ -83,8 +80,7 @@ class DCManagerShowOne(command.ShowOne): return f() -@six.add_metaclass(abc.ABCMeta) -class DCManagerShow(DCManagerLister, DCManagerShowOne): +class DCManagerShow(DCManagerLister, DCManagerShowOne, metaclass=abc.ABCMeta): @abc.abstractmethod def should_list(self, parsed_args): """Uses Lister behaviour if True, ShowOne otherwise.""" diff --git a/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py b/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py index b643e243..65089c93 100644 --- a/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py +++ b/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py @@ -18,7 +18,6 @@ import base64 import os from osc_lib.command import command -import six from dcmanagerclient import exceptions from dcmanagerclient import utils @@ -907,7 +906,7 @@ class RedeploySubcloud(base.DCManagerShowOne): "WARNING: This will redeploy the subcloud. " "All applications and data on the subcloud will be lost." ) - confirm = six.moves.input('Please type "redeploy" to confirm: ').strip().lower() + confirm = input('Please type "redeploy" to confirm: ').strip().lower() if confirm == "redeploy": try: return subcloud_manager.redeploy_subcloud( diff --git a/distributedcloud-client/dcmanagerclient/tests/base_shell_test.py b/distributedcloud-client/dcmanagerclient/tests/base_shell_test.py index 08abbb37..b8424dba 100644 --- a/distributedcloud-client/dcmanagerclient/tests/base_shell_test.py +++ b/distributedcloud-client/dcmanagerclient/tests/base_shell_test.py @@ -15,10 +15,10 @@ # limitations under the License. # +import io import os import sys -import six import testtools from dcmanagerclient import shell @@ -31,8 +31,8 @@ class BaseShellTests(testtools.TestCase): _old_env, os.environ = os.environ, clean_env.copy() try: - sys.stdout = six.moves.cStringIO() - sys.stderr = six.moves.cStringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() _shell = shell.DCManagerShell() _shell.run(argstr.split()) except SystemExit: diff --git a/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_manager.py b/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_manager.py index 9961075c..52db7820 100644 --- a/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_manager.py +++ b/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_manager.py @@ -387,7 +387,7 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest): self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID, actual_call[1]) @mock.patch("getpass.getpass", return_value="testpassword") - @mock.patch("six.moves.input", return_value="redeploy") + @mock.patch.object(subcloud_cmd, "input", return_value="redeploy") def test_redeploy_subcloud(self, _mock_input, _mock_getpass): self.client.subcloud_manager.redeploy_subcloud.return_value = [ self.subcloud_resource @@ -421,7 +421,7 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest): self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID, actual_call[1]) @mock.patch("getpass.getpass", return_value="testpassword") - @mock.patch("six.moves.input", return_value="redeploy") + @mock.patch.object(subcloud_cmd, "input", return_value="redeploy") def test_redeploy_subcloud_no_parameters(self, _mock_input, _mock_getpass): self.client.subcloud_manager.redeploy_subcloud.return_value = [ self.subcloud_resource @@ -430,7 +430,7 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest): self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID, actual_call[1]) @mock.patch("getpass.getpass", return_value="testpassword") - @mock.patch("six.moves.input", return_value="redeploy") + @mock.patch.object(subcloud_cmd, "input", return_value="redeploy") def test_redeploy_bootstrap_files_does_not_exists(self, _mock_input, _mock_getpass): self.client.subcloud_manager.redeploy_subcloud.return_value = [ self.subcloud_resource diff --git a/distributedcloud-client/requirements.txt b/distributedcloud-client/requirements.txt index 04217e56..1010cbdd 100644 --- a/distributedcloud-client/requirements.txt +++ b/distributedcloud-client/requirements.txt @@ -11,4 +11,3 @@ python-keystoneclient>=3.8.0 # Apache-2.0 PyYAML>=3.10.0 # MIT requests!=2.12.2,!=2.13.0,>=2.10.0 # Apache-2.0 requests-toolbelt # Apache-2.0 -six>=1.9.0 # MIT