From 3eb9937cad6610c8d8957a7700f06853e7dea914 Mon Sep 17 00:00:00 2001 From: Stefan Caraiman Date: Mon, 27 Jun 2016 13:05:46 +0300 Subject: [PATCH] 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 917ecfea4ccb7815960376ed22d558724b3dcecf) --- monascaclient/common/utils.py | 4 +-- monascaclient/v2_0/shell.py | 48 +++++++++++++++++------------------ test-requirements.txt | 2 +- tox.ini | 3 +-- 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/monascaclient/common/utils.py b/monascaclient/common/utils.py index 526745c..c4fac77 100644 --- a/monascaclient/common/utils.py +++ b/monascaclient/common/utils.py @@ -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) diff --git a/monascaclient/v2_0/shell.py b/monascaclient/v2_0/shell.py index 1edca86..a8f3333 100644 --- a/monascaclient/v2_0/shell.py +++ b/monascaclient/v2_0/shell.py @@ -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 diff --git a/test-requirements.txt b/test-requirements.txt index ddc9e71..c06872b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 diff --git a/tox.ini b/tox.ini index accf64c..5a03017 100644 --- a/tox.ini +++ b/tox.ini @@ -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