From 57225bb34ae5380c95dddd0e556847f7a17e3d61 Mon Sep 17 00:00:00 2001 From: albailey Date: Wed, 16 Sep 2020 13:01:03 -0500 Subject: [PATCH] Use newer flake8 to run on ubuntu-focal Zuul machines flake8 2.5.5 fails on ubuntu-focal zuul machines running python3.8 with the following error: AttributeError: 'FlakesChecker' object has no attribute 'CONSTANT' The update removes the version constraint to use newer flake8. The linters can be run in python3. Pylint cannot be run in python3 because mysql-python is not compatable, so a new zuul job for pylint is now added. The flake8 errors that the newer version raises are all suppressed, and some of them should be addressed by someone with familiarity in this repo. Change-Id: Ida6447728d4175173c02130cb04a6013e4f966f9 Partial-Bug: 1895054 Signed-off-by: albailey --- .zuul.yaml | 10 ++++++++ test-requirements.txt | 1 + tox.ini | 56 ++++++++++++++++++++++++++----------------- 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 85a56388..4631e0d3 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -9,10 +9,12 @@ jobs: - openstack-tox-pep8 - openstack-tox-linters + - ha-tox-pylint gate: jobs: - openstack-tox-pep8 - openstack-tox-linters + - ha-tox-pylint post: jobs: - stx-ha-upload-git-mirror @@ -56,6 +58,14 @@ nfv: https://opendev.org/starlingx/nfv update: https://opendev.org/starlingx/update +- job: + name: ha-tox-pylint + parent: tox + description: | + Run pylint test for ha in python2.7 + nodeset: ubuntu-bionic + vars: + tox_envlist: pylint - job: name: stx-ha-upload-git-mirror parent: upload-git-mirror diff --git a/test-requirements.txt b/test-requirements.txt index 0375f1c0..1132aeaa 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,4 @@ +hacking bashate >= 0.2 PyYAML >= 3.1.0 yamllint >= 0.5.2 diff --git a/tox.ini b/tox.ini index 55631319..16508019 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,27 @@ deps = -r{toxinidir}/test-requirements.txt whitelist_externals = reno [testenv:linters] +basepython = python3 +whitelist_externals = bash +commands = + bash -c "find {toxinidir} \ + -not \( -type d -name .?\* -prune \) \ + -type f \ + -not -name \*~ \ + -not -name \*.md \ + \( \ + -name \*.sh \ + -or -not -wholename \*/devstack/files/\* \ + -wholename \*/devstack/\* \ + \) \ + -print0 | xargs -r -n 1 -0 bashate -v -e E* -i E006" + bash -c "find {toxinidir} \ + \( -name middleware/io-monitor/recipes-common/io-monitor/io-monitor/io_monitor/test-tools/yaml/* -prune \) \ + -o \( -name .tox -prune \) \ + -o -type f -name '*.yaml' \ + -print0 | xargs -0 yamllint" + +[testenv:pylint] basepython = python2.7 deps = {[testenv]deps} eventlet @@ -32,24 +53,7 @@ deps = {[testenv]deps} sqlalchemy-migrate wsme pylint -whitelist_externals = bash commands = - bash -c "find {toxinidir} \ - -not \( -type d -name .?\* -prune \) \ - -type f \ - -not -name \*~ \ - -not -name \*.md \ - \( \ - -name \*.sh \ - -or -not -wholename \*/devstack/files/\* \ - -wholename \*/devstack/\* \ - \) \ - -print0 | xargs -0 bashate -v" - bash -c "find {toxinidir} \ - \( -name middleware/io-monitor/recipes-common/io-monitor/io-monitor/io_monitor/test-tools/yaml/* -prune \) \ - -o \( -name .tox -prune \) \ - -o -type f -name '*.yaml' \ - -print0 | xargs -0 yamllint" pylint --rcfile=./pylint.rc --extension-pkg-whitelist=greenlet \ ./service-mgmt-api/sm-api/sm_api/ \ ./service-mgmt-tools/sm-tools/sm_tools/ \ @@ -68,15 +72,24 @@ commands = # H404: multi line docstring should start without a leading new line # H405: multi line docstring summary not separated with an empty line # H501: Do not use locals() for string formatting +# W are warnings +# W504 W504 line break after binary operator +# W605 invalid escape sequence # - errors - +# E741 ambiguous variable name # F811 redefinition of unused '' from line # F821 undefined name 'e' +# F841 local variable +# F901 'raise NotImplemented' should be 'raise NotImplementedError' # - bugbear - # B008 Do not perform calls in argument defaults. The call is performed only once at function definition time. +# B014 Redundant exception types ignore= E402, H102,H104,H105,H106,H306,H401,H403,H404,H405,H501, - F811,F821, - B008 + W504,W605, + E741, + F811,F821,F841,F901, + B008,B014 # Enable checks which are off by default # H106 Don’t put vim configuration in source files (off by default). SHOULD BE ENABLED. # H203 Use assertIs(Not)None to check for None (off by default). @@ -89,9 +102,8 @@ basepython = python3 usedevelop = False skip_install = True deps = - hacking - flake8-bugbear<=19.3.0 - flake8 < 3.6.0 + -r{toxinidir}/test-requirements.txt + flake8-bugbear commands = flake8