diff --git a/.pylintrc b/.pylintrc index 762406c3..0a43119a 100644 --- a/.pylintrc +++ b/.pylintrc @@ -22,40 +22,31 @@ disable= abstract-method, arguments-differ, attribute-defined-outside-init, - bad-builtin, bad-indentation, broad-except, dangerous-default-value, - deprecated-lambda, expression-not-assigned, fixme, global-statement, - no-init, non-parent-init-called, not-callable, protected-access, redefined-builtin, redefined-outer-name, - star-args, super-init-not-called, - super-on-old-class, unpacking-non-sequence, unused-argument, # "C" Coding convention violations - bad-continuation, + consider-using-f-string, invalid-name, len-as-condition, missing-docstring, multiple-statements, superfluous-parens, # "R" Refactor recommendations - abstract-class-little-used, - abstract-class-not-used, duplicate-code, inconsistent-return-statements, - interface-not-implemented, no-else-return, - no-self-use, too-few-public-methods, too-many-ancestors, too-many-arguments, @@ -95,11 +86,6 @@ max-line-length=79 # _ is used by our localization additional-builtins=_ -[CLASSES] -# List of interface methods to ignore, separated by a comma. -ignore-iface-methods= - - [IMPORTS] # Deprecated modules which should not be used, separated by a comma deprecated-modules= diff --git a/networking_bgpvpn/neutron/db/bgpvpn_db.py b/networking_bgpvpn/neutron/db/bgpvpn_db.py index fafdcb13..16039a24 100644 --- a/networking_bgpvpn/neutron/db/bgpvpn_db.py +++ b/networking_bgpvpn/neutron/db/bgpvpn_db.py @@ -331,8 +331,8 @@ class BGPVPNPluginDb(): def _get_bgpvpn(self, context, id): try: return model_query.get_by_id(context, BGPVPN, id) - except exc.NoResultFound: - raise bgpvpn_ext.BGPVPNNotFound(id=id) + except exc.NoResultFound as no_res: + raise bgpvpn_ext.BGPVPNNotFound(id=id) from no_res @db_api.CONTEXT_READER def get_bgpvpn(self, context, id, fields=None): @@ -381,9 +381,10 @@ class BGPVPNPluginDb(): return query.filter(BGPVPNNetAssociation.id == assoc_id, BGPVPNNetAssociation.bgpvpn_id == bgpvpn_id ).one() - except exc.NoResultFound: - raise bgpvpn_ext.BGPVPNNetAssocNotFound(id=assoc_id, - bgpvpn_id=bgpvpn_id) + except exc.NoResultFound as no_res: + raise bgpvpn_ext.BGPVPNNetAssocNotFound( + id=assoc_id, + bgpvpn_id=bgpvpn_id) from no_res def create_net_assoc(self, context, bgpvpn_id, net_assoc): try: @@ -394,13 +395,14 @@ class BGPVPNPluginDb(): network_id=net_assoc['network_id']) context.session.add(net_assoc_db) return self._make_net_assoc_dict(net_assoc_db) - except db_exc.DBDuplicateEntry: + except db_exc.DBDuplicateEntry as db_dup_exc: LOG.warning("network %(net_id)s is already associated to " "BGPVPN %(bgpvpn_id)s", {'net_id': net_assoc['network_id'], 'bgpvpn_id': bgpvpn_id}) raise bgpvpn_ext.BGPVPNNetAssocAlreadyExists( - bgpvpn_id=bgpvpn_id, net_id=net_assoc['network_id']) + bgpvpn_id=bgpvpn_id, + net_id=net_assoc['network_id']) from db_dup_exc @db_api.CONTEXT_READER def get_net_assoc(self, context, assoc_id, bgpvpn_id, fields=None): @@ -445,9 +447,10 @@ class BGPVPNPluginDb(): return query.filter(BGPVPNRouterAssociation.id == assoc_id, BGPVPNRouterAssociation.bgpvpn_id == bgpvpn_id ).one() - except exc.NoResultFound: - raise bgpvpn_ext.BGPVPNRouterAssocNotFound(id=assoc_id, - bgpvpn_id=bgpvpn_id) + except exc.NoResultFound as no_res_exc: + raise bgpvpn_ext.BGPVPNRouterAssocNotFound( + id=assoc_id, + bgpvpn_id=bgpvpn_id) from no_res_exc @db_api.CONTEXT_WRITER def create_router_assoc(self, context, bgpvpn_id, router_association): @@ -460,13 +463,14 @@ class BGPVPNPluginDb(): context.session.add(router_assoc_db) context.session.flush() return self._make_router_assoc_dict(router_assoc_db) - except db_exc.DBDuplicateEntry: + except db_exc.DBDuplicateEntry as db_dup_exc: LOG.warning("router %(router_id)s is already associated to " "BGPVPN %(bgpvpn_id)s", {'router_id': router_id, 'bgpvpn_id': bgpvpn_id}) raise bgpvpn_ext.BGPVPNRouterAssocAlreadyExists( - bgpvpn_id=bgpvpn_id, router_id=router_association['router_id']) + bgpvpn_id=bgpvpn_id, + router_id=router_association['router_id']) from db_dup_exc @db_api.CONTEXT_READER def get_router_assoc(self, context, assoc_id, bgpvpn_id, fields=None): @@ -521,9 +525,10 @@ class BGPVPNPluginDb(): return query.filter(BGPVPNPortAssociation.id == assoc_id, BGPVPNPortAssociation.bgpvpn_id == bgpvpn_id ).one() - except exc.NoResultFound: - raise bgpvpn_rc_ext.BGPVPNPortAssocNotFound(id=assoc_id, - bgpvpn_id=bgpvpn_id) + except exc.NoResultFound as no_res_exc: + raise bgpvpn_rc_ext.BGPVPNPortAssocNotFound( + id=assoc_id, + bgpvpn_id=bgpvpn_id) from no_res_exc def create_port_assoc(self, context, bgpvpn_id, port_association): port_id = port_association['port_id'] @@ -536,13 +541,14 @@ class BGPVPNPluginDb(): port_id=port_id, advertise_fixed_ips=advertise_fixed_ips) context.session.add(port_assoc_db) - except db_exc.DBDuplicateEntry: + except db_exc.DBDuplicateEntry as db_dup_exc: LOG.warning(("port %(port_id)s is already associated to " "BGPVPN %(bgpvpn_id)s"), {'port_id': port_id, 'bgpvpn_id': bgpvpn_id}) raise bgpvpn_rc_ext.BGPVPNPortAssocAlreadyExists( - bgpvpn_id=bgpvpn_id, port_id=port_association['port_id']) + bgpvpn_id=bgpvpn_id, + port_id=port_association['port_id']) from db_dup_exc for route in port_association['routes']: _add_port_assoc_route_db_from_dict( diff --git a/networking_bgpvpn/neutron/db/migration/alembic_migrations/env.py b/networking_bgpvpn/neutron/db/migration/alembic_migrations/env.py index 28f26472..de4ae7a1 100644 --- a/networking_bgpvpn/neutron/db/migration/alembic_migrations/env.py +++ b/networking_bgpvpn/neutron/db/migration/alembic_migrations/env.py @@ -44,7 +44,7 @@ def set_mysql_engine(): def run_migrations_offline(): set_mysql_engine() - kwargs = dict() + kwargs = {} if neutron_config.database.connection: kwargs['url'] = neutron_config.database.connection else: diff --git a/networking_bgpvpn/neutron/extensions/bgpvpn.py b/networking_bgpvpn/neutron/extensions/bgpvpn.py index c71357b1..967e6221 100644 --- a/networking_bgpvpn/neutron/extensions/bgpvpn.py +++ b/networking_bgpvpn/neutron/extensions/bgpvpn.py @@ -111,7 +111,8 @@ class Bgpvpn(api_extensions.APIExtensionDescriptor): register_quota=True, translate_name=True) plugin = directory.get_plugin(bgpvpn_api_def.ALIAS) - for collection_name in bgpvpn_api_def.SUB_RESOURCE_ATTRIBUTE_MAP: + sub_res_attrs = bgpvpn_api_def.SUB_RESOURCE_ATTRIBUTE_MAP + for collection_name in sub_res_attrs: # Special handling needed for sub-resources with 'y' ending # (e.g. proxies -> proxy) resource_name = collection_name[:-1] diff --git a/networking_bgpvpn/neutron/services/plugin.py b/networking_bgpvpn/neutron/services/plugin.py index 84a939dd..8f790548 100644 --- a/networking_bgpvpn/neutron/services/plugin.py +++ b/networking_bgpvpn/neutron/services/plugin.py @@ -49,7 +49,7 @@ class BGPVPNPlugin(bgpvpn.BGPVPNPluginBase, bgpvpn_rc.BGPVPNRoutesControlPluginBase): def __init__(self): - super(BGPVPNPlugin, self).__init__() + super().__init__() # Need to look into /etc/neutron/networking_bgpvpn.conf for # service_provider definitions: @@ -72,7 +72,7 @@ class BGPVPNPlugin(bgpvpn.BGPVPNPluginBase, @property def supported_extension_aliases(self): - exts = copy.copy(super(BGPVPNPlugin, self).supported_extension_aliases) + exts = copy.copy(super().supported_extension_aliases) exts += self.driver.more_supported_extension_aliases return exts @@ -260,16 +260,16 @@ class BGPVPNPlugin(bgpvpn.BGPVPNPluginBase, r['type'] == bgpvpn_rc.api_def.BGPVPN_TYPE]: try: route_bgpvpn = self.get_bgpvpn(context, route['bgpvpn_id']) - except bgpvpn.BGPVPNNotFound: + except bgpvpn.BGPVPNNotFound as not_found_exc: raise bgpvpn_rc.BGPVPNPortAssocRouteNoSuchBGPVPN( - bgpvpn_id=route['bgpvpn_id']) + bgpvpn_id=route['bgpvpn_id']) from not_found_exc assoc_bgpvpn = self.get_bgpvpn(context, bgpvpn_id) if route_bgpvpn['type'] != assoc_bgpvpn['type']: raise bgpvpn_rc.BGPVPNPortAssocRouteBGPVPNTypeDiffer( route_bgpvpn_type=route_bgpvpn['type'], bgpvpn_type=assoc_bgpvpn['type'] - ) + ) assoc_tenant_id = port_association.get('project_id') if assoc_tenant_id is None: diff --git a/networking_bgpvpn/neutron/services/service_drivers/bagpipe/bagpipe.py b/networking_bgpvpn/neutron/services/service_drivers/bagpipe/bagpipe.py index 4b867600..ac5ac3aa 100644 --- a/networking_bgpvpn/neutron/services/service_drivers/bagpipe/bagpipe.py +++ b/networking_bgpvpn/neutron/services/service_drivers/bagpipe/bagpipe.py @@ -177,7 +177,7 @@ class BaGPipeBGPVPNDriver(v2.BaGPipeBGPVPNDriver): """BGPVPN Service Driver class for BaGPipe""" def __init__(self, service_plugin): - super(BaGPipeBGPVPNDriver, self).__init__(service_plugin) + super().__init__(service_plugin) self.agent_rpc = rpc_client.BGPVPNAgentNotifyApi() @@ -312,11 +312,11 @@ class BaGPipeBGPVPNDriver(v2.BaGPipeBGPVPNDriver): bgpvpn_rts = self._format_bgpvpn_network_route_targets(bgpvpns) LOG.debug("Port connected on BGPVPN network %s with route targets " - "%s" % (network_id, bgpvpn_rts)) + "%s", (network_id, bgpvpn_rts)) bgpvpn_network_info.update(bgpvpn_rts) - LOG.debug("Getting port %s network details" % port_id) + LOG.debug("Getting port %s network details", port_id) network_info = get_network_info_for_port(context, port_id, network_id) if not network_info: @@ -341,18 +341,19 @@ class BaGPipeBGPVPNDriver(v2.BaGPipeBGPVPNDriver): context, self._format_bgpvpn(context, bgpvpn, net_id)) - def update_bgpvpn_postcommit(self, context, old_bgpvpn, bgpvpn): - super(BaGPipeBGPVPNDriver, self).update_bgpvpn_postcommit( - context, old_bgpvpn, bgpvpn) + def update_bgpvpn_postcommit(self, context, old_bgpvpn, new_bgpvpn): + super().update_bgpvpn_postcommit( + context, old_bgpvpn, new_bgpvpn) (added_keys, removed_keys, changed_keys) = ( - utils.get_bgpvpn_differences(bgpvpn, old_bgpvpn)) + utils.get_bgpvpn_differences(new_bgpvpn, old_bgpvpn)) ATTRIBUTES_TO_IGNORE = set('name') moving_keys = added_keys | removed_keys | changed_keys if len(moving_keys ^ ATTRIBUTES_TO_IGNORE): - for net_id in self._networks_for_bgpvpn(context, bgpvpn): + for net_id in self._networks_for_bgpvpn(context, new_bgpvpn): if (get_network_ports(context, net_id)): - self._update_bgpvpn_for_network(context, net_id, bgpvpn) + self._update_bgpvpn_for_network(context, net_id, + new_bgpvpn) def _update_bgpvpn_for_net_with_id(self, context, network_id, bgpvpn_id): if get_network_ports(context, network_id): @@ -365,8 +366,7 @@ class BaGPipeBGPVPNDriver(v2.BaGPipeBGPVPNDriver): formated_bgpvpn) def create_net_assoc_postcommit(self, context, net_assoc): - super(BaGPipeBGPVPNDriver, self).create_net_assoc_postcommit(context, - net_assoc) + super().create_net_assoc_postcommit(context, net_assoc) self._update_bgpvpn_for_net_with_id(context, net_assoc['network_id'], net_assoc['bgpvpn_id']) @@ -447,7 +447,7 @@ class BaGPipeBGPVPNDriver(v2.BaGPipeBGPVPNDriver): port[portbindings.HOST_ID]) def create_router_assoc_postcommit(self, context, router_assoc): - super(BaGPipeBGPVPNDriver, self).create_router_assoc_postcommit( + super().create_router_assoc_postcommit( context, router_assoc) for net_id in get_networks_for_router(context, router_assoc['router_id']): @@ -464,7 +464,7 @@ class BaGPipeBGPVPNDriver(v2.BaGPipeBGPVPNDriver): @log_helpers.log_method_call def notify_router_interface_created(self, context, router_id, net_id): - super(BaGPipeBGPVPNDriver, self).notify_router_interface_created( + super().notify_router_interface_created( context, router_id, net_id) net_assocs = get_network_bgpvpn_assocs(context, net_id) @@ -485,7 +485,7 @@ class BaGPipeBGPVPNDriver(v2.BaGPipeBGPVPNDriver): @log_helpers.log_method_call def notify_router_interface_deleted(self, context, router_id, net_id): - super(BaGPipeBGPVPNDriver, self).notify_router_interface_deleted( + super().notify_router_interface_deleted( context, router_id, net_id) net_assocs = get_network_bgpvpn_assocs(context, net_id) diff --git a/networking_bgpvpn/neutron/services/service_drivers/bagpipe/bagpipe_v2.py b/networking_bgpvpn/neutron/services/service_drivers/bagpipe/bagpipe_v2.py index fe4e551d..ee23eb83 100644 --- a/networking_bgpvpn/neutron/services/service_drivers/bagpipe/bagpipe_v2.py +++ b/networking_bgpvpn/neutron/services/service_drivers/bagpipe/bagpipe_v2.py @@ -79,7 +79,7 @@ class BaGPipeBGPVPNDriver(driver_api.BGPVPNDriverRC): bgpvpn_vni_def.ALIAS] def __init__(self, service_plugin): - super(BaGPipeBGPVPNDriver, self).__init__(service_plugin) + super().__init__(service_plugin) self._push_rpc = resources_rpc.ResourcesPushRpcApi() @@ -105,16 +105,16 @@ class BaGPipeBGPVPNDriver(driver_api.BGPVPNDriverRC): self._push_bgpvpn_associations(context, bgpvpn['id'], rpc_events.DELETED) - def update_bgpvpn_precommit(self, context, old_bgpvpn, bgpvpn): - self._common_precommit_checks(bgpvpn) + def update_bgpvpn_precommit(self, context, old_bgpvpn, new_bgpvpn): + self._common_precommit_checks(new_bgpvpn) - def update_bgpvpn_postcommit(self, context, old_bgpvpn, bgpvpn): + def update_bgpvpn_postcommit(self, context, old_bgpvpn, new_bgpvpn): (added_keys, removed_keys, changed_keys) = ( - utils.get_bgpvpn_differences(bgpvpn, old_bgpvpn)) + utils.get_bgpvpn_differences(new_bgpvpn, old_bgpvpn)) ATTRIBUTES_TO_IGNORE = set(['name']) moving_keys = added_keys | removed_keys | changed_keys if len(moving_keys ^ ATTRIBUTES_TO_IGNORE): - self._push_bgpvpn_associations(context, bgpvpn['id'], + self._push_bgpvpn_associations(context, new_bgpvpn['id'], rpc_events.UPDATED) def _push_bgpvpn_associations(self, context, bgpvpn_id, event_type): diff --git a/networking_bgpvpn/neutron/services/service_drivers/driver_api.py b/networking_bgpvpn/neutron/services/service_drivers/driver_api.py index 1291f154..22b78a33 100644 --- a/networking_bgpvpn/neutron/services/service_drivers/driver_api.py +++ b/networking_bgpvpn/neutron/services/service_drivers/driver_api.py @@ -99,7 +99,7 @@ class BGPVPNDriverDBMixin(BGPVPNDriverBase, metaclass=abc.ABCMeta): """ def __init__(self, *args, **kwargs): - super(BGPVPNDriverDBMixin, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.bgpvpn_db = bgpvpn_db.BGPVPNPluginDb() def create_bgpvpn(self, context, bgpvpn): @@ -116,13 +116,13 @@ class BGPVPNDriverDBMixin(BGPVPNDriverBase, metaclass=abc.ABCMeta): def get_bgpvpn(self, context, id, fields=None): return self.bgpvpn_db.get_bgpvpn(context, id, fields) - def update_bgpvpn(self, context, id, bgpvpn_delta): + def update_bgpvpn(self, context, id, bgpvpn): old_bgpvpn = self.get_bgpvpn(context, id) with db_api.CONTEXT_WRITER.using(context): new_bgpvpn = copy.deepcopy(old_bgpvpn) - new_bgpvpn.update(bgpvpn_delta) + new_bgpvpn.update(bgpvpn) self.update_bgpvpn_precommit(context, old_bgpvpn, new_bgpvpn) - bgpvpn = self.bgpvpn_db.update_bgpvpn(context, id, bgpvpn_delta) + bgpvpn = self.bgpvpn_db.update_bgpvpn(context, id, bgpvpn) self.update_bgpvpn_postcommit(context, old_bgpvpn, bgpvpn) return bgpvpn diff --git a/networking_bgpvpn/tests/unit/db/test_db.py b/networking_bgpvpn/tests/unit/db/test_db.py index 60fd7f8f..6025c94d 100644 --- a/networking_bgpvpn/tests/unit/db/test_db.py +++ b/networking_bgpvpn/tests/unit/db/test_db.py @@ -83,7 +83,7 @@ class BgpvpnDBTestCase(test_plugin.BgpvpnTestCaseMixin): # Test should ensure vni attribute is not present as # bpvpn_vni extension is not loaded. # - self.assertFalse('vni' in bgpvpn) + self.assertNotIn('vni', bgpvpn) if utils.is_extension_supported(self.bgpvpn_plugin, bgpvpn_rc_def.ALIAS): @@ -93,7 +93,7 @@ class BgpvpnDBTestCase(test_plugin.BgpvpnTestCaseMixin): # Test should ensure local_pref attribute is not present as # bpvpn-routes-control extension is not loaded. # - self.assertFalse('local_pref' in bgpvpn) + self.assertNotIn('local_pref', bgpvpn) self.assertEqual([net['network']['id']], bgpvpn['networks']) diff --git a/networking_bgpvpn/tests/unit/extensions/test_bgpvpn_routes_control.py b/networking_bgpvpn/tests/unit/extensions/test_bgpvpn_routes_control.py index d558efb6..fe344054 100644 --- a/networking_bgpvpn/tests/unit/extensions/test_bgpvpn_routes_control.py +++ b/networking_bgpvpn/tests/unit/extensions/test_bgpvpn_routes_control.py @@ -97,7 +97,7 @@ class BgpvpnRoutesControlExtensionTestCase( update_data = {'router_association': { 'advertise_extra_routes': False, - }} + }} return_value = { 'project_id': _uuid(), @@ -134,30 +134,25 @@ class BgpvpnRoutesControlExtensionTestCase( "No valid key specs"), ({'routes': [{ 'type': 'prefix', - 'something_else_than_prefix': 'foo' - }]}, + 'something_else_than_prefix': 'foo'}]}, "No valid key specs"), ({'routes': [{ 'type': 'prefix', - 'prefix': '1.1.1.352' - }]}, + 'prefix': '1.1.1.352'}]}, "No valid key specs"), ({'routes': [{ 'type': 'prefix', - 'something_else_than_bgpvpn_id': 'foo' - }]}, + 'something_else_than_bgpvpn_id': 'foo'}]}, "No valid key specs"), ({'routes': [{ 'type': 'prefix', 'prefix': '12.1.2.3', - 'local_pref': -1, - }]}, + 'local_pref': -1, }]}, "No valid key specs"), ({'routes': [{ 'type': 'prefix', 'prefix': '12.1.2.3/20', - 'local_pref': 2 ** 32, - }]}, + 'local_pref': 2 ** 32, }]}, "No valid key specs") ] @@ -216,8 +211,7 @@ class BgpvpnRoutesControlExtensionTestCase( data = {'port_association': { 'port_id': self.port_id, 'project_id': _uuid() - } - } + }} data['port_association'].update(port_assoc_attrs) self._test_port_association_create_with_invalid_data(data, msg) @@ -261,8 +255,8 @@ class BgpvpnRoutesControlExtensionTestCase( 'local_pref': 42}, {'type': 'bgpvpn', 'bgpvpn_id': _uuid()}, - ] - }} + ] + }} return_value = { 'port_id': self.port_id, diff --git a/networking_bgpvpn/tests/unit/services/bagpipe/test_bagpipe.py b/networking_bgpvpn/tests/unit/services/bagpipe/test_bagpipe.py index e0984f31..8f1e3825 100644 --- a/networking_bgpvpn/tests/unit/services/bagpipe/test_bagpipe.py +++ b/networking_bgpvpn/tests/unit/services/bagpipe/test_bagpipe.py @@ -186,7 +186,7 @@ class TestBagpipeOVOPushPullMixin(object): self.assertEqual( [AnyOfClass(objs.BGPVPNNetAssociation)], ovos_in_call - ) + ) mocked_push.reset_mock() @@ -198,7 +198,7 @@ class TestBagpipeOVOPushPullMixin(object): self.assertEqual( [AnyOfClass(objs.BGPVPNNetAssociation)], ovos_in_call - ) + ) @mock.patch.object(resources_rpc.ResourcesPushRpcApi, 'push') def test_router_assoc_create_delete(self, mocked_push): @@ -216,7 +216,7 @@ class TestBagpipeOVOPushPullMixin(object): self.assertEqual( [AnyOfClass(objs.BGPVPNRouterAssociation)], ovos_in_call - ) + ) mocked_push.reset_mock() @@ -228,7 +228,7 @@ class TestBagpipeOVOPushPullMixin(object): self.assertEqual( [AnyOfClass(objs.BGPVPNRouterAssociation)], ovos_in_call - ) + ) @mock.patch.object(resources_rpc.ResourcesPushRpcApi, 'push') def test_port_assoc_crud(self, mocked_push): @@ -246,7 +246,7 @@ class TestBagpipeOVOPushPullMixin(object): self.assertEqual( [AnyOfClass(objs.BGPVPNPortAssociation)], ovos_in_call - ) + ) mocked_push.reset_mock() @@ -265,7 +265,7 @@ class TestBagpipeOVOPushPullMixin(object): self.assertEqual( [AnyOfClass(objs.BGPVPNPortAssociation)], ovos_in_call - ) + ) mocked_push.reset_mock() @@ -277,7 +277,7 @@ class TestBagpipeOVOPushPullMixin(object): self.assertEqual( [AnyOfClass(objs.BGPVPNPortAssociation)], ovos_in_call - ) + ) class TestBagpipeServiceDriver(TestBagpipeCommon): @@ -779,7 +779,7 @@ class TestBagpipeServiceDriverCallbacks(TestBagpipeCommon, self.router(tenant_id=self._tenant_id) as router, \ self.bgpvpn() as bgpvpn, \ mock.patch.object(self.bagpipe_driver, 'get_bgpvpn', - return_value=bgpvpn['bgpvpn']),\ + return_value=bgpvpn['bgpvpn']), \ mock.patch.object(bagpipe, 'get_router_bgpvpn_assocs', return_value=[{ @@ -805,7 +805,7 @@ class TestBagpipeServiceDriverCallbacks(TestBagpipeCommon, self.router(tenant_id=self._tenant_id) as router, \ self.bgpvpn() as bgpvpn, \ mock.patch.object(self.bagpipe_driver, 'get_bgpvpn', - return_value=bgpvpn['bgpvpn']),\ + return_value=bgpvpn['bgpvpn']), \ mock.patch.object(bagpipe, 'get_router_bgpvpn_assocs', return_value=[{ @@ -1002,11 +1002,11 @@ class TestBagpipeServiceDriverCallbacks(TestBagpipeCommon, { 'type': 'l3', 'route_targets': ['12345:3', '12346:1'] - }, + }, { 'type': 'l2', 'route_targets': ['12347:1'] - }] + }] result = driver._format_bgpvpn_network_route_targets(bgpvpns) expected = { 'l3vpn': { diff --git a/networking_bgpvpn/tests/unit/services/test_plugin.py b/networking_bgpvpn/tests/unit/services/test_plugin.py index 244a23e3..6d4611d0 100644 --- a/networking_bgpvpn/tests/unit/services/test_plugin.py +++ b/networking_bgpvpn/tests/unit/services/test_plugin.py @@ -323,7 +323,7 @@ class TestBGPVPNServicePlugin(BgpvpnTestCaseMixin): self.assertEqual(res.status_int, webob.exc.HTTPForbidden.code) def test_bgpvpn_router_assoc_create(self): - with self.router(tenant_id=self._tenant_id) as router,\ + with self.router(tenant_id=self._tenant_id) as router, \ self.bgpvpn() as bgpvpn, \ mock.patch.object( self.bgpvpn_plugin, @@ -445,7 +445,7 @@ class TestBGPVPNServicePlugin(BgpvpnTestCaseMixin): self.assertEqual(res.status_int, webob.exc.HTTPForbidden.code) def test_router_net_combination(self): - with self.network() as net,\ + with self.network() as net, \ self.bgpvpn() as bgpvpn, \ self.router(tenant_id=self._tenant_id) as router: self._test_router_net_combination_validation( @@ -542,11 +542,11 @@ class TestBGPVPNServicePlugin(BgpvpnTestCaseMixin): self.assertEqual(res.status_int, webob.exc.HTTPBadRequest.code) def test_attach_subnet_to_router_both_attached_to_bgpvpn(self): - with self.network() as net,\ - self.bgpvpn() as bgpvpn,\ - self.router(tenant_id=self._tenant_id) as router,\ - self.subnet(network={'network': net['network']}) as subnet,\ - self.assoc_net(bgpvpn['bgpvpn']['id'], net['network']['id']),\ + with self.network() as net, \ + self.bgpvpn() as bgpvpn, \ + self.router(tenant_id=self._tenant_id) as router, \ + self.subnet(network={'network': net['network']}) as subnet, \ + self.assoc_net(bgpvpn['bgpvpn']['id'], net['network']['id']), \ self.assoc_router(bgpvpn['bgpvpn']['id'], router['router']['id']): # Attach subnet to router @@ -562,12 +562,12 @@ class TestBGPVPNServicePlugin(BgpvpnTestCaseMixin): self.assertEqual(res.status_int, webob.exc.HTTPConflict.code) def test_attach_port_to_router_both_attached_to_bgpvpn(self): - with self.network() as net,\ - self.bgpvpn() as bgpvpn,\ - self.router(tenant_id=self._tenant_id) as router,\ - self.subnet(network={'network': net['network']}) as subnet,\ - self.port(subnet={'subnet': subnet['subnet']}) as port,\ - self.assoc_net(bgpvpn['bgpvpn']['id'], net['network']['id']),\ + with self.network() as net, \ + self.bgpvpn() as bgpvpn, \ + self.router(tenant_id=self._tenant_id) as router, \ + self.subnet(network={'network': net['network']}) as subnet, \ + self.port(subnet={'subnet': subnet['subnet']}) as port, \ + self.assoc_net(bgpvpn['bgpvpn']['id'], net['network']['id']), \ self.assoc_router(bgpvpn['bgpvpn']['id'], router['router']['id']): # Attach subnet to router @@ -599,7 +599,7 @@ class TestBGPVPNServicePlugin(BgpvpnTestCaseMixin): routes=[{ 'type': 'prefix', 'prefix': '12.1.3.0/24', - }]): + }]): mock_validate.assert_called_once_with( mock.ANY, port['port']['id']) @@ -637,8 +637,7 @@ class TestBGPVPNServicePlugin(BgpvpnTestCaseMixin): 'routes': [{ 'type': 'bgpvpn', 'bgpvpn_id': '3aff9b6b-387b-4ffd-a9ff-a4bdffb349ff' - }] - }} + }]}} bgpvpn_net_req = self.new_create_request( 'bgpvpn/bgpvpns', @@ -664,8 +663,7 @@ class TestBGPVPNServicePlugin(BgpvpnTestCaseMixin): 'routes': [{ 'type': 'bgpvpn', 'bgpvpn_id': bgpvpn_other['bgpvpn']['id'] - }] - }} + }]}} bgpvpn_net_req = self.new_create_request( 'bgpvpn/bgpvpns', @@ -781,9 +779,8 @@ class TestBGPVPNServicePlugin(BgpvpnTestCaseMixin): 'routes': [{ 'type': 'bgpvpn', 'bgpvpn_id': bgpvpn_other['bgpvpn']['id'] - }] - } - }, + }] + }}, port_assoc['port_association']['id'], as_admin=True ) @@ -812,9 +809,8 @@ class TestBGPVPNServicePlugin(BgpvpnTestCaseMixin): 'routes': [{ 'type': 'bgpvpn', 'bgpvpn_id': bgpvpn_l3['bgpvpn']['id'] - }] - } - }, + }] + }}, port_assoc['port_association']['id'], as_admin=True ) @@ -1272,8 +1268,8 @@ class TestBGPVPNServiceDriverDB(BgpvpnTestCaseMixin): mock_pre_commit, mock_post_commit): with self.bgpvpn() as bgpvpn, \ - self.network() as net,\ - self.subnet(network={'network': net['network']}) as subnet,\ + self.network() as net, \ + self.subnet(network={'network': net['network']}) as subnet, \ self.port(subnet={'subnet': subnet['subnet']}, tenant_id=self._tenant_id) as port: bgpvpn_id = bgpvpn['bgpvpn']['id'] @@ -1418,12 +1414,12 @@ class TestBGPVPNServiceDriverDB(BgpvpnTestCaseMixin): mock.ANY, assoc['port_association'], new_port_assoc['port_association'] - ) + ) mock_postcommit.assert_called_once_with( mock.ANY, assoc['port_association'], new_port_assoc['port_association'] - ) + ) @mock.patch.object(driver_api.BGPVPNDriverRC, 'delete_port_assoc_precommit') diff --git a/requirements.txt b/requirements.txt index 67b14709..e9da9bf1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,10 +2,6 @@ # date but we do not test them so no guarantee of having them all correct. If # you find any incorrect lower bounds, let us know or propose a fix. -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. - pbr>=4.0.0 # Apache-2.0 oslo.config>=5.2.0 # Apache-2.0 oslo.db>=4.37.0 # Apache-2.0 diff --git a/test-requirements.txt b/test-requirements.txt index 6dca4192..d441898c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,8 +1,4 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. - -hacking>=3.0.1,<3.1 # Apache-2.0 +hacking>=6.1.0,<6.2.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 python-subunit>=1.0.0 # Apache-2.0/BSD @@ -10,7 +6,7 @@ psycopg2>=2.8.5 # LGPL/ZPL PyMySQL>=0.7.6 # MIT License WebOb>=1.8.2 # MIT oslotest>=3.2.0 # Apache-2.0 -pylint==2.5.3 # GPLv2 +pylint==2.17.4 # GPLv2 pytest>=5.3.5 # MIT stestr>=1.0.0 # Apache-2.0 testresources>=2.0.0 # Apache-2.0/BSD diff --git a/tox.ini b/tox.ini index eec3f483..9a356c83 100644 --- a/tox.ini +++ b/tox.ini @@ -99,12 +99,23 @@ commands = oslopolicy-sample-generator --config-file=etc/oslo-policy-generator/p [flake8] show-source = True -# E123, E125 skipped as they are invalid PEP-8. # N530 direct neutron imports not allowed # W504 Line break occurred after a binary operator -ignore = E123,E125,N530,W504 +# E126 continuation line over-indented for hanging indent +# E128 continuation line under-indented for visual indent +# H405 multi line docstring summary not separated with an empty line +# I202 Additional newline in a group of imports +# E731 do not assign a lambda expression, use a def +# W504 line break after binary operator +ignore = E126,E128,E731,I202,H405,N530,W504 builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.tmp +# H106: Don't put vim configuration in source files +# H203: Use assertIs(Not)None to check for None +# H204: Use assert(Not)Equal to check for equality +# H205: Use assert(Greater|Less)(Equal) for comparison +# H904: Delay string interpolations at logging calls +enable-extensions=H106,H203,H204,H205,H904 [flake8:local-plugins] extension =

AltStyle によって変換されたページ (->オリジナル) /