From 4d34b1ac65307eb6862125a38e07a3e8e0cbba44 Mon Sep 17 00:00:00 2001 From: Thiago Brito Date: Wed, 22 Jun 2022 12:27:57 -0300 Subject: [PATCH] Add flake8-import-order and use python3.9 on tox Improving the code quality of upstream by adding the flake8 check on zuul and adding the flake8-import-order plugin to standardize imports. Also, defaults testenv to python3.9 configuration that should be used for now on with the debian migration. Story: 2010100 Task: 45669 Signed-off-by: Thiago Brito Change-Id: I55aa952c4f22a7af53e1f1c11a4a51997afa4bcf --- .zuul.yaml | 18 +++++++--- .../centos/files/guni_config.py | 1 + .../python-keystone/centos/files/public.py | 3 +- test-requirements.txt | 9 ++--- tox.ini | 33 ++++++++++--------- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index d8fbeeda..550361d1 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -5,16 +5,26 @@ - stx-release-notes-jobs check: jobs: - - openstack-tox-pep8 - - openstack-tox-linters + - stx-upstream-tox-pep8 + - stx-upstream-tox-linters gate: jobs: - - openstack-tox-pep8 - - openstack-tox-linters + - stx-upstream-tox-pep8 + - stx-upstream-tox-linters post: jobs: - stx-upstream-upload-git-mirror +- job: + name: stx-upstream-tox-pep8 + parent: openstack-tox-pep8 + nodeset: debian-bullseye + +- job: + name: stx-upstream-tox-linters + parent: openstack-tox-linters + nodeset: debian-bullseye + - job: name: stx-upstream-upload-git-mirror parent: upload-git-mirror diff --git a/openstack/python-horizon/centos/files/guni_config.py b/openstack/python-horizon/centos/files/guni_config.py index 57a0727d..6ee58d79 100644 --- a/openstack/python-horizon/centos/files/guni_config.py +++ b/openstack/python-horizon/centos/files/guni_config.py @@ -3,6 +3,7 @@ import fnmatch import os import resource import subprocess + from django.conf import settings diff --git a/openstack/python-keystone/centos/files/public.py b/openstack/python-keystone/centos/files/public.py index d3a29f3b..52c26983 100644 --- a/openstack/python-keystone/centos/files/public.py +++ b/openstack/python-keystone/centos/files/public.py @@ -12,10 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. +import sys from keystone.server import wsgi as wsgi_server -import sys + sys.argv = sys.argv[:1] application = wsgi_server.initialize_public_application() diff --git a/test-requirements.txt b/test-requirements.txt index b891eae8..76713af4 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,5 @@ -bashate >= 0.2 -PyYAML >= 3.1.0 -yamllint >= 0.5.2 -flake8 >= 2.5.4 # MIT +bashate +PyYAML +yamllint +flake8 +flake8-import-order diff --git a/tox.ini b/tox.ini index e147a498..4d5ed0de 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,12 @@ minversion = 2.3 skipsdist = True [testenv] -install_command = pip install -U {opts} {packages} +basepython = python3.9 +install_command = pip install \ + -v -v -v \ + -U \ + -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \ + {opts} {packages} setenv = VIRTUAL_ENV={envdir} OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 @@ -12,7 +17,6 @@ setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/test-requirements.txt [testenv:linters] -basepython = python3 whitelist_externals = bash commands = bash -c "find {toxinidir} \ @@ -27,17 +31,6 @@ commands = -o -name '*.yaml' \ -print0 | xargs -0 yamllint" -[testenv:pep8] -basepython = python3 -usedevelop = False -description = - Run style checks. - - -commands = - flake8 - - [flake8] # E123, E125 skipped as they are invalid PEP-8. # E501 skipped because some of the code files include templates @@ -46,10 +39,20 @@ commands = show-source = True ignore = E123,E125,E501,H405 exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-* +import-order-style = google + + +[testenv:pep8] +usedevelop = False +description = + Run style checks. + + +commands = + flake8 [testenv:venv] -basepython = python3 commands = {posargs} [testenv:docs] @@ -71,8 +74,8 @@ whitelist_externals = reno [testenv:newnote] -basepython = python3 # Re-use the releasenotes venv +basepython = python3 envdir = {toxworkdir}/releasenotes deps = -r{toxinidir}/doc/requirements.txt commands = reno new {posargs}