From 927bee2d66eff3e224b356cee72d5fb2bccbcaa8 Mon Sep 17 00:00:00 2001 From: albailey Date: Mon, 21 Dec 2020 10:59:14 -0600 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 updates the version constraint to use newer flake8. pylint has been switched to running in python3 which has challenges related to the new pip resolver. The correct version of Django cannot be specified with the new resolver so the pylint errors caused by the newer version are suppressed for now. The docs targets for tox use their own install_command which does not include an upper constraint. A non ascii character was removed from the tox.ini file which prevented running tox on some ubuntu envs. Partial-Bug: 1895054 Signed-off-by: albailey Change-Id: Ic6a50c2ecf2a654fd883ed92fc305336741d4303 --- pylint.rc | 10 ++++++++-- test-requirements.txt | 9 ++++++--- tox.ini | 17 ++++++++++------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/pylint.rc b/pylint.rc index b2bbf8f1..ac9beaf8 100755 --- a/pylint.rc +++ b/pylint.rc @@ -26,6 +26,7 @@ load-plugins= # can either give multiple identifier separated by comma (,) or put this option # multiple time (only on the command line, not in the configuration file where # it should appear only once). +# W0107 unnecessary-pass # W0201 attribute-defined-outside-init # W0212 protected-access var starting with _ used outside class or descendant # W0221 arguments-differ @@ -37,8 +38,13 @@ load-plugins= # E0202 method-hidden # E0203 access-member-before-definition # E1101 no-member -disable=C, R, W0201, W0212, W0221, W0235, W0403, W0511, W0613, W0703, - E0202, E0203, E1101 +# The next two error codes are because Django 1.11.20 cannot be specified +# without a custom upper constraints file +# E0401: Unable to import 'django.core.urlresolvers' (import-error) +# E0611: No name 'urlresolvers' in module 'django.core' (no-name-in-module) +disable=C, R, W0107, W0201, W0212, W0221, W0235, W0403, W0511, W0613, W0703, + E0202, E0203, E1101, + E0401, E0611 [REPORTS] diff --git a/test-requirements.txt b/test-requirements.txt index d062adbf..0ee31f18 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,11 +7,10 @@ # be installed in a specific order. # # Hacking should appear first in case something else depends on pep8 -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 +hacking>=1.1.0,<=2.0.0 # Apache-2.0 coverage>=3.6 # Apache-2.0 django-nose>=1.4.4 # BSD mock>=2.0 # BSD -mox3>=0.7.0 # Apache-2.0 nodeenv>=0.9.4 # BSD License # BSD nose # LGPL nose-exclude # LGPL @@ -24,4 +23,8 @@ testtools>=1.4.0 # MIT # This also needs xvfb library installed on your OS xvfbwrapper>=0.1.3 #license: MIT pyOpenSSL>=0.14 -bandit!=1.6.0,>=1.1.0,<2.0.0 +bandit;python_version>="3.0" +isort<5;python_version>="3.0" +pylint<2.1.0;python_version<"3.0" # GPLv2 +pylint<2.4.0;python_version>="3.0" # GPLv2 +Django diff --git a/tox.ini b/tox.ini index ba4949f4..239f123b 100644 --- a/tox.ini +++ b/tox.ini @@ -37,9 +37,11 @@ commands = [flake8] # H102 Apache 2.0 license header not found -# NOTE(Eric Barrett): H102 raises a false positive when using the SPDX license header -ignore = H102 -# H106 Don’t put vim configuration in source files (off by default). +# W503 line break before binary operator +# W504 line break after binary operator +# E741 ambiguous variable name 'l' +ignore = H102,W503,W504,E741 +# H106 Do not put vim configuration in source files (off by default). # H203 Use assertIs(Not)None to check for None (off by default). # H904 Delay string interpolations at logging calls (off by default). enable-extensions = H106,H203,H904 @@ -52,7 +54,7 @@ commands = flake8 [testenv:pylint] -basepython = python2.7 +basepython = python3 usedevelop = False skip_install = True deps = {[testenv]deps} @@ -64,9 +66,8 @@ deps = {[testenv]deps} -e{[tox]stxdir}/nfv/nfv/nfv-client -e{[tox]stxdir}/ha/service-mgmt-client/sm-client -e{[tox]stxdir}/utilities/ceph/python-cephclient/python-cephclient - horizon==15.2.0 + horizon requests-toolbelt - pylint commands = pylint starlingx-dashboard/starlingx-dashboard/starlingx_dashboard --rcfile=./pylint.rc @@ -77,6 +78,7 @@ commands = {posargs} [testenv:docs] basepython = python3 deps = -r{toxinidir}/doc/requirements.txt +install_command = pip install -U {opts} {packages} commands = rm -rf doc/build sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html @@ -85,6 +87,7 @@ whitelist_externals = rm [testenv:releasenotes] basepython = python3 deps = -r{toxinidir}/doc/requirements.txt +install_command = pip install -U {opts} {packages} commands = rm -rf releasenotes/build sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html @@ -97,10 +100,10 @@ basepython = python3 # Re-use the releasenotes venv envdir = {toxworkdir}/releasenotes deps = -r{toxinidir}/doc/requirements.txt +install_command = pip install -U {opts} {packages} commands = reno new {posargs} [testenv:bandit] basepython = python3 description = Bandit code scan for *.py files under config folder -deps = -r{toxinidir}/test-requirements.txt commands = bandit -r {toxinidir}/ -x '**/.tox/**,**/.eggs/**' -lll