diff --git a/fm-api/fm_api/fm_api.py b/fm-api/fm_api/fm_api.py index 0da0b7b6..617aefc3 100755 --- a/fm-api/fm_api/fm_api.py +++ b/fm-api/fm_api/fm_api.py @@ -140,17 +140,17 @@ class FaultAPIsBase(object): """ Validate the attributes only applies to Telco specific attributes""" if data.alarm_state not in constants.ALARM_STATE: - raise ClientException("Invalid Fault State: %s" % - data.alarm_state) + raise ClientException("Invalid Fault State: %s" % + data.alarm_state) if data.severity not in constants.ALARM_SEVERITY: - raise ClientException("Invalid Fault Severity: %s" % - data.severity) + raise ClientException("Invalid Fault Severity: %s" % + data.severity) if data.alarm_type not in constants.ALARM_TYPE: - raise ClientException("Invalid Fault Type: %s" % - data.alarm_type) + raise ClientException("Invalid Fault Type: %s" % + data.alarm_type) if data.probable_cause not in constants.ALARM_PROBABLE_CAUSE: - raise ClientException("Invalid Fault Probable Cause: %s" % - data.probable_cause) + raise ClientException("Invalid Fault Probable Cause: %s" % + data.probable_cause) @staticmethod def alarm_allowed(alarm_severity, threshold): diff --git a/fm-rest-api/fm/fm/cmd/dbsync.py b/fm-rest-api/fm/fm/cmd/dbsync.py index ab27e0c8..3ffab68e 100644 --- a/fm-rest-api/fm/fm/cmd/dbsync.py +++ b/fm-rest-api/fm/fm/cmd/dbsync.py @@ -8,7 +8,7 @@ import sys from oslo_config import cfg cfg.CONF(sys.argv[1:], project='fm') -from fm.db import migration +from fm.db import migration # noqa: E402 CONF = cfg.CONF diff --git a/python-fmclient/fmclient/fmclient/common/http.py b/python-fmclient/fmclient/fmclient/common/http.py index cf9d4acd..e7f451d1 100644 --- a/python-fmclient/fmclient/fmclient/common/http.py +++ b/python-fmclient/fmclient/fmclient/common/http.py @@ -154,7 +154,7 @@ class HTTPClient(_BaseHTTPClient): if kwargs.get('insecure', False) is True: self.session.verify = False else: - if kwargs.get('cacert', None) is not '': + if kwargs.get('cacert', None) is not '': # noqa: F632 self.session.verify = kwargs.get('cacert', True) self.session.cert = (kwargs.get('cert_file'), diff --git a/python-fmclient/fmclient/fmclient/shell.py b/python-fmclient/fmclient/fmclient/shell.py index 97aa5e71..52e2071b 100644 --- a/python-fmclient/fmclient/fmclient/shell.py +++ b/python-fmclient/fmclient/fmclient/shell.py @@ -315,7 +315,7 @@ def main(): print('caught: %r, aborting' % (e), file=sys.stderr) sys.exit(0) - except IOError as e: + except IOError: sys.exit(0) except Exception as e: diff --git a/python-fmclient/fmclient/fmclient/v1/event_log.py b/python-fmclient/fmclient/fmclient/v1/event_log.py index 67dac78f..89fd3363 100644 --- a/python-fmclient/fmclient/fmclient/v1/event_log.py +++ b/python-fmclient/fmclient/fmclient/v1/event_log.py @@ -11,7 +11,7 @@ from fmclient.common import base class EventLog(base.Resource): def __repr__(self): - return "" % self._info + return "" % self._info class EventLogManager(base.Manager): diff --git a/python-fmclient/fmclient/fmclient/v1/event_log_shell.py b/python-fmclient/fmclient/fmclient/v1/event_log_shell.py index ce2db745..db960eb5 100644 --- a/python-fmclient/fmclient/fmclient/v1/event_log_shell.py +++ b/python-fmclient/fmclient/fmclient/v1/event_log_shell.py @@ -79,8 +79,8 @@ def do_event_list(cc, args={}): logs = cc.event_log.list(q=queryAsArray, limit=args.limit, alarms=alarms, logs=logs, include_suppress=include_suppress) - for l in logs: - utils.normalize_field_data(l, ['entity_instance_id', 'reason_text']) + for lg in logs: + utils.normalize_field_data(lg, ['entity_instance_id', 'reason_text']) # omit action initially to keep output width sane # (can switch over to vertical formatting when available from CLIFF) diff --git a/python-fmclient/fmclient/fmclient/v1/event_suppression.py b/python-fmclient/fmclient/fmclient/v1/event_suppression.py index f3e65a6c..0ba0a86b 100644 --- a/python-fmclient/fmclient/fmclient/v1/event_suppression.py +++ b/python-fmclient/fmclient/fmclient/v1/event_suppression.py @@ -12,7 +12,7 @@ from fmclient.common import base class EventSuppression(base.Resource): def __repr__(self): - return "" % self._info + return "" % self._info class EventSuppressionManager(base.Manager): diff --git a/python-fmclient/fmclient/fmclient/v1/event_suppression_shell.py b/python-fmclient/fmclient/fmclient/v1/event_suppression_shell.py index 522ca7ec..7064dc17 100644 --- a/python-fmclient/fmclient/fmclient/v1/event_suppression_shell.py +++ b/python-fmclient/fmclient/fmclient/v1/event_suppression_shell.py @@ -82,24 +82,24 @@ def print_event_suppression_list(cc, no_paging, includeUUID): def event_suppression_update(cc, data, suppress=False): - event_suppression_list = _event_suppression_list(cc, include_unsuppressed=True) + event_suppression_list = _event_suppression_list(cc, include_unsuppressed=True) - alarm_id_list = [] - for alarm_id in data['alarm_id'].split(',') or []: - alarm_id_list.append(alarm_id) + alarm_id_list = [] + for alarm_id in data['alarm_id'].split(',') or []: + alarm_id_list.append(alarm_id) - if suppress: - patch_value = 'suppressed' - else: - patch_value = 'unsuppressed' + if suppress: + patch_value = 'suppressed' + else: + patch_value = 'unsuppressed' - patch = [] - for event_id in event_suppression_list: - if event_id.alarm_id in alarm_id_list: - print("Alarm ID: {} {}.".format(event_id.alarm_id, patch_value)) - uuid = event_id.uuid - patch.append(dict(path='/' + 'suppression_status', value=patch_value, op='replace')) - cc.event_suppression.update(uuid, patch) + patch = [] + for event_id in event_suppression_list: + if event_id.alarm_id in alarm_id_list: + print("Alarm ID: {} {}.".format(event_id.alarm_id, patch_value)) + uuid = event_id.uuid + patch.append(dict(path='/' + 'suppression_status', value=patch_value, op='replace')) + cc.event_suppression.update(uuid, patch) @utils.arg('--include-unsuppressed', action='store_true', diff --git a/test-requirements.txt b/test-requirements.txt index f88cf028..cbbb8bfc 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,4 @@ -hacking!=0.13.0,<0.14,>=0.12.0 +hacking bashate >= 0.2 mock PyYAML >= 3.1.0 diff --git a/tox.ini b/tox.ini index 5c8cf305..32bf0038 100644 --- a/tox.ini +++ b/tox.ini @@ -88,11 +88,14 @@ commands = # H405 multi line docstring summary not separated with an empty line # H702 Argument to ... must be a string # H903 Windows style line endings not allowed in code +# W504 line break after binary operator +# W605 invalid escape sequence # E123, E125 skipped as they are invalid PEP-8. # E501 skipped because some of the code files include templates # that end up quite wide show-source = True -ignore = H102,H104,H105,H301,H306,H401,H403,H404,H405,H702,H903,E123,E125,E501 +ignore = H102,H104,H105,H301,H306,H401,H403,H404,H405,H702,H903, + W504,W605,E123,E125,E501 exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-* # TODO: H106 Don’t put vim configuration in source files (off by default). # H203 Use assertIs(Not)None to check for None (off by default).