pyupgrade changes for Python3.9+
As discussed at the Epoxy PTG meeting, run an automated upgrade tool to make code python 3.9+ compliant. Result of running: $ pyupgrade --py39-plus $(git ls-files | grep ".py$") Fixed PEP8 errors introduced by pyupgrade by running: $ autopep8 --select=E127,E128,E501 --max-line-length 79 -r \ --in-place neutron_taas Also did manual updates as necessary to fix other errors and warnings after above commands. Inspired by Octavia and Nova [0]. [0] https://review.opendev.org/c/openstack/nova/+/896986 Change-Id: I14155656d7e233cdd0f8a30c34158465e8de325a
This commit is contained in:
parent
98a6569530
commit
b8c65a9ec2
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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':
|
||||
|
@ -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
|
||||
#
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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__()
|
||||
|
@ -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)
|
||||
|
@ -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',
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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(
|
||||
|
@ -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'
|
||||
|
@ -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):
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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'),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user