tox: fixed warnings

meta_data files:
- "too few spaces before comment" warning
- missing document start "---" warning

tox.ini:
- allowlist bash for testenv
- moved 'basepython' var to testenv as it was repeated
  in all derived envs
- removed "tox < 4" requirement. changed minversion to 4

pylint:
- renamed pylintrc to the standard convention ".pylintrc"
- Removed "enable" section, as all warnings are enabled by default
- Updated "disable" section as some warnings changed names
- files-output deprecated [1]
- bad-functions requires a plugin [2, 3]
- max-branchs ==> max-branches [4]
- overgeneral-exceptions updated

[1] https://pylint.pycqa.org/en/latest/whatsnew/1/1.7/summary.html#removed-changes
[2] https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html#bad-functions
[3] https://pylint.pycqa.org/en/latest/user_guide/messages/warning/bad-builtin.html
[4] https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/too-many-branches.html

Test Plan:
pass: run tox

Partial-Bug: 1976377

Change-Id: I715ed859e046a90cc7ec5d047d42902a51009eb8
Signed-off-by: Leonardo Fagundes Luz Serrano <Leonardo.FagundesLuzSerrano@windriver.com>
This commit is contained in:
Leonardo Fagundes Luz Serrano 2023-09-01 16:01:58 -03:00
parent 5bf031d65c
commit 5e19b07ebb
8 changed files with 68 additions and 167 deletions

View File

