Skip to content

Commit 71740aa

Browse files
committed
Add a make lint target
1 parent d52726c commit 71740aa

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ PCbuild/arm64/
127127
PCbuild/obj/
128128
PCbuild/win32/
129129
Tools/unicode/data/
130+
/.venv-pre-commit/
130131
/autom4te.cache
131132
/build/
132133
/builddir/

Makefile.pre.in

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,6 +3100,35 @@ funny:
31003100
-o -name MANIFEST \
31013101
-o -print
31023102

3103+
.PHONY: clean-venv
3104+
clean-venv:
3105+
rm -rf .venv-pre-commit
3106+
3107+
# Create a virtual environment for pre-commit
3108+
.PHONY: pre-commit-venv
3109+
pre-commit-venv:
3110+
@if [ -d .venv-pre-commit ] ; then \
3111+
echo "pre-commit venv already exists."; \
3112+
echo "To recreate it, remove it first with \`make clean-venv'."; \
3113+
else \
3114+
echo "Creating venv for pre-commit in .venv-pre-commit"; \
3115+
if uv --version > /dev/null; then \
3116+
uv venv .venv-pre-commit; \
3117+
VIRTUAL_ENV=.venv-pre-commit uv pip install pre-commit; \
3118+
else \
3119+
$(PYTHON_FOR_REGEN) -m venv .venv-pre-commit; \
3120+
.venv-pre-commit/bin/python3 -m pip install --upgrade pip; \
3121+
.venv-pre-commit/bin/python3 -m pip install pre-commit; \
3122+
fi; \
3123+
echo "The venv has been created in the .venv-pre-commit directory"; \
3124+
fi
3125+
3126+
# Run CPython's static analysis, verification, and style checks.
3127+
.PHONY: lint
3128+
lint: pre-commit-venv
3129+
.venv-pre-commit/bin/pre-commit run --all-files
3130+
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/patchcheck/patchcheck.py
3131+
31033132
# Perform some verification checks on any modified files.
31043133
.PHONY: patchcheck
31053134
patchcheck: all

0 commit comments

Comments
 (0)