From 51e604f87eadf7f14b37bcc6350900892ece8eca Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Wed, 16 Jul 2014 02:01:15 -0700 Subject: [PATCH] Cleanup and gate on hacking E713 rule This fixes the offending instances of the rule and removes it from the ignore list in tox.ini so that we can gate on the E713 rule. Change-Id: I1f9ef23a8569252b5b6fa660d0d200b1702056d0 --- nova/api/openstack/compute/plugins/v3/servers.py | 2 +- nova/api/openstack/compute/servers.py | 2 +- nova/exception.py | 2 +- nova/scheduler/filters/affinity_filter.py | 2 +- nova/utils.py | 4 ++-- nova/virt/vmwareapi/vm_util.py | 2 +- tox.ini | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nova/api/openstack/compute/plugins/v3/servers.py b/nova/api/openstack/compute/plugins/v3/servers.py index eb34c1880482..60ab3b8ad87b 100644 --- a/nova/api/openstack/compute/plugins/v3/servers.py +++ b/nova/api/openstack/compute/plugins/v3/servers.py @@ -239,7 +239,7 @@ class ServersController(wsgi.Controller): # disabled. Note that the tenant_id parameter is filtered out # by remove_invalid_options above unless the requestor is an # admin. - if 'tenant_id' in search_opts and not 'all_tenants' in search_opts: + if 'tenant_id' in search_opts and 'all_tenants' not in search_opts: # We do not need to add the all_tenants flag if the tenant # id associated with the token is the tenant id # specified. This is done so a request that does not need diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 48d99d1a2dc4..d931d28be226 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -1266,7 +1266,7 @@ class Controller(wsgi.Controller): @wsgi.action('changePassword') def _action_change_password(self, req, id, body): context = req.environ['nova.context'] - if (not 'changePassword' in body + if ('changePassword' not in body or 'adminPass' not in body['changePassword']): msg = _("No adminPass was specified") raise exc.HTTPBadRequest(explanation=msg) diff --git a/nova/exception.py b/nova/exception.py index e30432ae58a7..8eff489bb297 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -55,7 +55,7 @@ class ConvertedException(webob.exc.WSGIHTTPException): def _cleanse_dict(original): """Strip all admin_password, new_pass, rescue_pass keys from a dict.""" - return dict((k, v) for k, v in original.iteritems() if not "_pass" in k) + return dict((k, v) for k, v in original.iteritems() if "_pass" not in k) def wrap_exception(notifier=None, get_notifier=None): diff --git a/nova/scheduler/filters/affinity_filter.py b/nova/scheduler/filters/affinity_filter.py index a1c0ae2445c5..ba96832e0bdf 100644 --- a/nova/scheduler/filters/affinity_filter.py +++ b/nova/scheduler/filters/affinity_filter.py @@ -117,7 +117,7 @@ class _GroupAntiAffinityFilter(AffinityFilter): "in %(configured)s", {'host': host_state.host, 'configured': group_hosts}) if group_hosts: - return not host_state.host in group_hosts + return host_state.host not in group_hosts # No groups configured return True diff --git a/nova/utils.py b/nova/utils.py index bf5a522926aa..823a7a9dec0f 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -158,14 +158,14 @@ def _get_root_helper(): def execute(*cmd, **kwargs): """Convenience wrapper around oslo's execute() method.""" - if 'run_as_root' in kwargs and not 'root_helper' in kwargs: + if 'run_as_root' in kwargs and 'root_helper' not in kwargs: kwargs['root_helper'] = _get_root_helper() return processutils.execute(*cmd, **kwargs) def trycmd(*args, **kwargs): """Convenience wrapper around oslo's trycmd() method.""" - if 'run_as_root' in kwargs and not 'root_helper' in kwargs: + if 'run_as_root' in kwargs and 'root_helper' not in kwargs: kwargs['root_helper'] = _get_root_helper() return processutils.trycmd(*args, **kwargs) diff --git a/nova/virt/vmwareapi/vm_util.py b/nova/virt/vmwareapi/vm_util.py index cc497673cf92..cbeea889e54b 100644 --- a/nova/virt/vmwareapi/vm_util.py +++ b/nova/virt/vmwareapi/vm_util.py @@ -377,7 +377,7 @@ def get_vmdk_path_and_adapter_type(hardware_devices, uuid=None): def _find_controller_slot(controller_keys, taken, max_unit_number): for controller_key in controller_keys: for unit_number in range(max_unit_number): - if not unit_number in taken.get(controller_key, []): + if unit_number not in taken.get(controller_key, []): return controller_key, unit_number diff --git a/tox.ini b/tox.ini index 926e8b1ec37c..daeebd56d2b9 100644 --- a/tox.ini +++ b/tox.ini @@ -57,11 +57,11 @@ sitepackages = False # H803 skipped on purpose per list discussion. # E125 is deliberately excluded. See https://github.com/jcrocholl/pep8/issues/126 # The rest of the ignores are TODOs -# New from hacking 0.9: E129, E131, E265, E713, H407, H405, H904 +# New from hacking 0.9: E129, E131, E265, H407, H405, H904 # Stricter in hacking 0.9: F402 # E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301 -ignore = E121,E122,E123,E124,E125,E129,E126,E127,E128,E131,E251,E265,E711,E712,E713,F402,H405,H803,H904 +ignore = E121,E122,E123,E124,E125,E129,E126,E127,E128,E131,E251,E265,E711,E712,F402,H405,H803,H904 exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools [hacking]