@ -1,6 +1,6 @@
[MASTER]
# Specify a configuration file.
rcfile=pylint.rc
rcfile=.pylintrc
# Python code to execute, usually for sys.path manipulation such as pygtk.require().
#init-hook=
@ -13,116 +13,25 @@ persistent=yes
# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=
load-plugins= pylint.extensions.bad_builtin
[MESSAGES CONTROL]
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time.
#
# Python3 checker:
#
# E1601: print-statement
# E1602: parameter-unpacking
# E1603: unpacking-in-except
# E1604: old-raise-syntax
# E1605: backtick
# E1606: long-suffix
# E1607: old-ne-operator
# E1608: old-octal-literal
# E1609: import-star-module-level
# E1610: non-ascii-bytes-literal
# E1611: invalid-unicode-literal
# W1601: apply-builtin
# W1602: basestring-builtin
# W1603: buffer-builtin
# W1604: cmp-builtin
# W1605: coerce-builtin
# W1606: execfile-builtin
# W1607: file-builtin
# W1608: long-builtin
# W1609: raw_input-builtin
# W1610: reduce-builtin
# W1611: standarderror-builtin
# W1612: unicode-builtin
# W1613: xrange-builtin
# W1614: coerce-method
# W1615: delslice-method
# W1616: getslice-method
# W1617: setslice-method
# W1618: no-absolute-import
# W1619: old-division
# W1620: dict-iter-method
# W1621: dict-view-method
# W1622: next-method-called
# W1623: metaclass-assignment
# W1624: indexing-exception
# W1625: raising-string
# W1626: reload-builtin
# W1627: oct-method
# W1628: hex-method
# W1629: nonzero-method
# W1630: cmp-method
# W1632: input-builtin
# W1633: round-builtin
# W1634: intern-builtin
# W1635: unichr-builtin
# W1636: map-builtin-not-iterating
# W1637: zip-builtin-not-iterating
# W1638: range-builtin-not-iterating
# W1639: filter-builtin-not-iterating
# W1640: using-cmp-argument
# W1641: eq-without-hash
# W1642: div-method
# W1643: idiv-method
# W1644: rdiv-method
# W1645: exception-message-attribute
# W1646: invalid-str-codec
# W1647: sys-max-int
# W1648: bad-python3-import
# W1649: deprecated-string-function
# W1650: deprecated-str-translate-call
# W1651: deprecated-itertools-function
# W1652: deprecated-types-field
# W1653: next-method-defined
# W1654: dict-items-not-iterating
# W1655: dict-keys-not-iterating
# W1656: dict-values-not-iterating
# W1657: deprecated-operator-function
# W1658: deprecated-urllib-function
# W1659: xreadlines-attribute
# W1660: deprecated-sys-function
# W1661: exception-escape
# W1662: comprehension-escape
enable=E1603,E1609,E1610,E1602,E1606,E1608,E1607,E1605,E1604,E1601,E1611,W1652,
W1651,W1649,W1657,W1660,W1658,W1659,W1623,W1622,W1620,W1621,W1645,W1641,
W1624,W1648,W1625,W1611,W1662,W1661,W1650,W1640,W1630,W1614,W1615,W1642,
W1616,W1628,W1643,W1629,W1627,W1644,W1617,W1601,W1602,W1603,W1604,W1605,
W1654,W1655,W1656,W1619,W1606,W1607,W1639,W1618,W1632,W1634,W1608,W1636,
W1653,W1646,W1638,W1609,W1610,W1626,W1633,W1647,W1635,W1612,W1613,W1637
# Disable the message, report, category or checker with the given id(s). You
# 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).
# W0105 pointless-string-statement
# W0621 redefined-outer-name
# W0703 broad except warning
# W0707 raise-missing-from
disable=C, R, W0105, W0621, W0703, W0707
disable = C, R,
broad-exception-caught,
pointless-string-statement,
raise-missing-from,
redefined-outer-name,
[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs
# (visual studio) and html
output-format=text
# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]".
files-output=no
# Tells whether to display a full report or only the messages
reports=no
@ -264,7 +173,7 @@ max-locals=15
max-returns=6
# Maximum number of branch for function / method body
max-branchs=12
max-branches=12
# Maximum number of statements in function / method body
max-statements=50
@ -293,4 +202,5 @@ valid-classmethod-first-arg=cls
[EXCEPTIONS]
# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.BaseException,
builtins.Exception

View File

@ -52,7 +52,7 @@
postgresql: true
devstack_localrc:
# LIBS_FROM_GIT: keystone
FORCE: yes # yamllint disable-line rule:truthy
FORCE: yes # yamllint disable-line rule:truthy
# A minimal base job that eliminates most OpenStack services
# Leave Celiometer, Horizon and Swift in the base since none
@ -125,7 +125,7 @@
postgresql: true
devstack_localrc:
# LIBS_FROM_GIT: keystone
FORCE: yes # yamllint disable-line rule:truthy
FORCE: yes # yamllint disable-line rule:truthy
# And the tox version of the base-min job
- job:

View File

@ -3,7 +3,7 @@ debname: puppet-module-cristifalcas-etcd
debver: 1.12.3-3
dl_path:
name: puppet-module-cristifalcas-etcd-1.12.3-3.tar.gz
url: https://salsa.debian.org/openstack-team/puppet/puppet-module-cristifalcas-etcd/-/archive/debian/1.12.3-3/puppet-module-cristifalcas-etcd-debian-1.12.3-3.tar.gz # yamllint disable-line rule:line-length
url: https://salsa.debian.org/openstack-team/puppet/puppet-module-cristifalcas-etcd/-/archive/debian/1.12.3-3/puppet-module-cristifalcas-etcd-debian-1.12.3-3.tar.gz # yamllint disable-line rule:line-length
md5sum: 9ca374f32dad83478801a6eb4c1c52dd
sha256sum: ce3d08c990c390b3927e9f62a8eb1beff4d49b60da7e997f3a886fc49cf3d911
revision:

View File

@ -3,7 +3,7 @@ debname: puppet-module-puppetlabs-rabbitmq
debver: 8.5.0-6
dl_path:
name: puppet-module-puppetlabs-rabbitmq-8.5.0-6.tar.gz
url: https://salsa.debian.org/openstack-team/puppet/puppet-module-puppetlabs-rabbitmq/-/archive/debian/8.5.0-6/puppet-module-puppetlabs-rabbitmq-debian-8.5.0-6.tar.gz # yamllint disable-line rule:line-length
url: https://salsa.debian.org/openstack-team/puppet/puppet-module-puppetlabs-rabbitmq/-/archive/debian/8.5.0-6/puppet-module-puppetlabs-rabbitmq-debian-8.5.0-6.tar.gz # yamllint disable-line rule:line-length
md5sum: 0590fe35398a5fd0f1cb96566833228e
sha256sum: 5b75fc9c53d44f56637211a0ef160664a0da9a04106722a4e3cfc3b842c65fba
revision:

View File

@ -3,7 +3,7 @@ debname: puppet-module-puppetlabs-haproxy
debver: 2.1.0-3
dl_path:
name: puppet-module-puppetlabs-haproxy-2.1.0-3.tar.gz
url: https://salsa.debian.org/openstack-team/puppet/puppet-module-puppetlabs-haproxy/-/archive/debian/2.1.0-3/puppet-module-puppetlabs-haproxy-debian-2.1.0-3.tar.gz # yamllint disable-line rule:line-length
url: https://salsa.debian.org/openstack-team/puppet/puppet-module-puppetlabs-haproxy/-/archive/debian/2.1.0-3/puppet-module-puppetlabs-haproxy-debian-2.1.0-3.tar.gz # yamllint disable-line rule:line-length
md5sum: 0e523b59292206194b3bacc28bd483e2
sha256sum: 80a7bbe94fbc6ffcdf922232ae0ed43f80aec4815a49370bc96439c56f7f616a
revision:

View File

@ -3,7 +3,7 @@ debname: golang-github-vishvananda-netlink
debver: 1.1.0.125.gf243826-4
dl_path:
name: golang-github-vishvananda-debian-1.1.0.125.gf243826-4.tar.gz
url: https://salsa.debian.org/go-team/packages/golang-github-vishvananda-netlink/-/archive/debian/1.1.0.125.gf243826-4/golang-github-vishvananda-netlink-debian-1.1.0.125.gf243826-4.tar.gz # yamllint disable-line rule:line-length
url: https://salsa.debian.org/go-team/packages/golang-github-vishvananda-netlink/-/archive/debian/1.1.0.125.gf243826-4/golang-github-vishvananda-netlink-debian-1.1.0.125.gf243826-4.tar.gz # yamllint disable-line rule:line-length
md5sum: f6446c199670cdd89690f3366cf18916
sha256sum: 8db9eaf59ab220c5205c97ff1bb38ca76ad7760afdf8778746db318b76515c95
revision:

View File

@ -1,3 +1,4 @@
---
debver: 1.26.1
dl_path:
name: kubernetes-1.26.1.tar.gz

112
tox.ini
View File

@ -1,16 +1,14 @@
[tox]
envlist = linters,pylint
minversion = 3.2
minversion = 4
skipsdist = True
stxdir = {toxinidir}/..
# Cap setuptools via virtualenv to prevent compatibility issue with pb5 5.5.0
# Tox is also needed to be constrained
requires =
virtualenv<20.24.0
tox<4
[testenv]
basepython = python3
install_command = pip install -U \
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
{opts} {packages}
@ -19,10 +17,9 @@ setenv = VIRTUAL_ENV={envdir}
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
deps = -r{toxinidir}/test-requirements.txt
allowlist_externals = bash
[testenv:linters]
basepython = python3
allowlist_externals = bash
# Ignore errors in included vendor code that we don't control.
#bashate ignore
#E006 Line too long
@ -46,6 +43,54 @@ commands =
-o -type f -name '*.yaml' \
-print0 | xargs -0 yamllint"
[testenv:pep8]
usedevelop = False
skip_install = True
deps =
hacking
flake8-bugbear<=19.3.0
flake8<3.8.3
commands =
flake8
[testenv:pylint]
deps = -r{toxinidir}/test-requirements.txt
-e{[tox]stxdir}/config/sysinv/cgts-client/cgts-client
pylint
# Currently only one python module with a setup.py file
commands = pylint --rcfile=./.pylintrc \
tools/storage-topology/storage-topology/storage_topology
[testenv:venv]
commands = {posargs}
[testenv:docs]
deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf doc/build
sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html
allowlist_externals = rm
[testenv:releasenotes]
deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf releasenotes/build
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
allowlist_externals =
rm
reno
[testenv:newnote]
# Re-use the releasenotes venv
envdir = {toxworkdir}/releasenotes
deps = -r{toxinidir}/doc/requirements.txt
commands = reno new {posargs}
[testenv:functional]
allowlist_externals = cat
commands = cat /etc/group
[flake8]
# E series are pep8
# E265 block comment should start with '# '
@ -83,58 +128,3 @@ ignore = E265,E266,E402,E501,E722,E741
W291,W391,W503,W504
B001,B007,B009,B010,
F401
[testenv:pep8]
basepython = python3
usedevelop = False
skip_install = True
deps =
hacking
flake8-bugbear<=19.3.0
flake8<3.8.3
commands =
flake8
[testenv:pylint]
basepython = python3
deps = -r{toxinidir}/test-requirements.txt
-e{[tox]stxdir}/config/sysinv/cgts-client/cgts-client
pylint
# Currently only one python module with a setup.py file
commands = pylint --rcfile=./pylint.rc \
tools/storage-topology/storage-topology/storage_topology
[testenv:venv]
basepython = python3
commands = {posargs}
[testenv:docs]
basepython = python3
deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf doc/build
sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html
allowlist_externals = rm
[testenv:releasenotes]
basepython = python3
deps = -r{toxinidir}/doc/requirements.txt
commands =
rm -rf releasenotes/build
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
allowlist_externals =
rm
reno
[testenv:newnote]
basepython = python3
# Re-use the releasenotes venv
envdir = {toxworkdir}/releasenotes
deps = -r{toxinidir}/doc/requirements.txt
commands = reno new {posargs}
[testenv:functional]
basepython = python3
allowlist_externals = cat
commands = cat /etc/group