Fix PEP H902 (Use the 'not in' operator)

Change-Id: Ic3dec990d2fe43dd8841aadb7b87e8f26c2d0338
This commit is contained in:
Angus Salkeld 2013-05-21 13:01:54 +10:00
parent 28c5c494f9
commit efe10076a2
6 changed files with 10 additions and 10 deletions

View File

@ -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] = {}

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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