Browse Source

Run flake8 using pre-commit

- fixes two issues identified by newer flake8
- upgrades flake8 and keeps it pinned
- removes hacking as this is no longer needed, as pre-commit does
  its own pinning.
- enables us to easily add other linters, pylint would come in
  follow-up

Change-Id: If26234fad0cd982bd7d3dc23c42021b357c6bde9
Related-Bug: #1910543
changes/21/769921/2
Sorin Sbarnea 9 months ago
parent
commit
276bacfb92
  1. 9
      .pre-commit-config.yaml
  2. 13
      setup.cfg
  3. 2
      test-requirements.txt
  4. 8
      tox.ini
  5. 4
      tripleoclient/utils.py
  6. 2
      tripleoclient/v2/tripleo_container_image.py

9
.pre-commit-config.yaml

@ -0,0 +1,9 @@
---
repos:
- repo: https://gitlab.com/pycqa/flake8.git
rev: 3.8.4
hooks:
- id: flake8
language_version: python3
args: ['--config=setup.cfg']
pass_filenames: false

13
setup.cfg

@ -116,3 +116,16 @@ oslo.config.opts =
undercloud_config = tripleoclient.config.undercloud:list_opts
standalone_config = tripleoclient.config.standalone:list_opts
minion_config = tripleoclient.config.minion:list_opts
[flake8]
show-source = True
builtins = _
exclude =
.venv,
.git,
.tox,
dist,
doc/source/conf.py,
releasenotes
#.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,releasenotes

2
test-requirements.txt

@ -1,8 +1,6 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking>=3.0.1,<3.1.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
docutils>=0.11 # OSI-Approved Open Source, Public Domain
fixtures>=3.0.0 # Apache-2.0/BSD

8
tox.ini

@ -35,7 +35,8 @@ deps = bindep
commands = bindep test
[testenv:pep8]
commands = flake8
deps = pre-commit
commands = pre-commit run -a
[testenv:venv]
commands = {posargs}
@ -66,11 +67,6 @@ deps =
commands =
sphinx-build -b html doc/source doc/build/html
[flake8]
show-source = True
builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,releasenotes
[testenv:pdf-docs]
whitelist_externals = make
description =

4
tripleoclient/utils.py

@ -762,8 +762,8 @@ def is_loopback(host):
Return False if not.
"""
loopbacks = ['127', '::1']
for l in loopbacks:
if host.startswith(l):
for item in loopbacks:
if host.startswith(item):
return True
return False

2
tripleoclient/v2/tripleo_container_image.py

@ -375,7 +375,7 @@ class Build(command.Command):
os.path.abspath(parsed_args.config_path))
for image in expected_images:
if (image != config_path_base and image not in image_configs):
self.log.debug("processing image configs".format(image))
self.log.debug("processing image config %s", image)
image_config = self.find_image(
image,
self.tcib_config_path,

Loading…
Cancel
Save