From 3cb69aacff928b0cea5388b12c282b057fb83819 Mon Sep 17 00:00:00 2001 From: Sam Cunliffe Date: Tue, 6 Oct 2026 12:01:56 +0100 Subject: [PATCH 1/3] Switch from .pre-commit-config.yaml to prek.toml --- .pre-commit-config.yaml | 64 ------------ prek.toml | 97 +++++++++++++++++++ .../.pre-commit-config.yaml | 60 ------------ {{cookiecutter.project_slug}}/prek.toml | 90 +++++++++++++++++ 4 files changed, 187 insertions(+), 124 deletions(-) delete mode 100644 .pre-commit-config.yaml create mode 100644 prek.toml delete mode 100644 {{cookiecutter.project_slug}}/.pre-commit-config.yaml create mode 100644 {{cookiecutter.project_slug}}/prek.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index b1760833..00000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,64 +0,0 @@ -exclude: ^{{cookiecutter.project_slug}}/|^tests/data/test_package_generation/ -repos: - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.19 - hooks: - - id: ruff-check - args: - - --config=pyproject.toml - - id: ruff-format - args: - - --config=pyproject.toml - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.49.1 - hooks: - - id: markdownlint-fix - args: - - --dot - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.6 - hooks: - - id: forbid-tabs - - repo: https://github.com/pappasam/toml-sort - rev: v0.24.4 - hooks: - - id: toml-sort-fix - - repo: https://github.com/astral-sh/ty-pre-commit - rev: v0.0.79 - hooks: - - id: ty - args: - - --group=typechecking - - --isolated - - --no-default-groups - - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.8.4 - hooks: - - id: prettier - args: - - --quote-props=as-needed - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: check-case-conflict - - id: check-docstring-first - - id: check-merge-conflict - - id: end-of-file-fixer - - id: mixed-line-ending - args: - - --fix=lf - - id: trailing-whitespace - - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.38.0 - hooks: - # Schemas taken from https://www.schemastore.org/json/ - - id: check-jsonschema - name: "Validate GitHub issue templates" - files: ^\.github/ISSUE_TEMPLATE/.*\.yml$ - exclude: ^\.github/ISSUE_TEMPLATE/config\.yml$ - args: - [ - "--verbose", - "--schemafile", - ".github/schemas/github-issue-forms.json", - ] diff --git a/prek.toml b/prek.toml new file mode 100644 index 00000000..c7e54f7e --- /dev/null +++ b/prek.toml @@ -0,0 +1,97 @@ +#:schema https://www.schemastore.org/prek.json + +exclude = "^{{cookiecutter.project_slug}}/|^tests/data/test_package_generation/" + +[[repos]] +repo = "https://github.com/astral-sh/ruff-pre-commit" +rev = "v0.15.19" +hooks = [ + { + id = "ruff-check", + args = ["--config=pyproject.toml"] + }, + { + id = "ruff-format", + args = ["--config=pyproject.toml"] + } +] + +[[repos]] +repo = "https://github.com/igorshubovych/markdownlint-cli" +rev = "v0.49.1" +hooks = [ + { + id = "markdownlint-fix", + args = ["--dot"] + } +] + +[[repos]] +repo = "https://github.com/Lucas-C/pre-commit-hooks" +rev = "v1.5.6" +hooks = [ + { id = "forbid-tabs" } +] + +[[repos]] +repo = "https://github.com/pappasam/toml-sort" +rev = "v0.24.4" +hooks = [ + { id = "toml-sort-fix" } +] + +[[repos]] +repo = "https://github.com/astral-sh/ty-pre-commit" +rev = "v0.0.79" +hooks = [ + { + id = "ty", + args = [ + "--group=typechecking", + "--isolated", + "--no-default-groups" + ] + } +] + +[[repos]] +repo = "https://github.com/rbubley/mirrors-prettier" +rev = "v3.8.4" +hooks = [ + { + id = "prettier", + args = ["--quote-props=as-needed"] + } +] + +[[repos]] +repo = "https://github.com/pre-commit/pre-commit-hooks" +rev = "v6.0.0" +hooks = [ + { id = "check-case-conflict" }, + { id = "check-docstring-first" }, + { id = "check-merge-conflict" }, + { id = "end-of-file-fixer" }, + { + id = "mixed-line-ending", + args = ["--fix=lf"] + }, + { id = "trailing-whitespace" } +] + +[[repos]] +repo = "https://github.com/python-jsonschema/check-jsonschema" +rev = "0.38.0" +hooks = [ + { + id = "check-jsonschema", + name = "Validate GitHub issue templates", + files = '^\.github/ISSUE_TEMPLATE/.*\.yml$', + exclude = '^\.github/ISSUE_TEMPLATE/config\.yml$', + args = [ + "--verbose", + "--schemafile", + ".github/schemas/github-issue-forms.json" + ] + } +] diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml deleted file mode 100644 index 451c91a1..00000000 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ /dev/null @@ -1,60 +0,0 @@ -repos: - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.19 - hooks: - - id: ruff-check - - id: ruff-format - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.49.1 - hooks: - - id: markdownlint-fix - args: - - --dot - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.6 - hooks: - - id: forbid-tabs - - repo: https://github.com/pappasam/toml-sort - rev: v0.24.4 - hooks: - - id: toml-sort-fix - - repo: https://github.com/astral-sh/ty-pre-commit - rev: v0.0.79 - hooks: - - id: ty - args: - - --group=typechecking - - --isolated - - --no-default-groups - - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.8.4 - hooks: - - id: prettier - args: - - --quote-props=as-needed - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: check-case-conflict - - id: check-docstring-first - - id: check-merge-conflict - - id: check-toml - - id: end-of-file-fixer - - id: mixed-line-ending - args: - - --fix=lf - - id: trailing-whitespace - - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.38.0 - hooks: - # Schemas taken from https://www.schemastore.org/json/ - - id: check-jsonschema - name: "Validate GitHub issue templates" - files: ^\.github/ISSUE_TEMPLATE/.*\.yml$ - exclude: ^\.github/ISSUE_TEMPLATE/config\.yml$ - args: - [ - "--verbose", - "--schemafile", - ".github/schemas/github-issue-forms.json", - ] diff --git a/{{cookiecutter.project_slug}}/prek.toml b/{{cookiecutter.project_slug}}/prek.toml new file mode 100644 index 00000000..186aa244 --- /dev/null +++ b/{{cookiecutter.project_slug}}/prek.toml @@ -0,0 +1,90 @@ +#:schema https://www.schemastore.org/prek.json + +[[repos]] +repo = "https://github.com/astral-sh/ruff-pre-commit" +rev = "v0.15.19" +hooks = [ + { id = "ruff-check" }, + { id = "ruff-format" } +] + +[[repos]] +repo = "https://github.com/igorshubovych/markdownlint-cli" +rev = "v0.49.1" +hooks = [ + { + id = "markdownlint-fix", + args = ["--dot"] + } +] + +[[repos]] +repo = "https://github.com/Lucas-C/pre-commit-hooks" +rev = "v1.5.6" +hooks = [ + { id = "forbid-tabs" } +] + +[[repos]] +repo = "https://github.com/pappasam/toml-sort" +rev = "v0.24.4" +hooks = [ + { id = "toml-sort-fix" } +] + +[[repos]] +repo = "https://github.com/astral-sh/ty-pre-commit" +rev = "v0.0.79" +hooks = [ + { + id = "ty", + args = [ + "--group=typechecking", + "--isolated", + "--no-default-groups" + ] + } +] + +[[repos]] +repo = "https://github.com/rbubley/mirrors-prettier" +rev = "v3.8.4" +hooks = [ + { + id = "prettier", + args = ["--quote-props=as-needed"] + } +] + +[[repos]] +repo = "https://github.com/pre-commit/pre-commit-hooks" +rev = "v6.0.0" +hooks = [ + { id = "check-case-conflict" }, + { id = "check-docstring-first" }, + { id = "check-merge-conflict" }, + { id = "check-toml" }, + { id = "end-of-file-fixer" }, + { + id = "mixed-line-ending", + args = ["--fix=lf"] + }, + { id = "trailing-whitespace" } +] + +[[repos]] +repo = "https://github.com/python-jsonschema/check-jsonschema" +rev = "0.38.0" +hooks = [ + { + id = "check-jsonschema", + name = "Validate GitHub issue templates", + files = '^\.github/ISSUE_TEMPLATE/.*\.yml$', + exclude = '^\.github/ISSUE_TEMPLATE/config\.yml$', + args = [ + "--verbose", + "--schemafile", + ".github/schemas/github-issue-forms.json" + ] + } +] From cd9ae5dc177032bd6afc75abe4d9d1044c55358b Mon Sep 17 00:00:00 2001 From: Sam Cunliffe Date: Tue, 6 Oct 2026 12:51:08 +0100 Subject: [PATCH 2/3] Replace in the tests and CI caches. Toml sort prek itself. Fix some docs. Add prek (and other) badges. --- .github/workflows/linting.yml | 4 +- CONTRIBUTING.md | 8 +- docs/pages/linting.md | 2 +- docs/pages/tutorial.md | 2 +- prek.toml | 101 +++++++----------- .../.github/workflows/linting.yml | 4 +- .../.pre-commit-config.yaml | 60 ----------- tests/data/test_package_generation/prek.toml | 62 +++++++++++ .../.github/workflows/linting.yml | 4 +- {{cookiecutter.project_slug}}/prek.toml | 88 ++++++--------- 10 files changed, 144 insertions(+), 191 deletions(-) delete mode 100644 tests/data/test_package_generation/.pre-commit-config.yaml create mode 100644 tests/data/test_package_generation/prek.toml diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index f45a4b8d..40a083dc 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -18,7 +18,7 @@ jobs: uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cache/prek - key: prek-${{ hashFiles('.pre-commit-config.yaml') }} + key: prek-${{ hashFiles('prek.toml') }} - name: Set up python uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 @@ -41,7 +41,7 @@ jobs: uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cache/prek - key: prek-${{ hashFiles('.pre-commit-config.yaml') }} + key: prek-${{ hashFiles('prek.toml') }} - name: Set up python uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 17d5c2d0..eb73633e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,11 @@ # Contributing Guide +[![Link Checker](https://github.com/UCL-ARC/python-tooling/actions/workflows/links.yml/badge.svg)](https://github.com/UCL-ARC/python-tooling/actions/workflows/links.yml) +[![Linting](https://github.com/UCL-ARC/python-tooling/actions/workflows/linting.yml/badge.svg)](https://github.com/UCL-ARC/python-tooling/actions/workflows/linting.yml) +[![Run template tests](https://github.com/UCL-ARC/python-tooling/actions/workflows/test.yml/badge.svg)](https://github.com/UCL-ARC/python-tooling/actions/workflows/test.yml) +[![SPEC 0 — Minimum Supported Dependencies](https://img.shields.io/badge/SPEC-0-green?labelColor=%23004811&color=%235CA038)](https://scientific-python.org/specs/spec-0000/) +[![prek](https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge.svg)](https://github.com/j178/prek) + This template and our [recommendation pages][website] were made by [research software engineers] at [UCL's Centre for Advanced Research Computing][UCL ARC]. We made it with research software projects in mind, but whoever you are, we hope @@ -62,8 +68,6 @@ branch you want to test. #### Python version support -[![SPEC 0 — Minimum Supported Dependencies](https://img.shields.io/badge/SPEC-0-green?labelColor=%23004811&color=%235CA038)](https://scientific-python.org/specs/spec-0000/) - We follow Scientific Python's [SPEC 0](https://scientific-python.org/specs/spec-0000/) policy. Notably this means our template will support [Python versions for three years after their release](https://scientific-python.org/specs/spec-0000/#support-window), and changes to the template are required to pass tests in all such python versions. (See [the CI checks](./.github/workflows/test.yml) for precise details.) diff --git a/docs/pages/linting.md b/docs/pages/linting.md index e426d7e6..87ee97e0 100644 --- a/docs/pages/linting.md +++ b/docs/pages/linting.md @@ -6,7 +6,7 @@ layout: default ## Linting See -[here for an example configuration](https://github.com/UCL-ARC/python-tooling/blob/main/%7B%7Bcookiecutter.project_slug%7D%7D/.pre-commit-config.yaml) +[here for an example configuration](https://github.com/UCL-ARC/python-tooling/blob/main/%7B%7Bcookiecutter.project_slug%7D%7D/prek.toml) for some of these. ### Code formatting diff --git a/docs/pages/tutorial.md b/docs/pages/tutorial.md index f8290cac..694bbba9 100644 --- a/docs/pages/tutorial.md +++ b/docs/pages/tutorial.md @@ -400,7 +400,7 @@ The built documentation will be output to a directory `site`. The package is set-up to use [prek](https://prek.j178.dev/), a framework for running [Git hook scripts](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) on each commit to the repository. -There is a `.pre-commit-config.yaml` configuration file which you can take a look at. +There is a `prek.toml` configuration file which you can take a look at. With this setup `prek` will run a series of fast linters, checks and formatters on the repository on every commit. The main tools we recommend are [ruff](https://docs.astral.sh/ruff/), [ty](https://docs.astral.sh/ty/) and [prettier](https://prettier.io/). diff --git a/prek.toml b/prek.toml index c7e54f7e..d98d23ab 100644 --- a/prek.toml +++ b/prek.toml @@ -1,97 +1,72 @@ -#:schema https://www.schemastore.org/prek.json +# Configuration file for `prek`, a git hook framework written in Rust. +# See https://prek.j178.dev for more information. +# :schema https://www.schemastore.org/prek.json exclude = "^{{cookiecutter.project_slug}}/|^tests/data/test_package_generation/" [[repos]] -repo = "https://github.com/astral-sh/ruff-pre-commit" -rev = "v0.15.19" hooks = [ - { - id = "ruff-check", - args = ["--config=pyproject.toml"] - }, - { - id = "ruff-format", - args = ["--config=pyproject.toml"] - } + {args = [ + "--config=pyproject.toml", + ], id = "ruff-check"}, + {args = [ + "--config=pyproject.toml", + ], id = "ruff-format"}, ] +repo = "https://github.com/astral-sh/ruff-pre-commit" +rev = "v0.15.19" [[repos]] +hooks = [{args = ["--dot"], id = "markdownlint-fix"}] repo = "https://github.com/igorshubovych/markdownlint-cli" rev = "v0.49.1" -hooks = [ - { - id = "markdownlint-fix", - args = ["--dot"] - } -] [[repos]] +hooks = [{id = "forbid-tabs"}] repo = "https://github.com/Lucas-C/pre-commit-hooks" rev = "v1.5.6" -hooks = [ - { id = "forbid-tabs" } -] [[repos]] +hooks = [{id = "toml-sort-fix"}] repo = "https://github.com/pappasam/toml-sort" rev = "v0.24.4" -hooks = [ - { id = "toml-sort-fix" } -] [[repos]] -repo = "https://github.com/astral-sh/ty-pre-commit" -rev = "v0.0.79" hooks = [ - { - id = "ty", - args = [ - "--group=typechecking", - "--isolated", - "--no-default-groups" - ] - } + {args = [ + "--group=typechecking", + "--isolated", + "--no-default-groups", + ], id = "ty"}, ] +repo = "https://github.com/astral-sh/ty-pre-commit" +rev = "v0.0.79" [[repos]] +hooks = [{args = ["--quote-props=as-needed"], id = "prettier"}] repo = "https://github.com/rbubley/mirrors-prettier" rev = "v3.8.4" -hooks = [ - { - id = "prettier", - args = ["--quote-props=as-needed"] - } -] [[repos]] -repo = "https://github.com/pre-commit/pre-commit-hooks" -rev = "v6.0.0" hooks = [ - { id = "check-case-conflict" }, - { id = "check-docstring-first" }, - { id = "check-merge-conflict" }, - { id = "end-of-file-fixer" }, - { - id = "mixed-line-ending", - args = ["--fix=lf"] - }, - { id = "trailing-whitespace" } + {args = [ + "--fix=lf", + ], id = "mixed-line-ending"}, + {id = "check-case-conflict"}, + {id = "check-docstring-first"}, + {id = "check-merge-conflict"}, + {id = "end-of-file-fixer"}, + {id = "trailing-whitespace"}, ] +repo = "https://github.com/pre-commit/pre-commit-hooks" +rev = "v6.0.0" [[repos]] -repo = "https://github.com/python-jsonschema/check-jsonschema" -rev = "0.38.0" hooks = [ - { - id = "check-jsonschema", - name = "Validate GitHub issue templates", - files = '^\.github/ISSUE_TEMPLATE/.*\.yml$', - exclude = '^\.github/ISSUE_TEMPLATE/config\.yml$', - args = [ - "--verbose", - "--schemafile", - ".github/schemas/github-issue-forms.json" - ] - } + {args = [ + "--schemafile=.github/schemas/github-issue-forms.json", + "--verbose", + ], exclude = '^\.github/ISSUE_TEMPLATE/config\.yml$', files = '^\.github/ISSUE_TEMPLATE/.*\.yml$', id = "check-jsonschema", name = "Validate GitHub issue templates"}, ] +repo = "https://github.com/python-jsonschema/check-jsonschema" +rev = "0.38.0" diff --git a/tests/data/test_package_generation/.github/workflows/linting.yml b/tests/data/test_package_generation/.github/workflows/linting.yml index 85ec9970..27361e25 100644 --- a/tests/data/test_package_generation/.github/workflows/linting.yml +++ b/tests/data/test_package_generation/.github/workflows/linting.yml @@ -17,14 +17,14 @@ jobs: uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cache/prek - key: prek-${{ hashFiles('.pre-commit-config.yaml') }} + key: prek-${{ hashFiles('prek.toml') }} - name: Set up python uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: "3.x" cache: pip - cache-dependency-path: pyproject.toml + cache-dependency-path: prek.toml - name: Install dependencies run: python -m pip install prek diff --git a/tests/data/test_package_generation/.pre-commit-config.yaml b/tests/data/test_package_generation/.pre-commit-config.yaml deleted file mode 100644 index 451c91a1..00000000 --- a/tests/data/test_package_generation/.pre-commit-config.yaml +++ /dev/null @@ -1,60 +0,0 @@ -repos: - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.19 - hooks: - - id: ruff-check - - id: ruff-format - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.49.1 - hooks: - - id: markdownlint-fix - args: - - --dot - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.6 - hooks: - - id: forbid-tabs - - repo: https://github.com/pappasam/toml-sort - rev: v0.24.4 - hooks: - - id: toml-sort-fix - - repo: https://github.com/astral-sh/ty-pre-commit - rev: v0.0.79 - hooks: - - id: ty - args: - - --group=typechecking - - --isolated - - --no-default-groups - - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.8.4 - hooks: - - id: prettier - args: - - --quote-props=as-needed - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: check-case-conflict - - id: check-docstring-first - - id: check-merge-conflict - - id: check-toml - - id: end-of-file-fixer - - id: mixed-line-ending - args: - - --fix=lf - - id: trailing-whitespace - - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.38.0 - hooks: - # Schemas taken from https://www.schemastore.org/json/ - - id: check-jsonschema - name: "Validate GitHub issue templates" - files: ^\.github/ISSUE_TEMPLATE/.*\.yml$ - exclude: ^\.github/ISSUE_TEMPLATE/config\.yml$ - args: - [ - "--verbose", - "--schemafile", - ".github/schemas/github-issue-forms.json", - ] diff --git a/tests/data/test_package_generation/prek.toml b/tests/data/test_package_generation/prek.toml new file mode 100644 index 00000000..b6652f2f --- /dev/null +++ b/tests/data/test_package_generation/prek.toml @@ -0,0 +1,62 @@ +# :schema https://www.schemastore.org/prek.json + +[[repos]] +hooks = [{id = "ruff-check"}, {id = "ruff-format"}] +repo = "https://github.com/astral-sh/ruff-pre-commit" +rev = "v0.15.19" + +[[repos]] +hooks = [{args = ["--dot"], id = "markdownlint-fix"}] +repo = "https://github.com/igorshubovych/markdownlint-cli" +rev = "v0.49.1" + +[[repos]] +hooks = [{id = "forbid-tabs"}] +repo = "https://github.com/Lucas-C/pre-commit-hooks" +rev = "v1.5.6" + +[[repos]] +hooks = [{id = "toml-sort-fix"}] +repo = "https://github.com/pappasam/toml-sort" +rev = "v0.24.4" + +[[repos]] +hooks = [ + {args = [ + "--group=typechecking", + "--isolated", + "--no-default-groups", + ], id = "ty"}, +] +repo = "https://github.com/astral-sh/ty-pre-commit" +rev = "v0.0.79" + +[[repos]] +hooks = [{args = ["--quote-props=as-needed"], id = "prettier"}] +repo = "https://github.com/rbubley/mirrors-prettier" +rev = "v3.8.4" + +[[repos]] +hooks = [ + {args = [ + "--fix=lf", + ], id = "mixed-line-ending"}, + {id = "check-case-conflict"}, + {id = "check-docstring-first"}, + {id = "check-merge-conflict"}, + {id = "check-toml"}, + {id = "end-of-file-fixer"}, + {id = "trailing-whitespace"}, +] +repo = "https://github.com/pre-commit/pre-commit-hooks" +rev = "v6.0.0" + +[[repos]] +hooks = [ + {args = [ + "--schemafile=.github/schemas/github-issue-forms.json", + "--verbose", + ], exclude = '^\.github/ISSUE_TEMPLATE/config\.yml$', files = '^\.github/ISSUE_TEMPLATE/.*\.yml$', id = "check-jsonschema", name = "Validate GitHub issue templates"}, +] +repo = "https://github.com/python-jsonschema/check-jsonschema" +rev = "0.38.0" diff --git a/{{cookiecutter.project_slug}}/.github/workflows/linting.yml b/{{cookiecutter.project_slug}}/.github/workflows/linting.yml index ad5fa3e7..587b0f12 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/linting.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/linting.yml @@ -17,14 +17,14 @@ jobs: uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cache/prek - key: prek-${{ '{{' }} hashFiles('.pre-commit-config.yaml') {{ '}}' }} + key: prek-${{ '{{' }} hashFiles('prek.toml') {{ '}}' }} - name: Set up python uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: "3.x" cache: pip - cache-dependency-path: pyproject.toml + cache-dependency-path: prek.toml - name: Install dependencies run: python -m pip install prek diff --git a/{{cookiecutter.project_slug}}/prek.toml b/{{cookiecutter.project_slug}}/prek.toml index 186aa244..b6652f2f 100644 --- a/{{cookiecutter.project_slug}}/prek.toml +++ b/{{cookiecutter.project_slug}}/prek.toml @@ -1,90 +1,62 @@ -#:schema https://www.schemastore.org/prek.json +# :schema https://www.schemastore.org/prek.json [[repos]] +hooks = [{id = "ruff-check"}, {id = "ruff-format"}] repo = "https://github.com/astral-sh/ruff-pre-commit" rev = "v0.15.19" -hooks = [ - { id = "ruff-check" }, - { id = "ruff-format" } -] [[repos]] +hooks = [{args = ["--dot"], id = "markdownlint-fix"}] repo = "https://github.com/igorshubovych/markdownlint-cli" rev = "v0.49.1" -hooks = [ - { - id = "markdownlint-fix", - args = ["--dot"] - } -] [[repos]] +hooks = [{id = "forbid-tabs"}] repo = "https://github.com/Lucas-C/pre-commit-hooks" rev = "v1.5.6" -hooks = [ - { id = "forbid-tabs" } -] [[repos]] +hooks = [{id = "toml-sort-fix"}] repo = "https://github.com/pappasam/toml-sort" rev = "v0.24.4" -hooks = [ - { id = "toml-sort-fix" } -] [[repos]] -repo = "https://github.com/astral-sh/ty-pre-commit" -rev = "v0.0.79" hooks = [ - { - id = "ty", - args = [ - "--group=typechecking", - "--isolated", - "--no-default-groups" - ] - } + {args = [ + "--group=typechecking", + "--isolated", + "--no-default-groups", + ], id = "ty"}, ] +repo = "https://github.com/astral-sh/ty-pre-commit" +rev = "v0.0.79" [[repos]] +hooks = [{args = ["--quote-props=as-needed"], id = "prettier"}] repo = "https://github.com/rbubley/mirrors-prettier" rev = "v3.8.4" -hooks = [ - { - id = "prettier", - args = ["--quote-props=as-needed"] - } -] [[repos]] -repo = "https://github.com/pre-commit/pre-commit-hooks" -rev = "v6.0.0" hooks = [ - { id = "check-case-conflict" }, - { id = "check-docstring-first" }, - { id = "check-merge-conflict" }, - { id = "check-toml" }, - { id = "end-of-file-fixer" }, - { - id = "mixed-line-ending", - args = ["--fix=lf"] - }, - { id = "trailing-whitespace" } + {args = [ + "--fix=lf", + ], id = "mixed-line-ending"}, + {id = "check-case-conflict"}, + {id = "check-docstring-first"}, + {id = "check-merge-conflict"}, + {id = "check-toml"}, + {id = "end-of-file-fixer"}, + {id = "trailing-whitespace"}, ] +repo = "https://github.com/pre-commit/pre-commit-hooks" +rev = "v6.0.0" [[repos]] -repo = "https://github.com/python-jsonschema/check-jsonschema" -rev = "0.38.0" hooks = [ - { - id = "check-jsonschema", - name = "Validate GitHub issue templates", - files = '^\.github/ISSUE_TEMPLATE/.*\.yml$', - exclude = '^\.github/ISSUE_TEMPLATE/config\.yml$', - args = [ - "--verbose", - "--schemafile", - ".github/schemas/github-issue-forms.json" - ] - } + {args = [ + "--schemafile=.github/schemas/github-issue-forms.json", + "--verbose", + ], exclude = '^\.github/ISSUE_TEMPLATE/config\.yml$', files = '^\.github/ISSUE_TEMPLATE/.*\.yml$', id = "check-jsonschema", name = "Validate GitHub issue templates"}, ] +repo = "https://github.com/python-jsonschema/check-jsonschema" +rev = "0.38.0" From b891a19f19623bbcc94636291b7edf4baf5a4c3c Mon Sep 17 00:00:00 2001 From: Sam Cunliffe Date: Fri, 9 Oct 2026 15:29:13 +0100 Subject: [PATCH 3/3] Add comment about toml-sort / toml schema bug. --- prek.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/prek.toml b/prek.toml index d98d23ab..6a43846e 100644 --- a/prek.toml +++ b/prek.toml @@ -1,6 +1,7 @@ # Configuration file for `prek`, a git hook framework written in Rust. # See https://prek.j178.dev for more information. # :schema https://www.schemastore.org/prek.json +# ^ Remove the space here when toml-sort/#105 is resolved. The directive should be: '#:schema' exclude = "^{{cookiecutter.project_slug}}/|^tests/data/test_package_generation/"