diff --git a/.cruft.json b/.cruft.json index f7f1f4bb..330e025d 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "/home/runner/work/cookiecutter-scverse/cookiecutter-scverse", - "commit": "707f3faab836f9272912f92188b63b31da70c064", + "commit": "b1491b8903480508809046cac5889510da46f395", "checkout": null, "context": { "cookiecutter": { @@ -37,7 +37,7 @@ "trim_blocks": true }, "_template": "/home/runner/work/cookiecutter-scverse/cookiecutter-scverse", - "_commit": "707f3faab836f9272912f92188b63b31da70c064" + "_commit": "b1491b8903480508809046cac5889510da46f395" } }, "directory": null diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c6d9c514..1ae6fdf3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,48 +7,53 @@ default_stages: minimum_pre_commit_version: 2.16.0 repos: - repo: https://github.com/biomejs/pre-commit - rev: v2.5.5 + rev: v2.5.6 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.26.0 hooks: - id: pyproject-fmt + groups: [format] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.16.0 + rev: v0.16.1 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 args: [--assume-in-merge] - repo: https://github.com/zizmorcore/zizmor-pre-commit - rev: v1.28.0 + rev: v1.29.0 hooks: - id: zizmor args: [--no-progress, --fix] diff --git a/docs/contributing.md b/docs/contributing.md index 798c1c5e..f31c190c 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 1a769aba..b191b706 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 7e62ad01..c4bbda6d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,8 +34,6 @@ urls.Source = "https://github.com/scverse/cookiecutter-scverse-instance" [dependency-groups] dev = [ - "mypy", - "prek", "twine>=4.0.2", ] test = [ @@ -58,6 +56,10 @@ doc = [ "sphinxcontrib-katex", "sphinxext-opengraph", ] +typecheck = [ + "mypy", + "pandas-stubs", +] [tool.hatch] envs.default.installer = "uv" @@ -78,6 +80,14 @@ 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-check = "echo 'try `hatch check fmt --fix`'; false" +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-check = "echo 'try `hatch check code --fix`'; false" +envs.hatch-check-code.scripts.lint-fix = "prek run -a --no-group=format --no-group=typecheck" +envs.hatch-check-types.scripts.check = [ "mypy" ] +envs.hatch-check-types.dependency-groups = [ "typecheck", "test" ] [tool.ruff] line-length = 120 @@ -117,6 +127,9 @@ lint.per-file-ignores."docs/*" = [ "I" ] lint.per-file-ignores."tests/*" = [ "D" ] lint.pydocstyle.convention = "numpy" +[tool.mypy] +files = [ "src", "tests" ] + [tool.pytest] addopts = [ "--import-mode=importlib", # allow using test files with same name