From 025c87c6ff3b4a26f6a30d3d88b51163b0c2f917 Mon Sep 17 00:00:00 2001 From: Niels Bantilan Date: Fri, 13 Mar 2026 10:43:13 -0400 Subject: [PATCH 1/3] add prek Signed-off-by: Niels Bantilan --- .pre-commit-config.yaml | 20 -------------------- Makefile | 7 +++++-- maint_tools/uvlock.sh | 10 ++++++++++ prek.toml | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 22 deletions(-) delete mode 100644 .pre-commit-config.yaml create mode 100755 maint_tools/uvlock.sh create mode 100644 prek.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index ca576e41a..000000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,20 +0,0 @@ -repos: - - repo: https://github.com/astral-sh/ruff-pre-commit - # Ruff version. - rev: v0.15.2 - hooks: - # Run the linter. - - id: ruff - args: [--fix, --show-fixes] - # Run the formatter. - - id: ruff-format - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 - hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace - - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.9.0.6 - hooks: - - id: shellcheck diff --git a/Makefile b/Makefile index 870ded5f3..be229f192 100644 --- a/Makefile +++ b/Makefile @@ -6,10 +6,13 @@ help: .DEFAULT_GOAL := help +.PHONY: install-prek +install-prek: + curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/download/v0.3.5/prek-installer.sh | sh + .PHONY: fmt fmt: - uv run python -m ruff format - uv run python -m ruff check . --fix + prek ruff .PHONY: mypy mypy: diff --git a/maint_tools/uvlock.sh b/maint_tools/uvlock.sh new file mode 100755 index 000000000..724004eeb --- /dev/null +++ b/maint_tools/uvlock.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -euo pipefail + +uv lock +for dir in plugins/*/; do + if [ -f "$dir/uv.lock" ]; then + echo "Checking $dir..." + uv lock --directory "$dir" + fi +done diff --git a/prek.toml b/prek.toml new file mode 100644 index 000000000..137bb43ee --- /dev/null +++ b/prek.toml @@ -0,0 +1,34 @@ +[[repos]] +repo = "https://github.com/astral-sh/ruff-pre-commit" +rev = "v0.15.2" +hooks = [ + { id = "ruff", args = ["--fix", "--show-fixes"] }, + { id = "ruff-format" }, +] + +[[repos]] +repo = "https://github.com/pre-commit/pre-commit-hooks" +rev = "v5.0.0" +hooks = [ + { id = "check-yaml" }, + { id = "end-of-file-fixer" }, + { id = "trailing-whitespace" }, +] + +[[repos]] +repo = "https://github.com/shellcheck-py/shellcheck-py" +rev = "v0.9.0.6" +hooks = [ + { id = "shellcheck" }, +] + +[[repos]] +repo = "local" + +[[repos.hooks]] +id = "uvlock" +name = "uv lock" +language = "system" +entry = "bash maint_tools/uvlock.sh" +pass_filenames = false +files = "(^|/)pyproject\\.toml$|(^|/)uv\\.lock$" From fa168dcd668fd76579f828f48099e1194686e3e2 Mon Sep 17 00:00:00 2001 From: Niels Bantilan Date: Fri, 13 Mar 2026 10:48:40 -0400 Subject: [PATCH 2/3] add (optional) use of prek Signed-off-by: Niels Bantilan --- Makefile | 7 ++++--- prek.toml | 42 +++++++++++++++++------------------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index be229f192..db9d3e917 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,14 @@ help: .DEFAULT_GOAL := help -.PHONY: install-prek -install-prek: +.PHONY: prek-install +prek-install: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/download/v0.3.5/prek-installer.sh | sh .PHONY: fmt fmt: - prek ruff + uv run python -m ruff format + uv run python -m ruff check . --fix .PHONY: mypy mypy: diff --git a/prek.toml b/prek.toml index 137bb43ee..f4d04bd9c 100644 --- a/prek.toml +++ b/prek.toml @@ -1,34 +1,26 @@ [[repos]] -repo = "https://github.com/astral-sh/ruff-pre-commit" -rev = "v0.15.2" -hooks = [ - { id = "ruff", args = ["--fix", "--show-fixes"] }, - { id = "ruff-format" }, -] - -[[repos]] -repo = "https://github.com/pre-commit/pre-commit-hooks" -rev = "v5.0.0" -hooks = [ - { id = "check-yaml" }, - { id = "end-of-file-fixer" }, - { id = "trailing-whitespace" }, -] +repo = "local" -[[repos]] -repo = "https://github.com/shellcheck-py/shellcheck-py" -rev = "v0.9.0.6" -hooks = [ - { id = "shellcheck" }, -] +[[repos.hooks]] +id = "fmt" +name = "make fmt" +language = "system" +entry = "make fmt" +pass_filenames = false +files = "\\.py$" -[[repos]] -repo = "local" +[[repos.hooks]] +id = "mypy" +name = "make mypy" +language = "system" +entry = "make mypy" +pass_filenames = false +files = "\\.py$" [[repos.hooks]] id = "uvlock" -name = "uv lock" +name = "make uvlock" language = "system" -entry = "bash maint_tools/uvlock.sh" +entry = "make uvlock" pass_filenames = false files = "(^|/)pyproject\\.toml$|(^|/)uv\\.lock$" From ba9950d10347473500b55d3d62351fde15cfadf1 Mon Sep 17 00:00:00 2001 From: Niels Bantilan Date: Fri, 13 Mar 2026 10:49:48 -0400 Subject: [PATCH 3/3] update makefile Signed-off-by: Niels Bantilan --- Makefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Makefile b/Makefile index db9d3e917..baa6e3afe 100644 --- a/Makefile +++ b/Makefile @@ -24,13 +24,7 @@ mypy: .PHONY: uvlock uvlock: - uv lock - for dir in plugins/*/; do \ - if [ -f "$$dir/uv.lock" ]; then \ - echo "Checking $$dir..."; \ - uv lock --directory "$$dir"; \ - fi \ - done + bash maint_tools/uvlock.sh .PHONY: lint lint-fix: