From 7ff7e09392e78880738c068e107373806d4138f3 Mon Sep 17 00:00:00 2001 From: Michel Thebeau Date: Mon, 24 Jul 2023 10:46:00 -0400 Subject: [PATCH] libvirt: add pep8/flake8 to tox job Using config/sysinv/sysinv/sysinv as example of setup for pep8/flake8. Fix reported errors for config.py. Story: 2010816 Task: 48450 Change-Id: Ia0e511fd827b5d697a6b41b7064d13ab64efb779 Signed-off-by: Michel Thebeau --- .zuul.yaml | 9 +++++++++ libvirt/config.py | 5 ++++- requirements/test-requirements.txt | 1 + tox.ini | 11 ++++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 3891eb2..4fee3b4 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -7,11 +7,13 @@ - openstack-tox-linters - openstack-tox-pylint - tox-unittests + - tox-flake8 gate: jobs: - openstack-tox-linters - openstack-tox-pylint - tox-unittests + - tox-flake8 - job: name: tox-unittests @@ -19,3 +21,10 @@ description: Run unit tests vars: tox_envlist: unittests + +- job: + name: tox-flake8 + parent: tox + description: Run pep8/flake8 + vars: + tox_envlist: flake8 diff --git a/libvirt/config.py b/libvirt/config.py index 1191433..0af8006 100755 --- a/libvirt/config.py +++ b/libvirt/config.py @@ -3,9 +3,11 @@ import sys import yaml + def print_help(): print("./config.py ", - file=sys.stderr) + file=sys.stderr) + def readvalue(config_file, key): @@ -21,6 +23,7 @@ def readvalue(config_file, key): except KeyError as e: print('KeyError: %s' % e, file=sys.stderr) + if __name__ == "__main__": args = sys.argv[1:] diff --git a/requirements/test-requirements.txt b/requirements/test-requirements.txt index c4ea274..3e0422d 100644 --- a/requirements/test-requirements.txt +++ b/requirements/test-requirements.txt @@ -1,3 +1,4 @@ +hacking>=1.1.0,<=2.0.0 # Apache-2.0 yamllint === 1.32.0 bashate === 2.1.1 pylint === 2.13.9 diff --git a/tox.ini b/tox.ini index c6a012d..d1891de 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = linters,pylint,unittests +envlist = linters,flake8,pylint,unittests minversion = 2.3 skipsdist = True @@ -27,6 +27,15 @@ commands = -name \*.sh \ -print0 | xargs -0 bashate -v -iE006,E040" +[flake8] +ignore = +exclude = regression +max-line-length=80 + +[testenv:flake8] +commands = + flake8 {posargs} libvirt/ + [testenv:pylint] basepython = python3 sitepackages = False