From 9428ebfed976e0d5755b72ef85fc92721f9d30ee Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 22 Nov 2019 15:47:13 +0000 Subject: [PATCH] trivial: Resolve (most) flake8 3.x issues A future change will bump flake8 to 3.x. See off most of the issues that this will introduce now, with the exception of some missing typing imports in 'nova/virt/hardware.py' - fixing those here with the current version of flake8 would actually raise an error about unused imports. Change-Id: I9480ac1749d448efe4f415f5e80ff9b9837216b6 Signed-off-by: Stephen Finucane --- nova/objects/network.py | 6 +++--- nova/objects/security_group.py | 2 +- nova/tests/fixtures.py | 2 +- nova/tests/unit/api/openstack/compute/test_volumes.py | 8 ++++---- nova/virt/block_device.py | 2 +- nova/virt/powervm/media.py | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nova/objects/network.py b/nova/objects/network.py index 1d4a148d7385..ea35f938a36a 100644 --- a/nova/objects/network.py +++ b/nova/objects/network.py @@ -103,11 +103,11 @@ class Network(obj_base.NovaPersistentObject, obj_base.NovaObject, def _from_db_object(context, network, db_network): for field in network.fields: db_value = db_network[field] - if field is 'netmask_v6' and db_value is not None: + if field == 'netmask_v6' and db_value is not None: db_value = network._convert_legacy_ipv6_netmask(db_value) - if field is 'dhcp_server' and db_value is None: + if field == 'dhcp_server' and db_value is None: db_value = db_network['gateway'] - if field is 'share_address' and CONF.share_dhcp_address: + if field == 'share_address' and CONF.share_dhcp_address: db_value = CONF.share_dhcp_address network[field] = db_value diff --git a/nova/objects/security_group.py b/nova/objects/security_group.py index ecbdfba0c911..f8c2db449d94 100644 --- a/nova/objects/security_group.py +++ b/nova/objects/security_group.py @@ -49,7 +49,7 @@ class SecurityGroup(base.NovaPersistentObject, base.NovaObject): @staticmethod def _from_db_object(context, secgroup, db_secgroup): for field in secgroup.fields: - if field is not 'uuid': + if field != 'uuid': setattr(secgroup, field, db_secgroup[field]) secgroup._context = context secgroup.obj_reset_changes() diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index d8322e1f951f..b29df9ee6b4c 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -2397,7 +2397,7 @@ class HostNameWeigher(weights.BaseHostWeigher): self.weights = self.get_weights() def get_weights(self): - raise NotImplemented() + raise NotImplementedError() def _weigh_object(self, host_state, weight_properties): # Any unspecified host gets no weight. diff --git a/nova/tests/unit/api/openstack/compute/test_volumes.py b/nova/tests/unit/api/openstack/compute/test_volumes.py index b06521592255..76eaeebf7804 100644 --- a/nova/tests/unit/api/openstack/compute/test_volumes.py +++ b/nova/tests/unit/api/openstack/compute/test_volumes.py @@ -1399,10 +1399,10 @@ class AssistedSnapshotDeleteTestCaseV21(test.NoDBTestCase): self.controller.delete(req, '5') def test_delete_duplicate_query_parameters_validation(self): - params = { - 'delete_info': jsonutils.dumps({'volume_id': '1'}), - 'delete_info': jsonutils.dumps({'volume_id': '2'}) - } + params = [ + ('delete_info', jsonutils.dumps({'volume_id': '1'})), + ('delete_info', jsonutils.dumps({'volume_id': '2'})) + ] req = fakes.HTTPRequest.blank( self.url + '?%s' % urllib.parse.urlencode(params), diff --git a/nova/virt/block_device.py b/nova/virt/block_device.py index 6fb57fda2dd6..7dcc5ff1614f 100644 --- a/nova/virt/block_device.py +++ b/nova/virt/block_device.py @@ -333,7 +333,7 @@ class DriverVolumeBlockDevice(DriverBlockDevice): '%(mp)s : %(err)s', {'volume_id': volume_id, 'mp': mp, 'err': err}, instance=instance) - except exception.DeviceDetachFailed as err: + except exception.DeviceDetachFailed: with excutils.save_and_reraise_exception(): LOG.warning('Guest refused to detach volume %(vol)s', {'vol': volume_id}, instance=instance) diff --git a/nova/virt/powervm/media.py b/nova/virt/powervm/media.py index 03b820969223..f57ddd332d28 100644 --- a/nova/virt/powervm/media.py +++ b/nova/virt/powervm/media.py @@ -76,7 +76,7 @@ class ConfigDrivePowerVM(object): # OVS is the only supported vif type. All others (SEA, PowerVM SR-IOV) # will default to generic vif. for vif in network_info: - if vif.get('type') is not 'ovs': + if vif.get('type') != 'ovs': LOG.debug('Changing vif type from %(type)s to vif for vif ' '%(id)s.', {'type': vif.get('type'), 'id': vif.get('id')})