diff --git a/lower-constraints.txt b/lower-constraints.txt index a981b3e3..b76aaa9b 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -75,7 +75,6 @@ requests==2.14.2 requestsexceptions==1.2.0 rfc3986==1.1.0 Routes==2.4.1 -six==1.10.0 snowballstemmer==1.2.1 Sphinx==1.6.2 sphinxcontrib-websupport==1.0.1 diff --git a/os_vif/internal/ip/ip_command.py b/os_vif/internal/ip/ip_command.py index d7a1dbfe..e67f8c65 100644 --- a/os_vif/internal/ip/ip_command.py +++ b/os_vif/internal/ip/ip_command.py @@ -11,11 +11,9 @@ # under the License. import abc -import six -@six.add_metaclass(abc.ABCMeta) -class IpCommand(object): +class IpCommand(metaclass=abc.ABCMeta): TYPE_VETH = 'veth' TYPE_VLAN = 'vlan' diff --git a/os_vif/plugin.py b/os_vif/plugin.py index 8f89493c..9c7b902e 100644 --- a/os_vif/plugin.py +++ b/os_vif/plugin.py @@ -12,14 +12,12 @@ import abc from oslo_config import cfg -import six CONF = cfg.CONF -@six.add_metaclass(abc.ABCMeta) -class PluginBase(object): +class PluginBase(metaclass=abc.ABCMeta): """Base class for all VIF plugins.""" # Override to provide a tuple of oslo_config.Opt instances for diff --git a/os_vif/tests/functional/base.py b/os_vif/tests/functional/base.py index 8ce11289..db71bbe9 100644 --- a/os_vif/tests/functional/base.py +++ b/os_vif/tests/functional/base.py @@ -17,7 +17,6 @@ import abc import functools import inspect import os -import six import sys import eventlet.timeout @@ -99,8 +98,8 @@ def sanitize_log_path(path): # kills the whole worker, with all test cases scheduled to it. This metaclass # makes all test cases convert Timeout exceptions into unittest friendly # failure mode (self.fail). -@six.add_metaclass(_CatchTimeoutMetaclass) -class BaseFunctionalTestCase(base.BaseTestCase): +class BaseFunctionalTestCase(base.BaseTestCase, + metaclass=_CatchTimeoutMetaclass): """Base class for functional tests.""" COMPONENT_NAME = 'os_vif' diff --git a/os_vif/tests/unit/internal/ip/test_api.py b/os_vif/tests/unit/internal/ip/test_api.py index 801dd3a4..30bad184 100644 --- a/os_vif/tests/unit/internal/ip/test_api.py +++ b/os_vif/tests/unit/internal/ip/test_api.py @@ -10,8 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +import importlib + import mock -from six import moves from os_vif.internal.ip import api from os_vif.tests.unit import base @@ -21,18 +22,18 @@ class TestIpApi(base.TestCase): @staticmethod def _reload_original_os_module(): - moves.reload_module(api) + importlib.reload(api) def test_get_impl_windows(self): self.addCleanup(self._reload_original_os_module) with mock.patch('os.name', 'nt'): - moves.reload_module(api) + importlib.reload(api) from os_vif.internal.ip.windows import impl_netifaces self.assertIsInstance(api.ip, impl_netifaces.Netifaces) def test_get_impl_linux(self): self.addCleanup(self._reload_original_os_module) with mock.patch('os.name', 'posix'): - moves.reload_module(api) + importlib.reload(api) from os_vif.internal.ip.linux import impl_pyroute2 self.assertIsInstance(api.ip, impl_pyroute2.PyRoute2) diff --git a/os_vif/tests/unit/test_base.py b/os_vif/tests/unit/test_base.py index 0d16be51..95be63c0 100644 --- a/os_vif/tests/unit/test_base.py +++ b/os_vif/tests/unit/test_base.py @@ -12,7 +12,6 @@ import copy import mock -import six from oslo_serialization import jsonutils from oslo_versionedobjects import base @@ -51,7 +50,7 @@ class TestVersionedObjectPrintable(test_base.TestCase): out = str(self.obj) self.assertIn("'child1_field1': [1, 2, 3]}", out) self.assertIn("'child1_field1': [4, 5, 6]}", out) - cmp = str({'parent_field2': six.text_type("test string")}) + cmp = str({'parent_field2': "test string"}) cmp = cmp.replace('{', '').replace('}', '') self.assertIn(str(cmp), out) diff --git a/os_vif/tests/unit/test_exception.py b/os_vif/tests/unit/test_exception.py index 5385613e..ba2bb0d9 100644 --- a/os_vif/tests/unit/test_exception.py +++ b/os_vif/tests/unit/test_exception.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import six - from os_vif import exception from os_vif.tests.unit import base @@ -24,10 +22,10 @@ class VIFExceptionTestCase(base.TestCase): msg_fmt = "default message" exc = FakeVIFException() - self.assertEqual(six.text_type(exc), 'default message') + self.assertEqual(str(exc), 'default message') def test_error_msg(self): - self.assertEqual(six.text_type(exception.ExceptionBase('test')), + self.assertEqual(str(exception.ExceptionBase('test')), 'test') def test_default_error_msg_with_kwargs(self): @@ -35,4 +33,4 @@ class VIFExceptionTestCase(base.TestCase): msg_fmt = "default message: %(foo)s" exc = FakeVIFException(foo="bar") - self.assertEqual(six.text_type(exc), 'default message: bar') + self.assertEqual(str(exc), 'default message: bar') diff --git a/requirements.txt b/requirements.txt index a0ff0ffb..43371851 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,6 +12,5 @@ oslo.privsep>=1.23.0 # Apache-2.0 oslo.versionedobjects>=1.28.0 # Apache-2.0 ovsdbapp>=0.12.1 # Apache-2.0 pyroute2>=0.5.2;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2) -six>=1.10.0 # MIT stevedore>=1.20.0 # Apache-2.0 debtcollector>=1.19.0 # Apache-2.0 diff --git a/vif_plug_linux_bridge/iptables.py b/vif_plug_linux_bridge/iptables.py index c6f5c1c0..ba73c0ff 100644 --- a/vif_plug_linux_bridge/iptables.py +++ b/vif_plug_linux_bridge/iptables.py @@ -28,8 +28,6 @@ from oslo_concurrency import lockutils from oslo_concurrency import processutils from vif_plug_linux_bridge import privsep -import six - # NOTE(vish): Iptables supports chain names of up to 28 characters, and we # add up to 12 characters to binary_name which is used as a prefix, @@ -219,7 +217,7 @@ class IptablesTable(object): def remove_rules_regex(self, regex): """Remove all rules matching regex.""" - if isinstance(regex, six.string_types): + if isinstance(regex, str): regex = re.compile(regex) num_rules = len(self.rules) self.rules = [r for r in self.rules if not regex.match(str(r))] @@ -302,7 +300,7 @@ class IptablesManager(object): elif ip_version == 6: tables = self.ipv6 - for table, chains in six.iteritems(builtin_chains[ip_version]): + for table, chains in builtin_chains[ip_version].items(): for chain in chains: tables[table].add_chain(chain) tables[table].add_rule(chain, '-j $%s' % (chain,), @@ -334,11 +332,11 @@ class IptablesManager(object): self.apply() def dirty(self): - for table in six.itervalues(self.ipv4): + for table in self.ipv4.values(): if table.dirty: return True if self.use_ipv6: - for table in six.itervalues(self.ipv6): + for table in self.ipv6.values(): if table.dirty: return True return False @@ -365,7 +363,7 @@ class IptablesManager(object): for save, restore, tables in s: all_tables, _err = save() all_lines = all_tables.split('\n') - for table_name, table in six.iteritems(tables): + for table_name, table in tables.items(): start, end = self._find_table(all_lines, table_name) all_lines[start:end] = self._modify_rules( all_lines[start:end], table, table_name) diff --git a/vif_plug_linux_bridge/tests/unit/test_linux_net.py b/vif_plug_linux_bridge/tests/unit/test_linux_net.py index 648ae9b9..c57f8187 100644 --- a/vif_plug_linux_bridge/tests/unit/test_linux_net.py +++ b/vif_plug_linux_bridge/tests/unit/test_linux_net.py @@ -135,7 +135,7 @@ class LinuxNetTest(testtools.TestCase): check_exit_code=[0, 2, 254])] mock_ip_set.assert_has_calls(calls) - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch("os.path.exists") def test__disable_ipv6(self, mock_exists, mock_open): diff --git a/vif_plug_ovs/ovsdb/api.py b/vif_plug_ovs/ovsdb/api.py index 6e30191b..c18cba67 100644 --- a/vif_plug_ovs/ovsdb/api.py +++ b/vif_plug_ovs/ovsdb/api.py @@ -13,7 +13,6 @@ import abc from oslo_utils import importutils -import six interface_map = { @@ -29,8 +28,7 @@ def get_instance(context, iface_name=None): return iface.api_factory(context) -@six.add_metaclass(abc.ABCMeta) -class ImplAPI(object): +class ImplAPI(metaclass=abc.ABCMeta): @abc.abstractmethod def has_table_column(self, table, column): """Check if a column exists in a database table diff --git a/vif_plug_ovs/ovsdb/impl_vsctl.py b/vif_plug_ovs/ovsdb/impl_vsctl.py index 9df1650f..aa6e543b 100644 --- a/vif_plug_ovs/ovsdb/impl_vsctl.py +++ b/vif_plug_ovs/ovsdb/impl_vsctl.py @@ -22,7 +22,6 @@ from oslo_serialization import jsonutils from oslo_utils import excutils from oslo_utils import uuidutils from ovsdbapp import api as ovsdb_api -import six from vif_plug_ovs.ovsdb import api from vif_plug_ovs import privsep @@ -379,7 +378,7 @@ def _set_colval_args(*col_values): args += ["%s:%s%s%s" % ( col, k, op, _py_to_val(v)) for k, v in val.items()] elif (isinstance(val, collections.Sequence) and - not isinstance(val, six.string_types)): + not isinstance(val, str)): if len(val) == 0: args.append("%s%s%s" % (col, op, "[]")) else: diff --git a/vif_plug_ovs/tests/unit/test_linux_net.py b/vif_plug_ovs/tests/unit/test_linux_net.py index 4eaa1f73..f96eba55 100644 --- a/vif_plug_ovs/tests/unit/test_linux_net.py +++ b/vif_plug_ovs/tests/unit/test_linux_net.py @@ -16,7 +16,6 @@ import os.path import testtools from os_vif.internal.ip.api import ip as ip_lib -from six.moves import builtins from vif_plug_ovs import exception from vif_plug_ovs import linux_net @@ -62,7 +61,7 @@ class LinuxNetTest(testtools.TestCase): mock_set_state.assert_called_once_with("br0", "up") mock_arp_filtering.assert_called_once_with("br0") - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch("os.path.exists") def test__disable_ipv6(self, mock_exists, mock_open): @@ -80,7 +79,7 @@ class LinuxNetTest(testtools.TestCase): mock_open.assert_called_once_with(exists_path, 'w') @mock.patch.object(os.path, 'exists', return_value=True) - @mock.patch.object(builtins, 'open') + @mock.patch('builtins.open') def test__arp_filtering(self, mock_open, *args): mock_open.side_effect = mock.mock_open() linux_net._arp_filtering("br0") @@ -132,7 +131,7 @@ class LinuxNetTest(testtools.TestCase): linux_net.add_bridge_port("br0", "vnet1") mock_set.assert_called_once_with("vnet1", master="br0") - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch.object(os.path, 'isfile') def test_is_switchdev_ioerror(self, mock_isfile, mock_open): mock_isfile.side_effect = [True] @@ -143,7 +142,7 @@ class LinuxNetTest(testtools.TestCase): test_switchdev = linux_net._is_switchdev('pf_ifname') self.assertEqual(test_switchdev, False) - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch.object(os.path, 'isfile') def test_is_switchdev_empty(self, mock_isfile, mock_open): mock_isfile.side_effect = [True] @@ -159,7 +158,7 @@ class LinuxNetTest(testtools.TestCase): mock_open.assert_has_calls(open_calls) self.assertEqual(test_switchdev, False) - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch.object(os.path, 'isfile') def test_is_switchdev_positive(self, mock_isfile, mock_open): mock_isfile.side_effect = [True] @@ -191,7 +190,7 @@ class LinuxNetTest(testtools.TestCase): self.assertEqual(linux_net._parse_pf_number("pf31"), "31") self.assertIsNone(linux_net._parse_pf_number("g4rbl3d")) - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch.object(os.path, 'isfile') @mock.patch.object(os, 'listdir') @mock.patch.object(linux_net, "get_function_by_ifname") @@ -232,7 +231,7 @@ class LinuxNetTest(testtools.TestCase): mock_open.assert_has_calls(open_calls) self.assertEqual('rep_vf_2', ifname) - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch.object(os.path, 'isfile') @mock.patch.object(os, 'listdir') @mock.patch.object(linux_net, "get_function_by_ifname") @@ -263,7 +262,7 @@ class LinuxNetTest(testtools.TestCase): ifname = linux_net.get_representor_port('pf_ifname2', '2') self.assertEqual('rep_pf2_vf_2', ifname) - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch.object(os.path, 'isfile') @mock.patch.object(os, 'listdir') @mock.patch.object(linux_net, "get_function_by_ifname") @@ -290,7 +289,7 @@ class LinuxNetTest(testtools.TestCase): linux_net.get_representor_port, 'pf_ifname', '3'), - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch.object(os.path, 'isfile') @mock.patch.object(os, 'listdir') @mock.patch.object(linux_net, "get_function_by_ifname") @@ -317,7 +316,7 @@ class LinuxNetTest(testtools.TestCase): linux_net.get_representor_port, 'pf_ifname', '3') - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch.object(os.path, 'isfile') @mock.patch.object(os, 'listdir') @mock.patch.object(linux_net, "get_function_by_ifname") @@ -344,7 +343,7 @@ class LinuxNetTest(testtools.TestCase): linux_net.get_representor_port, 'pf_ifname', '3') - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch.object(os.path, 'isfile') @mock.patch.object(os, 'listdir') def test_physical_function_inferface_name( @@ -359,7 +358,7 @@ class LinuxNetTest(testtools.TestCase): '0000:00:00.1', pf_interface=True, switchdev=False) self.assertEqual(ifname, 'foo') - @mock.patch('six.moves.builtins.open') + @mock.patch('builtins.open') @mock.patch.object(os.path, 'isfile') @mock.patch.object(os, 'listdir') def test_physical_function_inferface_name_with_switchdev(