Fixed flake8 and broken gate

Flake8 went broken recently, adopts correct calling method to avoid
regression and fixes broken rules.

Also removes openstack-tox-pep8 from gate which was a guaranteed
failure when triggered as pep8 was removed.

Change-Id: Iba03d3051952f461bb16299a6d32475b2be43041
This commit is contained in:
Sorin Sbarnea 2020-01-27 14:06:28 +00:00
parent 612dfbd118
commit b6611fd03a
6 changed files with 45 additions and 37 deletions

View File

@ -10,9 +10,12 @@ repos:
- id: check-executables-have-shebangs - id: check-executables-have-shebangs
- id: check-merge-conflict - id: check-merge-conflict
- id: debug-statements - id: debug-statements
- id: flake8
- id: check-yaml - id: check-yaml
files: .*\.(yaml|yml)$ files: .*\.(yaml|yml)$
- repo: https://gitlab.com/pycqa/flake8
rev: '3.7.9'
hooks:
- id: flake8
# commented to allow progressive adoption in smaller patches # commented to allow progressive adoption in smaller patches
# - repo: https://github.com/adrienverge/yamllint.git # - repo: https://github.com/adrienverge/yamllint.git
# rev: v1.18.0 # rev: v1.18.0

View File

@ -337,28 +337,32 @@ if __name__ == '__main__':
default_output_file = '{}.out'.format(os.path.basename(__file__)) default_output_file = '{}.out'.format(os.path.basename(__file__))
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter, formatter_class=argparse.RawTextHelpFormatter,
description='Get a dictionary of releases from a release ' description='Get a dictionary of releases from a release '
'and a featureset file.') 'and a featureset file.')
parser.add_argument('--stable-release', parser.add_argument(
choices=RELEASES, '--stable-release',
required=True, choices=RELEASES,
help='Release that the change being tested is from.\n' required=True,
'All other releases are calculated from this\n' help='Release that the change being tested is from.\n'
'basis.') 'All other releases are calculated from this\n'
parser.add_argument('--featureset-file', 'basis.')
required=True, parser.add_argument(
help='Featureset file which will be introspected to\n' '--featureset-file',
'infer what type of upgrade is being performed\n' required=True,
'(if any).') help='Featureset file which will be introspected to\n'
parser.add_argument('--output-file', default=default_output_file, 'infer what type of upgrade is being performed\n'
help='Output file containing dictionary of releases\n' '(if any).')
'for the provided featureset and release.\n' parser.add_argument(
'(default: %(default)s)') '--output-file', default=default_output_file,
parser.add_argument('--log-file', default=default_log_file, help='Output file containing dictionary of releases\n'
help='log file to print debug information from\n' 'for the provided featureset and release.\n'
'running the script.\n' '(default: %(default)s)')
'(default: %(default)s)') parser.add_argument(
'--log-file', default=default_log_file,
help='log file to print debug information from\n'
'running the script.\n'
'(default: %(default)s)')
parser.add_argument('--upgrade-from', action='store_false', parser.add_argument('--upgrade-from', action='store_false',
help='Upgrade FROM the change under test instead\n' help='Upgrade FROM the change under test instead\n'
'of the default of upgrading TO the change\n' 'of the default of upgrading TO the change\n'

View File

@ -173,9 +173,9 @@ def gen_html(data, html_file, table_file, stats_hours, job_names, options):
fp.write("</tr>") fp.write("</tr>")
fp.write("<table>") fp.write("<table>")
fp.write("<p>Query parameters:</p>") fp.write("<p>Query parameters:</p>")
fp.write("Branch: "+options.b+"<br/>") fp.write("Branch: " + options.b + "<br/>")
fp.write("Status: "+options.s+"<br/>") fp.write("Status: " + options.s + "<br/>")
fp.write("Limit: "+options.l) fp.write("Limit: " + options.l)
total = passed_jobs + partial_jobs + failed_jobs total = passed_jobs + partial_jobs + failed_jobs
fp.write("<p>Overall</p>") fp.write("<p>Overall</p>")
@ -183,17 +183,17 @@ def gen_html(data, html_file, table_file, stats_hours, job_names, options):
passed_jobs, passed_jobs,
total, total,
float(passed_jobs) / float(total) * 100 float(passed_jobs) / float(total) * 100
)) ))
fp.write("Partial Failures: %d/%d (%d %%)<br/>" % ( fp.write("Partial Failures: %d/%d (%d %%)<br/>" % (
partial_jobs, partial_jobs,
total, total,
float(partial_jobs) / float(total) * 100 float(partial_jobs) / float(total) * 100
)) ))
fp.write("Complete Failures: %d/%d (%d %%)<br/>" % ( fp.write("Complete Failures: %d/%d (%d %%)<br/>" % (
failed_jobs, failed_jobs,
total, total,
float(failed_jobs) / float(total) * 100 float(failed_jobs) / float(total) * 100
)) ))
fp.close() fp.close()
@ -244,9 +244,8 @@ def main(args=sys.argv[1:]):
'patchset': patchset, 'patchset': patchset,
'project': re.sub(r'.*/', '', review['project']), 'project': re.sub(r'.*/', '', review['project']),
'branch': review['branch'], 'branch': review['branch'],
}) })
results[key].setdefault( results[key].setdefault('ci_results', {}).update(ci_results)
'ci_results', {}).update(ci_results)
gen_html(results, opts.o, "%s-table" % opts.o, 24, job_names, opts) gen_html(results, opts.o, "%s-table" % opts.o, 24, job_names, opts)

