Skip to content

Commit 559e9a1

Browse files
Tcc0403lancerts
andauthored
Add pre-commit config (#1009)
## Summary <!--- This is a required section; please describe the main purpose of this proposed code change. ---> This PR adds pre-commit config, [`prek`](https://prek.j178.dev/) dependency and instructions in `CONTRIBUTING.md`. <!--- ## Details This is an optional section; is there anything specific that reviewers should be aware of? ---> ## Testing Done <!--- This is a required section; please describe how this change was tested. ---> <!-- Replace BLANK with your device type. For example, A100-80G-PCIe Complete the following tasks before sending your PR, and replace `[ ]` with `[x]` to indicate you have done them. --> - Hardware Type: <BLANK> - [ ] run `make test` to ensure correctness - [ ] run `make checkstyle` to ensure code style - [ ] run `make test-convergence` to ensure convergence --------- Signed-off-by: Tcc0403 <76503978+Tcc0403@users.noreply.github.com> Co-authored-by: Shao Tang <tangshao28@gmail.com>
1 parent 25189b8 commit 559e9a1

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.14.11
5+
hooks:
6+
# Run the linter.
7+
- id: ruff-check
8+
args: [ --fix ]
9+
# Run the formatter.
10+
- id: ruff-format

docs/contributing.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ Leave `#take` in the comment and tag the maintainer.
2727
pip install -e .'[dev]'
2828
```
2929

30+
3. **Install pre-commit hooks using [`prek`](https://prek.j178.dev/), a `pre-commit` alternative built in rust**
31+
```
32+
prek install
33+
```
34+
Run pre-commit check without committing (`-a` is equivalent to `--all-files`)
35+
```
36+
prek run -a
37+
```
38+
3039
## Structure
3140

3241
!!! Info

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def get_optional_dependencies():
4444
"seaborn",
4545
"mkdocs-material",
4646
"torchvision>=0.20",
47+
"prek>=0.2.28",
4748
]
4849
}
4950

0 commit comments

Comments
 (0)