Skip to content

Commit b8d345f

Browse files
committed
✨ Add pre-commit to template
Add a simple `pre-commit-config.yaml` based on Hatch, along with a hatch environment for installing and running the pre-commit hooks.
1 parent 4a11d8f commit b8d345f

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

docs/design.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,17 @@ We use [MyST Markdown](https://mystmd.org/) for our AiiDA plugin package documen
3939
We want to use a Markdown-based documentation tool for simplicity, avoiding Sphinx' reStructuredText format.
4040
The main reason to use this over [MkDocs](https://www.mkdocs.org/) to test the Jupyter notebook integration, especially the "executable content".
4141
MyST is also easy to integrate with Sphinx, which has a lot of powerful tools, especially for scientific software.
42+
43+
## DevOps
44+
45+
This template includes development automation tools that ensure code quality, consistency, and developer efficiency.
46+
47+
### Pre-commit hooks
48+
49+
We use [`pre-commit`](https://pre-commit.com/) to run automated checks before each commit.
50+
The configuration is stored in `.pre-commit-config.yaml`, and only uses `hatch fmt` in two separate steps:
51+
52+
* `hatch fmt -f`
53+
* `hatch fmt -l`
54+
55+
The steps are separated in first _formatting_ the code, then _linting_ it to check for issues.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: format
5+
name: Format with Ruff
6+
entry: hatch fmt -f
7+
language: system
8+
types: [python]
9+
- id: Lint with Ruff
10+
name: lint
11+
entry: hatch fmt -l
12+
language: system
13+
types: [python]

template/pyproject.toml.jinja

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ dependencies = [
3131
]
3232
scripts.build = "cd docs && myst build"
3333
scripts.start = "cd docs && myst start"
34+
35+
36+
[tool.hatch.envs.precommit]
37+
dependencies = ["pre-commit"]
38+
scripts.install = "pre-commit install"
39+
scripts.run = "pre-commit run {args:--all-files}"

0 commit comments

Comments
 (0)