From d914e553660a516febbb627b13592259bb58e388 Mon Sep 17 00:00:00 2001 From: Clawd Date: Sun, 1 Feb 2026 14:39:13 +0000 Subject: [PATCH] Migrate from pre-commit to prek - Replace pre-commit and pre-commit-hooks dependencies with prek>=0.3.0 - Use prek's builtin hooks for pre-commit-hooks compatibility - Update CI workflow cache and commands - Remove duplicate local hooks now covered by builtin - Update actions/cache to v4 Benefits: - Faster hook execution with Rust-native implementations - Single binary without Python runtime dependency - Automatic fast path for supported hooks - Better performance and disk space usage --- .github/workflows/ci.yml | 10 ++--- .pre-commit-config.yaml | 89 ++++++---------------------------------- pyproject.toml | 3 +- 3 files changed, 18 insertions(+), 84 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d406952..29e1ed6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,14 +18,14 @@ jobs: steps: - uses: actions/checkout@v4 - uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # v5.3.1 - - name: Cache pre-commit - uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 + - name: Cache prek + uses: actions/cache@v4 with: - path: ~/.cache/pre-commit - key: pre-commit-|${{ hashFiles('.pre-commit-config.yaml') }} + path: ~/.cache/prek + key: prek-|${{ hashFiles('.pre-commit-config.yaml') }} - name: Lint run: | - uv run pre-commit run --all-files + uv run prek run --all-files env: SKIP: no-commit-to-branch - name: Lint GitHub Actions diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 359020a..b246100 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,18 @@ repos: hooks: - id: shellcheck name: ✅ Check Shell files + - repo: builtin + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-json + - id: check-toml + - id: check-merge-conflict + - id: detect-private-key + - id: check-executables-have-shebangs + stages: [pre-commit, pre-push, manual] + - id: check-symlinks - repo: local hooks: - id: ruff @@ -24,56 +36,6 @@ repos: language: system entry: uv run ruff check args: [--fix, --exit-non-zero-on-fix] - - id: check-ast - name: 🐍 Check Python AST - language: system - types: [python] - entry: uv run check-ast - - id: check-case-conflict - name: 🔠 Check for case conflicts - language: system - entry: uv run check-case-conflict - - id: check-docstring-first - name: â„šī¸ Check docstring is first - language: system - types: [python] - entry: uv run check-docstring-first - - id: check-executables-have-shebangs - name: 🧐 Check that executables have shebangs - language: system - types: [text, executable] - entry: uv run check-executables-have-shebangs - stages: [pre-commit, pre-push, manual] - - id: check-json - name: īŊ› Check JSON files - language: system - types: [json] - entry: uv run check-json - - id: check-merge-conflict - name: đŸ’Ĩ Check for merge conflicts - language: system - types: [text] - entry: uv run check-merge-conflict - - id: check-symlinks - name: 🔗 Check for broken symlinks - language: system - types: [symlink] - entry: uv run check-symlinks - - id: check-toml - name: ✅ Check TOML files - language: system - types: [toml] - entry: uv run check-toml - - id: check-xml - name: ✅ Check XML files - entry: uv run check-xml - language: system - types: [xml] - - id: check-yaml - name: ✅ Check YAML files - language: system - types: [yaml] - entry: uv run check-yaml - id: codespell name: ✅ Check code for common misspellings language: system @@ -83,27 +45,6 @@ repos: .lock )$ entry: uv run codespell --ignore-words=.codespell - - id: debug-statements - name: đŸĒĩ Debug Statements and imports (Python) - language: system - types: [python] - entry: uv run debug-statement-hook - - id: detect-private-key - name: đŸ•ĩī¸ Detect Private Keys - language: system - types: [text] - entry: uv run detect-private-key - - id: end-of-file-fixer - name: ⎐ Fix End of Files - language: system - types: [text] - entry: uv run end-of-file-fixer - stages: [pre-commit, pre-push, manual] - - id: fix-byte-order-marker - name: 🚏 Fix UTF-8 byte order marker - language: system - types: [text] - entry: uv run fix-byte-order-marker - id: mypy name: 🆎 Static type checking using mypy language: system @@ -116,12 +57,6 @@ repos: types: [python] entry: uv run pytest pass_filenames: false - - id: trailing-whitespace - name: ✄ Trim Trailing Whitespace - language: system - types: [text] - entry: uv run trailing-whitespace-fixer - stages: [pre-commit, pre-push, manual] - id: yamllint name: 🎗 Check YAML files with yamllint language: system diff --git a/pyproject.toml b/pyproject.toml index 46e0d53..2e9acbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,10 +38,9 @@ packages = ["custom_components/weenect"] dev = [ "codespell>=2.3.0", "mypy>=1.15.0", - "pre-commit>=4.1.0", + "prek>=0.3.0", "yamllint>=1.35.1", "ruff>=0.9.9", - "pre-commit-hooks>=5.0.0", "pytest-homeassistant-custom-component>=0.13.195", ]