Use pre-commit for pep8 checks

pre-commit was introduced in several repos and is known to be useful.
It allows us to easily add more checks.

Change-Id: I8bfbd0abbf2ad825716331833fb6ab68a1e61dfd
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami
2025-10-12 00:10:56 +09:00
parent 2d375edcc8
commit 43c1571fe7
4 changed files with 26 additions and 5 deletions

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

@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
args: ['--fix', 'lf']
exclude: '.*\.(svg)$'
- id: fix-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://opendev.org/openstack/hacking
rev: 7.0.0
hooks:
- id: hacking
additional_dependencies: []
exclude: '^(doc|releasenotes|tools)/.*$'

View File

@@ -108,7 +108,7 @@ openstack messaging queue set metadata
usage: openstack messaging queue set metadata [-h] <queue_name> <queue_metadata>
Set queue metadata.All the metadata of the queue will be replaced by
Set queue metadata.All the metadata of the queue will be replaced by
queue_metadata.
**Positional arguments:**

View File

@@ -1,6 +1,3 @@
# Hacking already pins down pep8, pyflakes and flake8
hacking>=6.1.0,<6.2.0 # Apache-2.0
# Unit testing
fixtures>=3.0.0 # Apache-2.0/BSD
testtools>=2.2.0 # MIT

View File

@@ -17,7 +17,11 @@ commands = find . -type f -name "*.pyc" -delete
allowlist_externals = find
[testenv:pep8]
commands = flake8
skip_install = true
deps =
pre-commit
commands =
pre-commit run -a
[testenv:cover]
setenv = {[testenv]setenv}