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 <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2019-11-22 15:47:13 +00:00
parent 4c8f3990c6
commit 9428ebfed9
6 changed files with 11 additions and 11 deletions

View File

@ -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

View File

@ -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()

View File

@ -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.

View File

@ -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),

View File

@ -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)

View File

@ -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')})