From 71740aa205b6a38ad72216c9ea3351173827cf57 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 26 Jul 2024 23:57:48 +0100 Subject: [PATCH 1/3] Add a ``make lint`` target --- .gitignore | 1 + Makefile.pre.in | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/.gitignore b/.gitignore index 8872e9d5508ff1..0d85fef7789362 100644 --- a/.gitignore +++ b/.gitignore @@ -127,6 +127,7 @@ PCbuild/arm64/ PCbuild/obj/ PCbuild/win32/ Tools/unicode/data/ +/.venv-pre-commit/ /autom4te.cache /build/ /builddir/ diff --git a/Makefile.pre.in b/Makefile.pre.in index 9ea7bc49be316c..0da93f3623ad52 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3100,6 +3100,35 @@ funny: -o -name MANIFEST \ -o -print +.PHONY: clean-venv +clean-venv: + rm -rf .venv-pre-commit + +# Create a virtual environment for pre-commit +.PHONY: pre-commit-venv +pre-commit-venv: + @if [ -d .venv-pre-commit ] ; then \ + echo "pre-commit venv already exists."; \ + echo "To recreate it, remove it first with \`make clean-venv'."; \ + else \ + echo "Creating venv for pre-commit in .venv-pre-commit"; \ + if uv --version > /dev/null; then \ + uv venv .venv-pre-commit; \ + VIRTUAL_ENV=.venv-pre-commit uv pip install pre-commit; \ + else \ + $(PYTHON_FOR_REGEN) -m venv .venv-pre-commit; \ + .venv-pre-commit/bin/python3 -m pip install --upgrade pip; \ + .venv-pre-commit/bin/python3 -m pip install pre-commit; \ + fi; \ + echo "The venv has been created in the .venv-pre-commit directory"; \ + fi + +# Run CPython's static analysis, verification, and style checks. +.PHONY: lint +lint: pre-commit-venv + .venv-pre-commit/bin/pre-commit run --all-files + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/patchcheck/patchcheck.py + # Perform some verification checks on any modified files. .PHONY: patchcheck patchcheck: all From edb0227df6943e9c082d872142810e94bcbd535c Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sat, 27 Jul 2024 00:03:46 +0100 Subject: [PATCH 2/3] tabs --- Makefile.pre.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 0da93f3623ad52..70f3fba5199a34 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3126,8 +3126,8 @@ pre-commit-venv: # Run CPython's static analysis, verification, and style checks. .PHONY: lint lint: pre-commit-venv - .venv-pre-commit/bin/pre-commit run --all-files - $(PYTHON_FOR_REGEN) $(srcdir)/Tools/patchcheck/patchcheck.py + .venv-pre-commit/bin/pre-commit run --all-files + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/patchcheck/patchcheck.py # Perform some verification checks on any modified files. .PHONY: patchcheck From 9b7f8e5270869f30dd9375327f7ff3b46a0af649 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sat, 27 Jul 2024 00:04:21 +0100 Subject: [PATCH 3/3] tabs (again) --- Makefile.pre.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 70f3fba5199a34..ceb71c38922f59 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -3120,7 +3120,7 @@ pre-commit-venv: .venv-pre-commit/bin/python3 -m pip install --upgrade pip; \ .venv-pre-commit/bin/python3 -m pip install pre-commit; \ fi; \ - echo "The venv has been created in the .venv-pre-commit directory"; \ + echo "The venv has been created in the .venv-pre-commit directory"; \ fi # Run CPython's static analysis, verification, and style checks.