Use newer flake8 on python3.8 zuul systems

flake8 2.5.5 fails on ubuntu-focal zuul machines running python3.8
with the following error:
AttributeError: 'FlakesChecker' object has no attribute 'CONSTANT'

Fixed:
 E117 over-indented
 E741 ambiguous variable name
 F841 local variable is assigned to but never used

Per-Line-Suppressed:
 E402 module level import not at top of file
 F632 use ==/!= to compare constant literals

Global Suppress:
 W504 line break after binary operator
 W605 invalid escape sequence

The suppressed errors can be fixed by later submissions.

Change-Id: I2df3ece427f0c84ce16c1a82f4d9f0c9a5a6982b
Partial-Bug: 1895054
Signed-off-by: albailey <Al.Bailey@windriver.com>
This commit is contained in:
albailey 2020-11-16 13:09:11 -06:00
parent 454aa61326
commit 42a9cfa882
10 changed files with 35 additions and 32 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@ from fmclient.common import base
class EventLog(base.Resource):
def __repr__(self):
return "<EventLog %s>" % self._info
return "<EventLog %s>" % self._info
class EventLogManager(base.Manager):

View File

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

View File

@ -12,7 +12,7 @@ from fmclient.common import base
class EventSuppression(base.Resource):
def __repr__(self):
return "<EventSuppression %s>" % self._info
return "<EventSuppression %s>" % self._info
class EventSuppressionManager(base.Manager):

View File

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

View File

@ -1,4 +1,4 @@
hacking!=0.13.0,<0.14,>=0.12.0
hacking
bashate >= 0.2
mock
PyYAML >= 3.1.0

View File

@ -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 Dont put vim configuration in source files (off by default).
# H203 Use assertIs(Not)None to check for None (off by default).