enable pre-commit lints from main ironic repo
Brought over the same lints as used in the main ironic repo via pre-commit and ruff. Updated tox.ini to use pre-commit the same way. Needed to use newer codespell due to issue with Pres vs Press. Change-Id: I559ecb5bedae0aa79bac5aff24d621db0819ce4f Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
This commit is contained in:
66
.pre-commit-config.yaml
Normal file
66
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,66 @@
|
||||
---
|
||||
default_language_version:
|
||||
# force all unspecified python hooks to run python3
|
||||
python: python3
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.5.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
# NOTE(JayF): We shouldn't modify release notes after their
|
||||
# associated release. Instead, ignore these minor lint issues.
|
||||
- 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$
|
||||
- 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: []
|
||||
exclude: '^(doc|releasenotes|tools)/.*$'
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.4.1
|
||||
hooks:
|
||||
- id: codespell
|
||||
args: [--write-changes]
|
||||
- repo: https://github.com/sphinx-contrib/sphinx-lint
|
||||
rev: v1.0.0
|
||||
hooks:
|
||||
- id: sphinx-lint
|
||||
args: [--enable=default-role]
|
||||
files: ^doc/|releasenotes|api-ref
|
||||
- repo: https://opendev.org/openstack/bashate
|
||||
rev: 2.1.0
|
||||
hooks:
|
||||
- id: bashate
|
||||
args: ["-iE006,E044", "-eE005,E042"]
|
||||
name: bashate
|
||||
description: This hook runs bashate for linting shell scripts
|
||||
entry: bashate
|
||||
language: python
|
||||
types: [shell]
|
||||
- repo: https://github.com/PyCQA/doc8
|
||||
rev: v1.1.2
|
||||
hooks:
|
||||
- id: doc8
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.7.3
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: ['--fix', '--unsafe-fixes']
|
||||
@@ -1,3 +1,14 @@
|
||||
[build-system]
|
||||
requires = ["pbr>=6.0.0", "setuptools>=64.0.0"]
|
||||
build-backend = "pbr.build"
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 79
|
||||
target-version = "py37"
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
"E", # pycodestyle (error)
|
||||
"F", # pyflakes
|
||||
"LOG", # flake8-logging
|
||||
]
|
||||
|
||||
24
tox.ini
24
tox.ini
@@ -1,5 +1,6 @@
|
||||
[tox]
|
||||
minversion = 3.18.0
|
||||
minversion = 4.4.0
|
||||
envlist =
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
@@ -10,6 +11,7 @@ setenv =
|
||||
LANGUAGE=en_US
|
||||
LC_ALL=en_US.UTF-8
|
||||
PYTHONWARNINGS=default::DeprecationWarning
|
||||
PYTHONUNBUFFERED=1
|
||||
deps =
|
||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
@@ -17,14 +19,9 @@ deps =
|
||||
commands = stestr run {posargs}
|
||||
|
||||
[testenv:pep8]
|
||||
deps =
|
||||
hacking~=6.0.0 # Apache-2.0
|
||||
doc8>=0.8.1 # Apache-2.0
|
||||
flake8-import-order>=0.17.1 # LGPLv3
|
||||
pycodestyle>=2.0.0,<3.0.0 # MIT
|
||||
commands =
|
||||
flake8 {posargs}
|
||||
doc8 README.rst CONTRIBUTING.md doc/source
|
||||
deps = pre-commit
|
||||
allowlist_externals = pre-commit
|
||||
commands = pre-commit run --all-files --show-diff-on-failure {posargs}
|
||||
|
||||
[testenv:cover]
|
||||
setenv =
|
||||
@@ -69,6 +66,7 @@ commands = {posargs}
|
||||
|
||||
[flake8]
|
||||
application-import-names = ironic_prometheus_exporter
|
||||
filename = *.py,app.wsgi
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||
import-order-style = pep8
|
||||
show-source = True
|
||||
@@ -76,8 +74,6 @@ show-source = True
|
||||
[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}
|
||||
deps = pre-commit
|
||||
allowlist_externals = pre-commit
|
||||
commands = pre-commit run --all-files --show-diff-on-failure codespell
|
||||
|
||||
Reference in New Issue
Block a user