diff --git a/.cruft.json b/.cruft.json index 09f389bd..f790eab9 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "/home/runner/work/cookiecutter-scverse/cookiecutter-scverse", - "commit": "31733e798d89018e590c2586962c153d38057dad", + "commit": "2aa744197ecb205b364ad33055531d0462bbc312", "checkout": null, "context": { "cookiecutter": { @@ -37,7 +37,7 @@ "trim_blocks": true }, "_template": "/home/runner/work/cookiecutter-scverse/cookiecutter-scverse", - "_commit": "31733e798d89018e590c2586962c153d38057dad" + "_commit": "2aa744197ecb205b364ad33055531d0462bbc312" } }, "directory": null diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0284b58e..a722f3ea 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.4 + rev: v2.5.5 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 + rev: v2.26.0 hooks: - id: pyproject-fmt + groups: [format] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.22 + rev: v0.16.0 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.27.0 + rev: v1.28.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 1661a3b0..c4bbda6d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", + "Typing :: Typed", ] dependencies = [ "anndata>=0.13", @@ -33,8 +34,6 @@ urls.Source = "https://github.com/scverse/cookiecutter-scverse-instance" [dependency-groups] dev = [ - "mypy", - "prek", "twine>=4.0.2", ] test = [ @@ -57,6 +56,10 @@ doc = [ "sphinxcontrib-katex", "sphinxext-opengraph", ] +typecheck = [ + "mypy", + "pandas-stubs", +] [tool.hatch] envs.default.installer = "uv" @@ -77,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 @@ -116,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 diff --git a/src/cookiecutter_scverse_instance/py.typed b/src/cookiecutter_scverse_instance/py.typed new file mode 100644 index 00000000..e69de29b