From 8e4af6aa2b41535f0a4e09aba23b816dd66d5a8a Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Thu, 12 Apr 2018 09:12:46 +0300 Subject: [PATCH] Fix pep8 new warnings A recent change in pep/pycodingchecks introduced new warnings as part of the pep8 target that causes pep8 to fail now. This patch fixes code that issued warnings W503,E731,E266,E402 Change-Id: Ib0ad4d722eb6ce322d7f72a5bdaf38b6cb85937e --- vmware_nsxlib/tests/unit/v3/test_ns_group_manager.py | 4 ++-- vmware_nsxlib/tests/unit/v3/test_policy_resources.py | 10 ++++++---- vmware_nsxlib/v3/cluster.py | 4 ++-- vmware_nsxlib/v3/security.py | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/vmware_nsxlib/tests/unit/v3/test_ns_group_manager.py b/vmware_nsxlib/tests/unit/v3/test_ns_group_manager.py index c3f10a56..936ed257 100644 --- a/vmware_nsxlib/tests/unit/v3/test_ns_group_manager.py +++ b/vmware_nsxlib/tests/unit/v3/test_ns_group_manager.py @@ -180,7 +180,7 @@ class TestNSGroupManager(nsxlib_testcase.NsxLibTestCase): cont_manager = ns_group_manager.NSGroupManager(self.nsxlib, size) # We expect that the first suggested index is 2 expected_suggested_groups = NSG_IDS[2:5] + NSG_IDS[:2] - suggest_group = lambda: cont_manager._suggest_nested_group('fake-id') with mock.patch.object(cont_manager, '_hash_uuid', return_value=7): - for i, suggested in enumerate(suggest_group()): + for i, suggested in enumerate( + cont_manager._suggest_nested_group('fake-id')): self.assertEqual(expected_suggested_groups[i], suggested) diff --git a/vmware_nsxlib/tests/unit/v3/test_policy_resources.py b/vmware_nsxlib/tests/unit/v3/test_policy_resources.py index ae510055..49191ee5 100644 --- a/vmware_nsxlib/tests/unit/v3/test_policy_resources.py +++ b/vmware_nsxlib/tests/unit/v3/test_policy_resources.py @@ -319,10 +319,12 @@ class TestPolicyGroup(NsxPolicyLibTestCase): 'key': policy_constants.CONDITION_KEY_TAG, 'value': 'abc', 'operator': policy_constants.CONDITION_OP_EQUALS} - with mock.patch.object(self.policy_api, "get", - return_value={'expression': [old_cond]}) as get_call,\ - mock.patch.object(self.policy_api, - "create_or_update") as update_call: + with mock.patch.object( + self.policy_api, "get", + return_value={'expression': [old_cond]}) as get_call,\ + mock.patch.object( + self.policy_api, + "create_or_update") as update_call: self.resourceApi.update_condition(domain_id, id, cond_val=None, tenant=TEST_TENANT) diff --git a/vmware_nsxlib/v3/cluster.py b/vmware_nsxlib/v3/cluster.py index 063ef4cf..098ae37f 100644 --- a/vmware_nsxlib/v3/cluster.py +++ b/vmware_nsxlib/v3/cluster.py @@ -425,8 +425,8 @@ class ClusteredAPI(object): conns.spawn(self._validate, endpoint) eventlet.sleep(0) while conns.running(): - if (self.health == ClusterHealth.GREEN - or self.health == ClusterHealth.ORANGE): + if (self.health == ClusterHealth.GREEN or + self.health == ClusterHealth.ORANGE): # only wait for 1 or more endpoints to reduce init time break eventlet.sleep(0.5) diff --git a/vmware_nsxlib/v3/security.py b/vmware_nsxlib/v3/security.py index aa5a5515..9bd4aca3 100644 --- a/vmware_nsxlib/v3/security.py +++ b/vmware_nsxlib/v3/security.py @@ -252,8 +252,8 @@ class NsxLibFirewallSection(utils.NsxLibApiBase): self._create_with_retry(resource, body) def remove_member_from_fw_exclude_list(self, target_id, target_type): - resource = ('firewall/excludelist?action=remove_member&object_id=' - + target_id) + resource = ('firewall/excludelist?action=remove_member&object_id=' + + target_id) self._create_with_retry(resource) def get_excludelist(self):