From c9e9ef9f43dce18e6cdcd528414a05b9ad78134a Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 15 Mar 2017 18:06:28 +0100 Subject: [PATCH] Fix a few minor annoyances that snuck in We had the normal infra pep8 ignores marked, but follow some of them by hand in this codebase anyway. While E12* are not valid pep8, the prevailing style of shade is in agreement with them. While we weren't enforcing them, a few instances snuck in. Fix them and just turn the flags on. Change-Id: Iea2bd9a99eb8b20dd40418ac8479b809d3872de8 --- shade/openstackcloud.py | 12 ++++++------ shade/operatorcloud.py | 2 +- shade/tests/functional/test_endpoints.py | 4 ++-- shade/tests/functional/test_object.py | 6 ++---- shade/tests/functional/test_services.py | 4 ++-- shade/tests/unit/test__utils.py | 4 ++-- tox.ini | 3 +-- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index a27c996e7..d00e38016 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -2121,8 +2121,7 @@ class OpenStackCloud(_normalize.Normalizer): external_ipv4_networks.append(network) # External Floating IPv4 networks - if ('router:external' in network - and network['router:external']): + if ('router:external' in network and network['router:external']): external_ipv4_floating_networks.append(network) # Internal networks @@ -3016,7 +3015,7 @@ class OpenStackCloud(_normalize.Normalizer): if interface_type: filtered_ports = [] if (router.get('external_gateway_info') and - 'external_fixed_ips' in router['external_gateway_info']): + 'external_fixed_ips' in router['external_gateway_info']): ext_fixed = \ router['external_gateway_info']['external_fixed_ips'] else: @@ -4013,7 +4012,7 @@ class OpenStackCloud(_normalize.Normalizer): for count in _utils._iterate_timeout( timeout, "Timeout waiting for the volume snapshot to be available." - ): + ): snapshot = self.get_volume_snapshot_by_id(snapshot_id) if snapshot['status'] == 'available': @@ -5862,7 +5861,7 @@ class OpenStackCloud(_normalize.Normalizer): return segment_size def is_object_stale( - self, container, name, filename, file_md5=None, file_sha256=None): + self, container, name, filename, file_md5=None, file_sha256=None): metadata = self.get_object_metadata(container, name) if not metadata: @@ -5998,7 +5997,8 @@ class OpenStackCloud(_normalize.Normalizer): entry['etag'] = result.headers['Etag'] def _upload_large_object( - self, endpoint, filename, headers, file_size, segment_size, use_slo): + self, endpoint, filename, + headers, file_size, segment_size, use_slo): # If the object is big, we need to break it up into segments that # are no larger than segment_size, upload each of them individually # and then upload a manifest object. The segments can be uploaded in diff --git a/shade/operatorcloud.py b/shade/operatorcloud.py index bed069af8..02ddd4709 100644 --- a/shade/operatorcloud.py +++ b/shade/operatorcloud.py @@ -1150,7 +1150,7 @@ class OperatorCloud(openstackcloud.OpenStackCloud): domain_id = dom['id'] with _utils.shade_exceptions( - "Failed to delete domain {id}".format(id=domain_id)): + "Failed to delete domain {id}".format(id=domain_id)): # Deleting a domain is expensive, so disabling it first increases # the changes of success domain = self.update_domain(domain_id, enabled=False) diff --git a/shade/tests/functional/test_endpoints.py b/shade/tests/functional/test_endpoints.py index e7346fe64..4ef648c47 100644 --- a/shade/tests/functional/test_endpoints.py +++ b/shade/tests/functional/test_endpoints.py @@ -103,8 +103,8 @@ class TestEndpoints(base.BaseFunctionalTestCase): self.assertIsNotNone(endpoints[0].get('id')) def test_update_endpoint(self): - if self.operator_cloud.cloud_config.get_api_version( - 'identity').startswith('2'): + ver = self.operator_cloud.cloud_config.get_api_version('identity') + if ver.startswith('2'): # NOTE(SamYaple): Update endpoint only works with v3 api self.assertRaises(OpenStackCloudUnavailableFeature, self.operator_cloud.update_endpoint, diff --git a/shade/tests/functional/test_object.py b/shade/tests/functional/test_object.py index b14834df3..a13b27ac3 100644 --- a/shade/tests/functional/test_object.py +++ b/shade/tests/functional/test_object.py @@ -66,8 +66,7 @@ class TestObject(base.BaseFunctionalTestCase): self.assertFalse(self.user_cloud.is_object_stale( container_name, name, fake_file.name - ) - ) + )) self.assertEqual( 'bar', self.user_cloud.get_object_metadata( container_name, name)['x-object-meta-foo'] @@ -131,8 +130,7 @@ class TestObject(base.BaseFunctionalTestCase): self.assertFalse(self.user_cloud.is_object_stale( container_name, name, fake_file.name - ) - ) + )) self.assertEqual( 'bar', self.user_cloud.get_object_metadata( container_name, name)['x-object-meta-foo'] diff --git a/shade/tests/functional/test_services.py b/shade/tests/functional/test_services.py index bd43deb67..729c6c7af 100644 --- a/shade/tests/functional/test_services.py +++ b/shade/tests/functional/test_services.py @@ -65,8 +65,8 @@ class TestServices(base.BaseFunctionalTestCase): self.assertIsNotNone(service.get('id')) def test_update_service(self): - if self.operator_cloud.cloud_config.get_api_version( - 'identity').startswith('2'): + ver = self.operator_cloud.cloud_config.get_api_version('identity') + if ver.startswith('2'): # NOTE(SamYaple): Update service only works with v3 api self.assertRaises(OpenStackCloudUnavailableFeature, self.operator_cloud.update_service, diff --git a/shade/tests/unit/test__utils.py b/shade/tests/unit/test__utils.py index 8296f471e..24da072f2 100644 --- a/shade/tests/unit/test__utils.py +++ b/shade/tests/unit/test__utils.py @@ -98,7 +98,7 @@ class TestUtils(base.TestCase): data, u'中文', {'other': { 'financial': {'status': 'rich'} - }}) + }}) self.assertEqual([el2], ret) def test__filter_list_filter(self): @@ -139,7 +139,7 @@ class TestUtils(base.TestCase): data, 'donald', {'other': { 'financial': {'status': 'rich'} - }}) + }}) self.assertEqual([el2, el3], ret) def test_safe_dict_min_ints(self): diff --git a/tox.ini b/tox.ini index 3a82b0c17..c6272e480 100644 --- a/tox.ini +++ b/tox.ini @@ -67,10 +67,9 @@ commands = python setup.py build_sphinx commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html [flake8] -# Infra does not follow hacking, nor the broken E12* things # The string of H ignores is because there are some useful checks # related to python3 compat. -ignore = E123,E125,E129,H3,H4,H5,H6,H7,H8,H103,H201,H238 +ignore = H3,H4,H5,H6,H7,H8,H103,H201,H238 show-source = True builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build