View File

@ -33,3 +33,8 @@ warnerrors = False
[tool:pytest] [tool:pytest]
norecursedirs = .git .tox dist norecursedirs = .git .tox dist
log_cli = true log_cli = true
[flake8]
# based on https://github.com/psf/black
ignore = E203,E501,W503,W504,D
# "D" added because we do not use docstrings checks, yet

View File

@ -146,7 +146,7 @@ def main(args=sys.argv[1:]):
'connect to.') 'connect to.')
parser.add_argument('--jobnum', '-n', default=uuid.uuid4().hex, parser.add_argument('--jobnum', '-n', default=uuid.uuid4().hex,
help='A unique identifier identifing this job.') help='A unique identifier identifing this job.')
parser.add_argument('--timeout', '-t', default='10800', parser.add_argument('--timeout', '-t', default='10800',
help='Set a timeout, after which the command will ' help='Set a timeout, after which the command will '
'be killed.') 'be killed.')
parser.add_argument('--envsize', default="2", parser.add_argument('--envsize', default="2",
@ -177,7 +177,7 @@ def main(args=sys.argv[1:]):
parser.add_argument('--extra-nodes', default='0', parser.add_argument('--extra-nodes', default='0',
help='Number of extra undercloud-like nodes to ' help='Number of extra undercloud-like nodes to '
'request') 'request')
parser.add_argument('--debug', '-d', action='store_true', parser.add_argument('--debug', '-d', action='store_true',
help='Set to debug mode.') help='Set to debug mode.')
opts = parser.parse_args(args) opts = parser.parse_args(args)
if opts.debug: if opts.debug:

View File

@ -71,9 +71,6 @@
- openstack-tox-py35: - openstack-tox-py35:
files: files:
- ^scripts/emit_releases_file/.*$ - ^scripts/emit_releases_file/.*$
- openstack-tox-pep8:
files:
- ^scripts/emit_releases_file/.*$
- tripleo-buildimage-overcloud-full-centos-7: - tripleo-buildimage-overcloud-full-centos-7:
files: *build_images_files files: *build_images_files
- tripleo-ci-centos-7-standalone-upgrade-train: - tripleo-ci-centos-7-standalone-upgrade-train: