diff --git a/.cruft.json b/.cruft.json index 09f389b..d6a03e3 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "/home/runner/work/cookiecutter-scverse/cookiecutter-scverse", - "commit": "31733e798d89018e590c2586962c153d38057dad", + "commit": "ba8ba4359df21973a17be78d182f4a7361727098", "checkout": null, "context": { "cookiecutter": { @@ -37,7 +37,7 @@ "trim_blocks": true }, "_template": "/home/runner/work/cookiecutter-scverse/cookiecutter-scverse", - "_commit": "31733e798d89018e590c2586962c153d38057dad" + "_commit": "ba8ba4359df21973a17be78d182f4a7361727098" } }, "directory": null diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0284b58..2f7ed62 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,37 +11,42 @@ repos: hooks: - id: biome-format exclude: ^\.cruft\.json$ # inconsistent indentation with cruft - file never to be modified manually. + groups: [format] - repo: https://github.com/tox-dev/pyproject-fmt rev: v2.25.3 hooks: - id: pyproject-fmt + groups: [format] - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.15.22 hooks: - id: ruff-check - types_or: [python, pyi, jupyter] args: [--fix, --exit-non-zero-on-fix] - id: ruff-format - types_or: [python, pyi, jupyter] + groups: [format] - repo: local hooks: - id: mypy name: mypy - entry: uv run --group test mypy src tests + entry: hatch check types language: system types: [python] files: ^(src|tests)/ require_serial: true pass_filenames: false + groups: [typecheck] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: - id: detect-private-key - id: check-ast - id: end-of-file-fixer + groups: [format] - id: mixed-line-ending args: [--fix=lf] + groups: [format] - id: trailing-whitespace + groups: [format] - id: check-case-conflict # Check that there are no merge conflicts (could be generated by template sync) - id: check-merge-conflict diff --git a/docs/contributing.md b/docs/contributing.md index 798c1c5..f31c190 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -153,10 +153,12 @@ We recommend running them with [prek][], a fast, drop-in replacement for `pre-co On every commit, the checks will either automatically fix issues with the code, or raise an error message. See [pre-commit checks](template_usage.md#pre-commit-checks) for a full list of checks enabled for this repository. -To enable the checks locally, install [prek][] (e.g. with `uv tool install prek`) and run +To enable the checks locally, run ```bash -prek install +hatch run hatch-check-code:prek install +# or +uvx prek install ``` in the root of the repository. diff --git a/docs/template_usage.md b/docs/template_usage.md index 1a769ab..b191b70 100644 --- a/docs/template_usage.md +++ b/docs/template_usage.md @@ -194,7 +194,7 @@ This template uses a number of pre-commit checks. In this section we'll detail what is used, where they're defined, and how to modify these checks. To run the checks locally, we recommend [prek][], a fast, drop-in replacement for `pre-commit` that reads the same `.pre-commit-config.yaml`. -Install it (e.g. with `uv tool install prek`) and run `prek install` once to set up the git hook, then `prek run --all-files` to check the whole repository. +Set up the git hook once by running `prek install` (e.g. `uvx prek install`), then `hatch check --fix` to format and check the whole repository. ### Overview of pre-commit hooks used by the template diff --git a/pyproject.toml b/pyproject.toml index 1661a3b..627ca78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,8 +33,6 @@ urls.Source = "https://github.com/scverse/cookiecutter-scverse-instance" [dependency-groups] dev = [ - "mypy", - "prek", "twine>=4.0.2", ] test = [ @@ -57,6 +55,10 @@ doc = [ "sphinxcontrib-katex", "sphinxext-opengraph", ] +typecheck = [ + "mypy", + # add any stub packages that you might need here +] [tool.hatch] envs.default.installer = "uv" @@ -77,6 +79,15 @@ envs.hatch-test.overrides.matrix.deps.env-vars = [ { value = "allow", key = "UV_PRERELEASE", if = [ "pre" ] }, ] envs.hatch-test.dependency-groups = [ "dev", "test" ] +envs.hatch-check-fmt.dependencies = [ "prek" ] +envs.hatch-check-fmt.scripts.format-fix = "prek run -a --group=format --no-group=typecheck" +envs.hatch-check-code.dependencies = [ "prek" ] +envs.hatch-check-code.scripts.lint-fix = "prek run -a --no-group=format --no-group=typecheck" +envs.hatch-check-types.dependencies = [ "mypy" ] +envs.hatch-check-types.scripts.check = [ "mypy" ] + +[tool.mypy] +files = [ "src", "tests" ] [tool.ruff] line-length = 120