Skip to content

GH-109408: Add a make lint target #122333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ PCbuild/arm64/
PCbuild/obj/
PCbuild/win32/
Tools/unicode/data/
/.venv-pre-commit/
/autom4te.cache
/build/
/builddir/
Expand Down
29 changes: 29 additions & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading