From 2ffdf2e9173ca2ad0f95ac7f565da64b8b62691f Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: 2023年9月22日 11:40:12 +0100 Subject: [PATCH] tox: Use pre-commit for pep8 target pre-commit is an effective linter runner. No need to duplicate things. We are able to remove our homegrown "is this valid JSON" check by using the one built into pre-commit. Beautiful! Change-Id: I89398d4a1c5d4e7205f5f9c499cba0b4ff90fa46 Signed-off-by: Stephen Finucane --- .pre-commit-config.yaml | 2 ++ tox.ini | 48 +++++++++++++++-------------------------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e55574fbddf..34547655a589 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,8 @@ repos: - id: debug-statements # nova/cmd/manage.py imports pdb on purpose. exclude: 'nova/cmd/manage.py' + - id: check-json + files: .*\.json$ - id: check-yaml files: .*\.(yaml|yml)$ - repo: https://github.com/Lucas-C/pre-commit-hooks diff --git a/tox.ini b/tox.ini index 3df9d470dffd..c96276de2dad 100644 --- a/tox.ini +++ b/tox.ini @@ -107,43 +107,29 @@ extras = commands = bash tools/mypywrap.sh {posargs} +[testenv:pep8] +description = + Run style checks. +deps = + pre-commit +extras = +commands = + pre-commit run --all-files --show-diff-on-failure + +[testenv:autopep8] +extras = +deps = + pre-commit +commands = + pre-commit run --all-files --show-diff-on-failure autopep8 + [testenv:codespell] description = Run codespell to check spelling. deps = pre-commit commands = - pre-commit run codespell --all-files --show-diff-on-failure - -[testenv:pep8] -description = - Run style checks. -deps = - {[testenv]deps} - {[testenv:codespell]deps} - autopep8 -extras = -commands = - {[testenv:mypy]commands} - {[testenv:codespell]commands} - # check if autopep8 would alter the formatting but don't actually change it - # so we can gate on this in the ci - autopep8 --exit-code --max-line-length=79 --diff -r nova doc setup.py - # since autopep8 only tries to make minimal changes to conform to pep8 we still need to run - # our hacking and flake8 check to keep our existing code style consistent. - # The full list of issues addressable by autopep8 can be found here - # https://pypi.org/project/autopep8/#features - bash tools/flake8wrap.sh {posargs} - # Check that all JSON files don't have \r\n in line. - bash -c "! find doc/ -type f -name *.json | xargs grep -U -n $'\r'" - # Check that all included JSON files are valid JSON - bash -c '! find doc/ -type f -name *.json | xargs -t -n1 python -m json.tool 2>&1> /dev/null | grep -B1 -v ^python' - -[testenv:autopep8] -extras = -deps = autopep8 -commands = - autopep8 --exit-code --max-line-length=79 --in-place -r nova doc setup.py + pre-commit run --all-files --show-diff-on-failure codespell [testenv:fast8] description =

AltStyle によって変換されたページ (->オリジナル) /