Merge "Switch to pre-commit"

This commit is contained in:
Zuul
2025-09-18 23:00:56 +00:00
committed by Gerrit Code Review
3 changed files with 48 additions and 16 deletions

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

@@ -0,0 +1,38 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
args: ['--fix', 'lf']
exclude: |
(?x)(
.*.svg$|
)
- id: fix-byte-order-marker
- id: check-merge-conflict
- id: debug-statements
- id: check-json
files: .*\.json$
exclude: sushy_tools/emulator/templates/.*$
- id: check-yaml
files: .*\.(yaml|yml)$
exclude: releasenotes/.*$
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: remove-tabs
exclude: '.*\.(svg)$'
- repo: https://opendev.org/openstack/hacking
rev: 6.1.0
hooks:
- id: hacking
additional_dependencies:
- flake8-import-order>=0.19,<0.20
exclude: '^(doc|releasenotes|tools)/.*$'
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: [--write-changes]

View File

@@ -35,7 +35,7 @@
"BootSourceOverrideMode": {{ boot_source_mode|string|tojson }}
{%- endif %}
{%- else %}
"Hdd"
"Hdd"
]
{%- endif %}
{%- else %}

24
tox.ini
View File

@@ -18,12 +18,15 @@ commands = stestr run {posargs}
stestr slowest
[testenv:pep8]
deps=
hacking~=6.0.0 # Apache-2.0
flake8-import-order>=0.17.1 # LGPLv3
pycodestyle>=2.0.0,<3.0.0 # MIT
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
commands = flake8 {posargs}
deps = pre-commit
allowlist_externals = pre-commit
commands = pre-commit run --all-files --show-diff-on-failure {posargs}
[testenv:codespell]
description =
Run codespell to check spelling
deps = pre-commit
commands = pre-commit run --all-files --show-diff-on-failure codespell
[testenv:venv]
commands = {posargs}
@@ -67,12 +70,3 @@ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
import-order-style = pep8
application-import-names = sushy_tools
filename = *.py
[testenv:codespell]
description =
Run codespell to check spelling
deps = codespell
# note(JayF): {posargs} lets us run `tox -ecodespell -- -w` to get codespell
# to correct spelling issues in our code it's aware of.
commands =
codespell {posargs}