diff --git a/.pylintrc b/.pylintrc index 8ff5a9b7..22cb26c9 100644 --- a/.pylintrc +++ b/.pylintrc @@ -32,7 +32,6 @@ disable= global-statement, keyword-arg-before-vararg, literal-comparison, - non-parent-init-called, not-callable, protected-access, raise-missing-from, @@ -80,7 +79,6 @@ disable= # new for python3 version of pylint consider-using-set-comprehension, unnecessary-pass, - useless-object-inheritance [BASIC] # Variable names can be 1 to 31 characters long, with lowercase and underscores diff --git a/doc/source/conf.py b/doc/source/conf.py index 88dd0eb4..f36b3712 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -42,8 +41,8 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'tap-as-a-service' -copyright = u'2013, OpenStack Foundation' +project = 'tap-as-a-service' +copyright = '2013, OpenStack Foundation' # If true, '()' will be appended to :func: etc. cross-reference text. add_function_parentheses = True @@ -72,8 +71,8 @@ htmlhelp_basename = '%sdoc' % project latex_documents = [ ('index', 'doc-tap-as-a-service.tex', - u'Tap as a Service Documentation', - u'OpenStack Foundation', 'manual'), + 'Tap as a Service Documentation', + 'OpenStack Foundation', 'manual'), ] # Example configuration for intersphinx: refer to the Python standard library. diff --git a/neutron_taas/services/taas/agents/extensions/taas.py b/neutron_taas/services/taas/agents/extensions/taas.py index b2d6864c..eb0f05ce 100644 --- a/neutron_taas/services/taas/agents/extensions/taas.py +++ b/neutron_taas/services/taas/agents/extensions/taas.py @@ -34,7 +34,7 @@ OPTS = [ cfg.CONF.register_opts(OPTS) -class TaasAgentDriver(object, metaclass=abc.ABCMeta): +class TaasAgentDriver(metaclass=abc.ABCMeta): """Defines stable abstract interface for TaaS Agent Driver.""" @abc.abstractmethod diff --git a/neutron_taas/services/taas/agents/taas_agent_api.py b/neutron_taas/services/taas/agents/taas_agent_api.py index 19c29a18..c940be0c 100644 --- a/neutron_taas/services/taas/agents/taas_agent_api.py +++ b/neutron_taas/services/taas/agents/taas_agent_api.py @@ -17,7 +17,7 @@ from neutron_lib import rpc as n_rpc import oslo_messaging as messaging -class TaasPluginApiMixin(object): +class TaasPluginApiMixin: # Currently there are no Calls the Agent makes towards the Plugin. @@ -28,7 +28,7 @@ class TaasPluginApiMixin(object): super().__init__() -class TaasAgentRpcCallbackMixin(object): +class TaasAgentRpcCallbackMixin: """Mixin for Taas agent Implementations.""" def __init__(self): diff --git a/neutron_taas/services/taas/drivers/linux/ovs_taas.py b/neutron_taas/services/taas/drivers/linux/ovs_taas.py index 6e4b8ad1..38484d8d 100644 --- a/neutron_taas/services/taas/drivers/linux/ovs_taas.py +++ b/neutron_taas/services/taas/drivers/linux/ovs_taas.py @@ -401,7 +401,7 @@ class OvsTaasDriver(taas_base.TaasAgentDriver): ) else: - actions = "output:%s,mod_vlan_vid:%s,output:%s" % ( + actions = "output:{},mod_vlan_vid:{},output:{}".format( str(ovs_port_id), str(taas_id), str(patch_int_tap_id) ) if network_type == 'vlan': diff --git a/neutron_taas/services/taas/drivers/linux/ovs_utils.py b/neutron_taas/services/taas/drivers/linux/ovs_utils.py index 42a02ce8..fe3b1b52 100644 --- a/neutron_taas/services/taas/drivers/linux/ovs_utils.py +++ b/neutron_taas/services/taas/drivers/linux/ovs_utils.py @@ -22,7 +22,7 @@ # - A value may be affiliated with multiple keys. # - A value may be affiliated with a key multiple times. # -class key_value_mgr(object): +class key_value_mgr: # # Initializes internal state for specified # keys # diff --git a/neutron_taas/services/taas/drivers/linux/sriov_nic_utils.py b/neutron_taas/services/taas/drivers/linux/sriov_nic_utils.py index 88398f95..7c18385a 100644 --- a/neutron_taas/services/taas/drivers/linux/sriov_nic_utils.py +++ b/neutron_taas/services/taas/drivers/linux/sriov_nic_utils.py @@ -30,7 +30,7 @@ import re LOG = logging.getLogger(__name__) -class SriovNicUtils(object): +class SriovNicUtils: # # Initializes internal state for specified # keys # @@ -169,7 +169,7 @@ class SriovNicUtils(object): with open(addr_file, encoding="utf-8") as f: mac = next(f).strip() return mac - except (IOError, StopIteration) as e: + except (OSError, StopIteration) as e: LOG.warning("Could not find the expected sysfs file for " "determining the MAC address of the PCI device " "%(addr)s. May not be a NIC. Error: %(e)s", diff --git a/neutron_taas/services/taas/service_drivers/__init__.py b/neutron_taas/services/taas/service_drivers/__init__.py index 41d1f0cb..8a791932 100644 --- a/neutron_taas/services/taas/service_drivers/__init__.py +++ b/neutron_taas/services/taas/service_drivers/__init__.py @@ -15,7 +15,7 @@ import abc -class TaasBaseDriver(object, metaclass=abc.ABCMeta): +class TaasBaseDriver(metaclass=abc.ABCMeta): def __init__(self, service_plugin): self.service_plugin = service_plugin diff --git a/neutron_taas/services/taas/service_drivers/service_driver_context.py b/neutron_taas/services/taas/service_drivers/service_driver_context.py index 5b1831fc..846ad0c6 100644 --- a/neutron_taas/services/taas/service_drivers/service_driver_context.py +++ b/neutron_taas/services/taas/service_drivers/service_driver_context.py @@ -19,7 +19,7 @@ from oslo_log import log LOG = log.getLogger(__name__) -class ServiceDriverContext(object): +class ServiceDriverContext: """ServiceDriverContext context base class""" def __init__(self, service_plugin, plugin_context): self._plugin = service_plugin diff --git a/neutron_taas/services/taas/service_drivers/taas_agent_api.py b/neutron_taas/services/taas/service_drivers/taas_agent_api.py index c0e2dc1f..a4f02ba1 100644 --- a/neutron_taas/services/taas/service_drivers/taas_agent_api.py +++ b/neutron_taas/services/taas/service_drivers/taas_agent_api.py @@ -21,7 +21,7 @@ import oslo_messaging as messaging LOG = logging.getLogger(__name__) -class TaasAgentApi(object): +class TaasAgentApi: """RPC calls to agent APIs""" def __init__(self, topic, host): diff --git a/neutron_taas/services/taas/service_drivers/taas_rpc.py b/neutron_taas/services/taas/service_drivers/taas_rpc.py index 9a17393e..43e306b5 100644 --- a/neutron_taas/services/taas/service_drivers/taas_rpc.py +++ b/neutron_taas/services/taas/service_drivers/taas_rpc.py @@ -36,7 +36,7 @@ from oslo_utils import excutils LOG = logging.getLogger(__name__) -class TaasCallbacks(object): +class TaasCallbacks: def __init__(self, rpc_driver, plugin): super().__init__() diff --git a/neutron_taas/tests/unit/db/test_taas_db.py b/neutron_taas/tests/unit/db/test_taas_db.py index a7b658d2..5540ed77 100644 --- a/neutron_taas/tests/unit/db/test_taas_db.py +++ b/neutron_taas/tests/unit/db/test_taas_db.py @@ -33,7 +33,7 @@ class TaaSDbTestCase(testlib_api.SqlTestCase): """Unit test for TaaS DB support.""" def setUp(self): - super(TaaSDbTestCase, self).setUp() + super().setUp() self.ctx = context.get_admin_context() self.mixin = taas_db.Taas_db_Mixin() self.plugin = importutils.import_object(DB_PLUGIN_KLAAS) diff --git a/neutron_taas/tests/unit/extensions/test_taas.py b/neutron_taas/tests/unit/extensions/test_taas.py index c2fce24c..aa6c9b62 100644 --- a/neutron_taas/tests/unit/extensions/test_taas.py +++ b/neutron_taas/tests/unit/extensions/test_taas.py @@ -38,12 +38,12 @@ class TaasExtensionTestCase(test_extensions_base.ExtensionTestCase): def setUp(self): conf_common.register_core_common_config_opts() extensions.append_api_extensions_path(taas_extensions.__path__) - super(TaasExtensionTestCase, self).setUp() + super().setUp() plural_mappings = {'tap_service': 'tap_services', 'tap_flow': 'tap_flows'} self.setup_extension( - '%s.%s' % (taas_extensions.taas.TaasPluginBase.__module__, - taas_extensions.taas.TaasPluginBase.__name__), + '{}.{}'.format(taas_extensions.taas.TaasPluginBase.__module__, + taas_extensions.taas.TaasPluginBase.__name__), taas_api.ALIAS, taas_extensions.taas.Taas, 'taas', diff --git a/neutron_taas/tests/unit/extensions/test_vlan_filter.py b/neutron_taas/tests/unit/extensions/test_vlan_filter.py index 46e62827..c93682af 100644 --- a/neutron_taas/tests/unit/extensions/test_vlan_filter.py +++ b/neutron_taas/tests/unit/extensions/test_vlan_filter.py @@ -34,14 +34,13 @@ _get_path = test_api_v2._get_path class VlanFilterExtensionTestCase(test_taas_ext.TaasExtensionTestCase): def setUp(self): - super(VlanFilterExtensionTestCase, self).setUp() + super().setUp() attr_map = taas_api_def.RESOURCE_ATTRIBUTE_MAP attr_map['tap_flows'].update( vlan_filter_ext.RESOURCE_ATTRIBUTE_MAP['tap_flows']) def _get_expected_tap_flow(self, data): - ret = super(VlanFilterExtensionTestCase, - self)._get_expected_tap_flow(data) + ret = super()._get_expected_tap_flow(data) ret['tap_flow'].update( vlan_filter=data['tap_flow'].get('vlan_filter', None)) return ret diff --git a/neutron_taas/tests/unit/services/drivers/test_linux_sriov_nic_driver.py b/neutron_taas/tests/unit/services/drivers/test_linux_sriov_nic_driver.py index 6451e9fd..d58b5bbb 100644 --- a/neutron_taas/tests/unit/services/drivers/test_linux_sriov_nic_driver.py +++ b/neutron_taas/tests/unit/services/drivers/test_linux_sriov_nic_driver.py @@ -39,7 +39,7 @@ FAKE_TAP_FLOW = {'port': FAKE_TAP_SERVICE['port'], class TestSriovNicTaas(base.TaasTestCase): def setUp(self): - super(TestSriovNicTaas, self).setUp() + super().setUp() @mock.patch.object(sriov_nic_taas, 'sriov_utils') def test_create_tap_service(self, mock_sriov_utils): diff --git a/neutron_taas/tests/unit/services/drivers/test_linux_sriov_utils.py b/neutron_taas/tests/unit/services/drivers/test_linux_sriov_utils.py index 0a0de978..3d9d773d 100644 --- a/neutron_taas/tests/unit/services/drivers/test_linux_sriov_utils.py +++ b/neutron_taas/tests/unit/services/drivers/test_linux_sriov_utils.py @@ -36,7 +36,7 @@ FAKE_SRIOV_PORT = { class TestSriovNicUtils(base.TaasTestCase): def setUp(self): - super(TestSriovNicUtils, self).setUp() + super().setUp() def test_get_sysfs_netdev_path_with_pf_interface(self): self.assertEqual( diff --git a/neutron_taas/tests/unit/services/taas/test_taas_plugin.py b/neutron_taas/tests/unit/services/taas/test_taas_plugin.py index dcb77484..da97567c 100644 --- a/neutron_taas/tests/unit/services/taas/test_taas_plugin.py +++ b/neutron_taas/tests/unit/services/taas/test_taas_plugin.py @@ -40,7 +40,7 @@ class DummyError(Exception): class TestTaasPlugin(testlib_api.SqlTestCase): def setUp(self): - super(TestTaasPlugin, self).setUp() + super().setUp() mock.patch.object(n_rpc, 'Connection', spec=object).start() mock.patch.object(taas_agent_api, 'TaasAgentApi', spec=object).start() @@ -162,8 +162,8 @@ class TestTaasPlugin(testlib_api.SqlTestCase): self._context, ts_id_1) tap_id_assoc_2 = self._plugin.create_tap_id_association( self._context, ts_id_2) - self.assertEqual(set([1, 2]), set([tap_id_assoc_1['taas_id'], - tap_id_assoc_2['taas_id']])) + self.assertEqual({1, 2}, {tap_id_assoc_1['taas_id'], + tap_id_assoc_2['taas_id']}) with testtools.ExpectedException(taas_exc.TapServiceLimitReached): self._plugin.create_tap_id_association( self._context, @@ -177,8 +177,8 @@ class TestTaasPlugin(testlib_api.SqlTestCase): "dummyHost") tap_id_assoc_3 = self._plugin.create_tap_id_association( self._context, ts_id_3) - self.assertEqual(set([1, 2]), set([tap_id_assoc_3['taas_id'], - tap_id_assoc_2['taas_id']])) + self.assertEqual({1, 2}, {tap_id_assoc_3['taas_id'], + tap_id_assoc_2['taas_id']}) def test_create_tap_service_wrong_tenant_id(self): self._port_details['tenant_id'] = 'other-tenant' diff --git a/neutron_taas/tests/unit/taas_client/osc/fakes.py b/neutron_taas/tests/unit/taas_client/osc/fakes.py index d1ac927e..ab64b056 100644 --- a/neutron_taas/tests/unit/taas_client/osc/fakes.py +++ b/neutron_taas/tests/unit/taas_client/osc/fakes.py @@ -17,7 +17,7 @@ import copy from oslo_utils import uuidutils -class FakeTapService(object): +class FakeTapService: @staticmethod def create_tap_service(attrs=None): @@ -48,7 +48,7 @@ class FakeTapService(object): return tap_services -class FakeTapFlow(object): +class FakeTapFlow: @staticmethod def create_tap_flow(attrs=None): diff --git a/neutron_taas/tests/unit/taas_client/osc/test_osc_tap_flow.py b/neutron_taas/tests/unit/taas_client/osc/test_osc_tap_flow.py index 9ec6a4b3..fc6292d0 100644 --- a/neutron_taas/tests/unit/taas_client/osc/test_osc_tap_flow.py +++ b/neutron_taas/tests/unit/taas_client/osc/test_osc_tap_flow.py @@ -54,7 +54,7 @@ class TestCreateTapFlow(test_fakes.TestNeutronClientOSCV2): ) def setUp(self): - super(TestCreateTapFlow, self).setUp() + super().setUp() self.cmd = osc_tap_flow.CreateTapFlow(self.app, self.namespace) def test_create_tap_flow(self): @@ -117,7 +117,7 @@ class TestCreateTapFlow(test_fakes.TestNeutronClientOSCV2): class TestListTapFlow(test_fakes.TestNeutronClientOSCV2): def setUp(self): - super(TestListTapFlow, self).setUp() + super().setUp() self.cmd = osc_tap_flow.ListTapFlow(self.app, self.namespace) def test_list_tap_flows(self): @@ -149,7 +149,7 @@ class TestListTapFlow(test_fakes.TestNeutronClientOSCV2): class TestDeleteTapFlow(test_fakes.TestNeutronClientOSCV2): def setUp(self): - super(TestDeleteTapFlow, self).setUp() + super().setUp() self.app.client_manager.network = mock.Mock() self.app.client_manager.network.find_tap_flow = mock.Mock( side_effect=lambda name_or_id, ignore_missing: @@ -194,7 +194,7 @@ class TestShowTapFlow(test_fakes.TestNeutronClientOSCV2): ) def setUp(self): - super(TestShowTapFlow, self).setUp() + super().setUp() self.app.client_manager.network = mock.Mock() self.app.client_manager.network.find_tap_flow = mock.Mock( side_effect=lambda name_or_id, ignore_missing: @@ -246,7 +246,7 @@ class TestUpdateTapFlow(test_fakes.TestNeutronClientOSCV2): ) def setUp(self): - super(TestUpdateTapFlow, self).setUp() + super().setUp() self.cmd = osc_tap_flow.UpdateTapFlow(self.app, self.namespace) self.app.client_manager.network = mock.Mock() self.app.client_manager.network.find_tap_flow = mock.Mock( diff --git a/neutron_taas/tests/unit/taas_client/osc/test_osc_tap_service.py b/neutron_taas/tests/unit/taas_client/osc/test_osc_tap_service.py index 2bac89c4..ddcf856a 100644 --- a/neutron_taas/tests/unit/taas_client/osc/test_osc_tap_service.py +++ b/neutron_taas/tests/unit/taas_client/osc/test_osc_tap_service.py @@ -51,7 +51,7 @@ class TestCreateTapService(test_fakes.TestNeutronClientOSCV2): ) def setUp(self): - super(TestCreateTapService, self).setUp() + super().setUp() self.cmd = osc_tap_service.CreateTapService(self.app, self.namespace) def test_create_tap_service(self): @@ -95,7 +95,7 @@ class TestCreateTapService(test_fakes.TestNeutronClientOSCV2): class TestListTapService(test_fakes.TestNeutronClientOSCV2): def setUp(self): - super(TestListTapService, self).setUp() + super().setUp() self.cmd = osc_tap_service.ListTapService(self.app, self.namespace) def test_list_tap_service(self): @@ -125,7 +125,7 @@ class TestListTapService(test_fakes.TestNeutronClientOSCV2): class TestDeleteTapService(test_fakes.TestNeutronClientOSCV2): def setUp(self): - super(TestDeleteTapService, self).setUp() + super().setUp() self.app.client_manager.network = mock.Mock() self.app.client_manager.network.find_tap_service = mock.Mock( side_effect=lambda name_or_id, ignore_missing: @@ -164,7 +164,7 @@ class TestShowTapService(test_fakes.TestNeutronClientOSCV2): ) def setUp(self): - super(TestShowTapService, self).setUp() + super().setUp() self.app.client_manager.network = mock.Mock() self.app.client_manager.network.find_tap_service = mock.Mock( side_effect=lambda name_or_id, ignore_missing: @@ -212,7 +212,7 @@ class TestUpdateTapService(test_fakes.TestNeutronClientOSCV2): ) def setUp(self): - super(TestUpdateTapService, self).setUp() + super().setUp() self.cmd = osc_tap_service.UpdateTapService(self.app, self.namespace) self.app.client_manager.network = mock.Mock() self.app.client_manager.network.find_tap_service = mock.Mock( diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index 31101b81..bef1d097 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -59,9 +59,9 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'tap-as-a-service' -copyright = u'2017, Tap-as-a-service developers' -author = u'Tap-as-a-service developers' +project = 'tap-as-a-service' +copyright = '2017, Tap-as-a-service developers' +author = 'Tap-as-a-service developers' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -247,8 +247,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'tap-as-a-service.tex', u'tap-as-a-service Documentation', - u'OpenStack', 'manual'), + (master_doc, 'tap-as-a-service.tex', 'tap-as-a-service Documentation', + 'OpenStack', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -277,7 +277,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'tap-as-a-service', u'tap-as-a-service Documentation', + (master_doc, 'tap-as-a-service', 'tap-as-a-service Documentation', [author], 1) ] @@ -291,7 +291,7 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'tap-as-a-service', u'tap-as-a-service Documentation', + (master_doc, 'tap-as-a-service', 'tap-as-a-service Documentation', author, 'tap-as-a-service', 'One line description of project.', 'Miscellaneous'), ]