Fixes H904: wrapping using parantheses

Enabled H904 on tox and changes made in relevant files to adhere to the
H904 guideline.

Change-Id: Ib2c1d64c176843ceca6dec147d5985a8f9a9fc96
(cherry picked from commit 917ecfea4c)
This commit is contained in:
Stefan Caraiman 2016-06-27 13:05:46 +03:00 committed by Witold Bedyk
parent 631f70555f
commit 3eb9937cad
4 changed files with 28 additions and 29 deletions

View File

@ -118,8 +118,8 @@ def find_resource(manager, name_or_id):
try:
return manager.find(name=name_or_id)
except exc.NotFound:
msg = "No %s with a name or ID of '%s' exists." % \
(manager.resource_class.__name__.lower(), name_or_id)
msg = ("No %s with a name or ID of '%s' exists." %
(manager.resource_class.__name__.lower(), name_or_id))
raise exc.CommandError(msg)

View File

@ -414,8 +414,8 @@ def do_metric_statistics(mc, args):
statlist = args.statistics.split(',')
for stat in statlist:
if stat.upper() not in statistic_types:
errmsg = 'Invalid type, not one of [' + \
', '.join(statistic_types) + ']'
errmsg = ('Invalid type, not one of [' +
', '.join(statistic_types) + ']')
print(errmsg)
return
fields = {}
@ -508,8 +508,8 @@ def _validate_notification_period(period, notification_type):
def do_notification_create(mc, args):
'''Create notification.'''
if args.type.upper() not in notification_types:
errmsg = 'Invalid type, not one of [' + \
', '.join(notification_types) + ']'
errmsg = ('Invalid type, not one of [' +
', '.join(notification_types) + ']')
print(errmsg)
return
fields = {}
@ -649,8 +649,8 @@ def do_notification_update(mc, args):
fields['notification_id'] = args.id
fields['name'] = args.name
if args.type.upper() not in notification_types:
errmsg = 'Invalid type, not one of [' + \
', '.join(state_types) + ']'
errmsg = ('Invalid type, not one of [' +
', '.join(state_types) + ']')
print(errmsg)
return
fields['type'] = args.type
@ -686,8 +686,8 @@ def do_notification_patch(mc, args):
fields['name'] = args.name
if args.type:
if args.type.upper() not in notification_types:
errmsg = 'Invalid type, not one of [' + \
', '.join(notification_types) + ']'
errmsg = ('Invalid type, not one of [' +
', '.join(notification_types) + ']')
print(errmsg)
return
fields['type'] = args.type
@ -710,8 +710,8 @@ def do_notification_patch(mc, args):
def _validate_severity(severity):
if severity.upper() not in severity_types:
errmsg = 'Invalid severity, not one of [' + \
', '.join(severity_types) + ']'
errmsg = ('Invalid severity, not one of [' +
', '.join(severity_types) + ']')
print(errmsg)
return False
return True
@ -935,8 +935,8 @@ def do_alarm_definition_update(mc, args):
fields['ok_actions'] = _arg_split_patch_update(args.ok_actions)
fields['undetermined_actions'] = _arg_split_patch_update(args.undetermined_actions)
if args.actions_enabled not in enabled_types:
errmsg = 'Invalid value, not one of [' + \
', '.join(enabled_types) + ']'
errmsg = ('Invalid value, not one of [' +
', '.join(enabled_types) + ']')
print(errmsg)
return
fields['actions_enabled'] = args.actions_enabled in ['true', 'True']
@ -996,8 +996,8 @@ def do_alarm_definition_patch(mc, args):
fields['undetermined_actions'] = _arg_split_patch_update(args.undetermined_actions, patch=True)
if args.actions_enabled:
if args.actions_enabled not in enabled_types:
errmsg = 'Invalid value, not one of [' + \
', '.join(enabled_types) + ']'
errmsg = ('Invalid value, not one of [' +
', '.join(enabled_types) + ']')
print(errmsg)
return
fields['actions_enabled'] = args.actions_enabled in ['true', 'True']
@ -1057,8 +1057,8 @@ def do_alarm_list(mc, args):
fields['metric_dimensions'] = utils.format_dimensions_query(args.metric_dimensions)
if args.state:
if args.state.upper() not in state_types:
errmsg = 'Invalid state, not one of [' + \
', '.join(state_types) + ']'
errmsg = ('Invalid state, not one of [' +
', '.join(state_types) + ']')
print(errmsg)
return
fields['state'] = args.state
@ -1165,8 +1165,8 @@ def do_alarm_update(mc, args):
fields = {}
fields['alarm_id'] = args.id
if args.state.upper() not in state_types:
errmsg = 'Invalid state, not one of [' + \
', '.join(state_types) + ']'
errmsg = ('Invalid state, not one of [' +
', '.join(state_types) + ']')
print(errmsg)
return
fields['state'] = args.state
@ -1196,8 +1196,8 @@ def do_alarm_patch(mc, args):
fields['alarm_id'] = args.id
if args.state:
if args.state.upper() not in state_types:
errmsg = 'Invalid state, not one of [' + \
', '.join(state_types) + ']'
errmsg = ('Invalid state, not one of [' +
', '.join(state_types) + ']')
print(errmsg)
return
fields['state'] = args.state
@ -1296,8 +1296,8 @@ def do_alarm_count(mc, args):
fields['metric_dimensions'] = utils.format_parameters(args.metric_dimensions)
if args.state:
if args.state.upper() not in state_types:
errmsg = 'Invalid state, not one of [' + \
', '.join(state_types) + ']'
errmsg = ('Invalid state, not one of [' +
', '.join(state_types) + ']')
print(errmsg)
return
fields['state'] = args.state
@ -1312,8 +1312,8 @@ def do_alarm_count(mc, args):
if args.group_by:
group_by = args.group_by.split(',')
if not set(group_by).issubset(set(group_by_types)):
errmsg = 'Invalid group-by, one or more values not in [' + \
','.join(group_by_types) + ']'
errmsg = ('Invalid group-by, one or more values not in [' +
','.join(group_by_types) + ']')
print(errmsg)
return
fields['group_by'] = args.group_by

View File

@ -4,7 +4,7 @@
coverage>=3.6 # Apache-2.0
discover # BSD
fixtures<2.0,>=1.3.1 # Apache-2.0/BSD
hacking<0.10,>=0.9.2
hacking>=0.11.0,<0.12 # Apache-2.0
mock>=1.2 # BSD
mox3>=0.7.0 # Apache-2.0
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 # BSD

View File

@ -32,7 +32,6 @@ show-source = True
max-line-length = 120
# H302 Do not import objects, only modules
# H803 git commit title should not end with period
# H904 Wrap long lines in parentheses instead of a backslash
ignore = H302,H803,H904
ignore = H302,H803
builtins = _
exclude=.venv,.git,.tox,dist,client_api_example.py,*openstack/common*,*lib/python*,*egg,build