Prepare for hacking 6.x

This brings in a new version of flake8 as well as additional checks of
its own. Address all of them in advance of the bump.

Change-Id: I870bd8110106d4714db7ead94429fad6a74beb88
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-05-03 11:38:08 +01:00
parent 69735d3bd8
commit 6baf11f606
12 changed files with 31 additions and 30 deletions

View File

@ -263,10 +263,10 @@ class Object(_base.BaseResource):
attr_keys_to_delete = set()
for key in keys:
if key == 'delete_after':
del(metadata['delete_at'])
del metadata['delete_at']
else:
if key in metadata:
del(metadata[key])
del metadata[key]
# Delete the attribute from the local copy of the object.
# Metadata that doesn't have Component attributes is
# handled by self.metadata being reset when we run

View File

@ -99,7 +99,7 @@ class _BaseComponent:
deprecation_reason = None
#: Control field used to manage the deprecation warning. We want to warn
# only once when the attribute is retrieved in the code.
#: only once when the attribute is retrieved in the code.
already_warned_deprecation = False
def __init__(
@ -1009,7 +1009,8 @@ class Resource(dict):
return cls(_synchronized=synchronized, connection=connection, **obj)
def _attr_to_dict(self, attr, to_munch):
"""For a given attribute, convert it into a form suitable for a dict value.
"""For a given attribute, convert it into a form suitable for a dict
value.
:param bool attr: Attribute name to convert

View File

@ -200,7 +200,7 @@ class TestCompute(base.BaseFunctionalTest):
# returning a string tests that the call is correct. Testing that
# the cloud returns actual data in the output is out of scope.
log = self.user_cloud._get_server_console_output(server_id=server.id)
self.assertTrue(isinstance(log, str))
self.assertIsInstance(log, str)
def test_get_server_console_name_or_id(self):
self.addCleanup(self._cleanup_servers_and_volumes, self.server_name)
@ -210,7 +210,7 @@ class TestCompute(base.BaseFunctionalTest):
flavor=self.flavor,
wait=True)
log = self.user_cloud.get_server_console(server=self.server_name)
self.assertTrue(isinstance(log, str))
self.assertIsInstance(log, str)
def test_list_availability_zone_names(self):
self.assertEqual(

View File

@ -117,4 +117,4 @@ class TestNetworkQuotas(base.BaseFunctionalTest):
quota_val = quota_details[quota]
if quota_val:
for expected_key in expected_keys:
self.assertTrue(expected_key in quota_val)
self.assertIn(expected_key, quota_val)

View File

@ -760,8 +760,8 @@ class TestCase(base.TestCase):
)
def assertResourceListEqual(self, actual, expected, resource_type):
"""Helper for the assertEqual which compares Resource lists object against
dictionary representing expected state.
"""Helper for the assertEqual which compares Resource lists object
against dictionary representing expected state.
:param list actual: List of actual objects.
:param listexpected: List of dictionaries representing expected

View File

@ -561,9 +561,9 @@ class TestImage(BaseTestImage):
)
image_no_checksums = self.fake_image_dict.copy()
del(image_no_checksums['owner_specified.openstack.md5'])
del(image_no_checksums['owner_specified.openstack.sha256'])
del(image_no_checksums['owner_specified.openstack.object'])
del image_no_checksums['owner_specified.openstack.md5']
del image_no_checksums['owner_specified.openstack.sha256']
del image_no_checksums['owner_specified.openstack.object']
self.register_uris([
dict(method='GET',
@ -736,9 +736,9 @@ class TestImage(BaseTestImage):
object_path = self.fake_image_dict['owner_specified.openstack.object']
image_no_checksums = self.fake_image_dict.copy()
del(image_no_checksums['owner_specified.openstack.md5'])
del(image_no_checksums['owner_specified.openstack.sha256'])
del(image_no_checksums['owner_specified.openstack.object'])
del image_no_checksums['owner_specified.openstack.md5']
del image_no_checksums['owner_specified.openstack.sha256']
del image_no_checksums['owner_specified.openstack.object']
self.register_uris([
dict(method='GET',

View File

@ -62,19 +62,19 @@ class TestServerIP(base.TestCase):
self.assertEqual(4, len(ips))
ips = sorted(ips, key=lambda ip: ip.version)
self.assertEqual(type(ips[0]), server_ip.ServerIP)
self.assertIsInstance(ips[0], server_ip.ServerIP)
self.assertEqual(ips[0].network_label, "label1")
self.assertEqual(ips[0].address, "a1")
self.assertEqual(ips[0].version, 1)
self.assertEqual(type(ips[1]), server_ip.ServerIP)
self.assertIsInstance(ips[1], server_ip.ServerIP)
self.assertEqual(ips[1].network_label, "label1")
self.assertEqual(ips[1].address, "a2")
self.assertEqual(ips[1].version, 2)
self.assertEqual(type(ips[2]), server_ip.ServerIP)
self.assertIsInstance(ips[2], server_ip.ServerIP)
self.assertEqual(ips[2].network_label, "label2")
self.assertEqual(ips[2].address, "a3")
self.assertEqual(ips[2].version, 3)
self.assertEqual(type(ips[3]), server_ip.ServerIP)
self.assertIsInstance(ips[3], server_ip.ServerIP)
self.assertEqual(ips[3].network_label, "label2")
self.assertEqual(ips[3].address, "a4")
self.assertEqual(ips[3].version, 4)
@ -97,11 +97,11 @@ class TestServerIP(base.TestCase):
self.assertEqual(2, len(ips))
ips = sorted(ips, key=lambda ip: ip.version)
self.assertEqual(type(ips[0]), server_ip.ServerIP)
self.assertIsInstance(ips[0], server_ip.ServerIP)
self.assertEqual(ips[0].network_label, label)
self.assertEqual(ips[0].address, "a1")
self.assertEqual(ips[0].version, 1)
self.assertEqual(type(ips[1]), server_ip.ServerIP)
self.assertIsInstance(ips[1], server_ip.ServerIP)
self.assertEqual(ips[1].network_label, label)
self.assertEqual(ips[1].address, "a2")
self.assertEqual(ips[1].version, 2)

View File

@ -64,8 +64,8 @@ class TestCloudRegion(base.TestCase):
def test_iteration(self):
cc = cloud_region.CloudRegion("test1", "region-al", fake_config_dict)
self.assertTrue('a' in cc)
self.assertFalse('x' in cc)
self.assertIn('a', cc)
self.assertNotIn('x', cc)
def test_equality(self):
cc1 = cloud_region.CloudRegion("test1", "region-al", fake_config_dict)

View File

@ -40,6 +40,5 @@ class TestMissingVersion(base.TestCase):
def test_unsupported_version_override(self):
self.cloud.config.config['image_api_version'] = '7'
self.assertTrue(isinstance(self.cloud.image, proxy.Proxy))
self.assertIsInstance(self.cloud.image, proxy.Proxy)
self.assert_calls()

View File

@ -442,9 +442,10 @@ class Munch(dict):
object.__setattr__(self, k, v)
def __delattr__(self, k):
"""Deletes attribute k if it exists, otherwise deletes key k. A KeyError
raised by deleting the key--such as when the key is missing--will
propagate as an AttributeError instead.
"""Deletes attribute k if it exists, otherwise deletes key k.
A KeyError raised by deleting the key - such as when the key is missing
- will propagate as an AttributeError instead.
"""
try:
# Throws exception if not in prototype chain