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
This commit is contained in:
Sorin Sbarnea 2021-01-08 13:23:59 +00:00
parent dc2aacaefd
commit 276bacfb92
6 changed files with 27 additions and 11 deletions

9
.pre-commit-config.yaml Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 =

View File

@ -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

View File

@ -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,