From 38dd0d1b709d8f2f9b4ee5737c2b0f0b6eb5d9ad Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 19 Nov 2020 11:12:08 -0500 Subject: [PATCH] Only run codechecks on changed Python source files --- .pre-commit-config.yaml | 11 ++++++----- tox.ini | 14 +++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 76162535a..916b331e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,10 @@ repos: - - repo: local + - repo: "local" hooks: - - id: codechecks - name: codechecks + - id: "codechecks" + name: "codechecks" stages: ["push"] + language: "system" + files: ".py$" entry: "tox -e codechecks" - language: system - pass_filenames: false + pass_filenames: true diff --git a/tox.ini b/tox.ini index 597270e3a..b95476f58 100644 --- a/tox.ini +++ b/tox.ini @@ -95,12 +95,16 @@ setenv = # .decode(getattr(sys.stdout, "encoding", "utf8")) # `TypeError: decode() argument 1 must be string, not None` PYTHONIOENCODING=utf_8 + + # If no positional arguments are given, try to run the checks on the + # entire codebase, including various pieces of supporting code. + DEFAULT_FILES="src integration static misc setup.py" commands = - flake8 src integration static misc setup.py - python misc/coding_tools/check-umids.py src - python misc/coding_tools/check-debugging.py - python misc/coding_tools/find-trailing-spaces.py -r src static misc setup.py - python misc/coding_tools/check-miscaptures.py + flake8 {posargs:{env:DEFAULT_FILES}} + python misc/coding_tools/check-umids.py {posargs:{env:DEFAULT_FILES}} + python misc/coding_tools/check-debugging.py {posargs:{env:DEFAULT_FILES}} + python misc/coding_tools/find-trailing-spaces.py -r {posargs:{env:DEFAULT_FILES}} + python misc/coding_tools/check-miscaptures.py {posargs:{env:DEFAULT_FILES}} # If towncrier.check fails, you forgot to add a towncrier news # fragment explaining the change in this branch. Create one at