From efe10076a224c9ac11e9fc11788fd1a4bd0d9dfc Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Tue, 21 May 2013 13:01:54 +1000 Subject: [PATCH] Fix PEP H902 (Use the 'not in' operator) Change-Id: Ic3dec990d2fe43dd8841aadb7b87e8f26c2d0338 --- heat/common/template_format.py | 4 ++-- heat/common/wsgi.py | 4 ++-- heat/engine/parser.py | 4 ++-- heat/engine/resources/loadbalancer.py | 2 +- heat/engine/watchrule.py | 4 ++-- tox.ini | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/heat/common/template_format.py b/heat/common/template_format.py index 5430d94f..020efc7c 100644 --- a/heat/common/template_format.py +++ b/heat/common/template_format.py @@ -57,12 +57,12 @@ def default_for_missing(tpl, version_param, versions): This is currently only applied to YAML templates. ''' # if version is missing, implicitly use the lastest one - if not version_param in tpl: + if version_param not in tpl: tpl[version_param] = versions[-1] # create empty placeholders for any of the main dict sections for param in (u'Parameters', u'Mappings', u'Resources', u'Outputs'): - if not param in tpl: + if param not in tpl: tpl[param] = {} diff --git a/heat/common/wsgi.py b/heat/common/wsgi.py index b5788df2..fcfa2742 100644 --- a/heat/common/wsgi.py +++ b/heat/common/wsgi.py @@ -80,7 +80,7 @@ class WritableLogger(object): def get_bind_addr(conf, default_port=None): """Return the host and port to bind to.""" for opt in bind_opts: - if not opt.name in conf: + if opt.name not in conf: conf.register_opt(opt) return (conf.bind_host, conf.bind_port or default_port) @@ -415,7 +415,7 @@ class Request(webob.Request): def get_content_type(self, allowed_content_types): """Determine content type of the request body.""" - if not "Content-Type" in self.headers: + if "Content-Type" not in self.headers: raise exception.InvalidContentType(content_type=None) content_type = self.content_type diff --git a/heat/engine/parser.py b/heat/engine/parser.py index a5cfd64e..fc30a4e2 100644 --- a/heat/engine/parser.py +++ b/heat/engine/parser.py @@ -349,7 +349,7 @@ class Stack(object): try: # First delete any resources which are not in newstack for res in reversed(self): - if not res.name in newstack.keys(): + if res.name not in newstack.keys(): logger.debug("resource %s not found in updated stack" % res.name + " definition, deleting") try: @@ -366,7 +366,7 @@ class Stack(object): # Then create any which are defined in newstack but not self for res in newstack: - if not res.name in self.keys(): + if res.name not in self.keys(): logger.debug("resource %s not found in current stack" % res.name + " definition, adding") res.stack = self diff --git a/heat/engine/resources/loadbalancer.py b/heat/engine/resources/loadbalancer.py index 719fe895..aaf9e985 100644 --- a/heat/engine/resources/loadbalancer.py +++ b/heat/engine/resources/loadbalancer.py @@ -381,7 +381,7 @@ class LoadBalancer(stack_resource.StackResource): 'SourceSecurityGroupName', 'SourceSecurityGroupOwnerAlias') - if not key in allow: + if key not in allow: raise exception.InvalidTemplateAttribute(resource=self.name, key=key) diff --git a/heat/engine/watchrule.py b/heat/engine/watchrule.py index c55df70e..26b6aa21 100644 --- a/heat/engine/watchrule.py +++ b/heat/engine/watchrule.py @@ -230,7 +230,7 @@ class WatchRule(object): logger.info('WATCH: stack:%s, watch_name:%s %s', self.stack_id, self.name, new_state) actions = [] - if not self.ACTION_MAP[new_state] in self.rule: + if self.ACTION_MAP[new_state] not in self.rule: logger.info('no action for new state %s', new_state) else: @@ -246,7 +246,7 @@ class WatchRule(object): return actions def create_watch_data(self, data): - if not self.rule['MetricName'] in data: + if self.rule['MetricName'] not in data: # Our simplified cloudwatch implementation only expects a single # Metric associated with each alarm, but some cfn-push-stats # options, e.g --haproxy try to push multiple metrics when we diff --git a/tox.ini b/tox.ini index 1859a2bf..4240ad26 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ commands = python setup.py testr --coverage [flake8] -ignore = H302,H303,H304,H403,H404,F403,F841,H306,H902,H201,H101,H703,H702 +ignore = H302,H303,H304,H403,H404,F403,F841,H306,H201,H101,H703,H702 show-source = true builtins = _ exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools,build -- 2.45.2