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..baa6e3afe 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,10 @@ help: .DEFAULT_GOAL := help +.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: uv run python -m ruff format @@ -20,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: 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..f4d04bd9c --- /dev/null +++ b/prek.toml @@ -0,0 +1,26 @@ +[[repos]] +repo = "local" + +[[repos.hooks]] +id = "fmt" +name = "make fmt" +language = "system" +entry = "make fmt" +pass_filenames = false +files = "\\.py$" + +[[repos.hooks]] +id = "mypy" +name = "make mypy" +language = "system" +entry = "make mypy" +pass_filenames = false +files = "\\.py$" + +[[repos.hooks]] +id = "uvlock" +name = "make uvlock" +language = "system" +entry = "make uvlock" +pass_filenames = false +files = "(^|/)pyproject\\.toml$|(^|/)uv\\.lock$"