Skip to content

Commit 06d2195

Browse files
committed
Add info about pre-commit to CONTRIBUTING.md
1 parent 1686821 commit 06d2195

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

CONTRIBUTING.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ Hamiltonians.
4040

4141
### Main subdirectories
4242

43-
**check/**: contains scripts for testing
43+
* `check/`: contains scripts for testing
4444

45-
**docker/**: contains a Docker configuration
45+
* `docker/`: contains a Docker configuration
4646

47-
**docs/**: contains OpenFermion documentation
47+
* `docs/`: contains OpenFermion documentation
4848

49-
**src/**: contains the main code
49+
* `src/`: contains the main code
5050

51-
**dev_tools/**: contains programs and configuration files used during development
51+
* `dev_tools/`: contains programs and configuration files used during development
5252

5353
The legacy subdirectories `cloud_library/` and `rtd_docs/` should be ignored.
5454

@@ -188,6 +188,27 @@ The following command will set up large refactoring revisions to be ignored by `
188188
git config blame.ignoreRevsFile .git-blame-ignore-revs
189189
```
190190

191+
### Pre-commit git hooks (optional)
192+
193+
The project includes a `.pre-commit-config.yaml` file for [pre-commit](https://pre-commit.com), an
194+
open-source utility that runs various static analysis tools when triggered by certain git operations
195+
such as `git commit`. This can help you meet project conventions, at the cost of introducing small
196+
delays in `git commit` and `git push` operations. If you want to use `pre-commit`, you can install
197+
and configure it like this:
198+
199+
```shell
200+
pip install pre-commit
201+
pre-commit install -t pre-commit -t pre-push -t commit-msg
202+
```
203+
204+
Next, run it once after installation to initialize it:
205+
206+
```shell
207+
pre-commit run
208+
```
209+
210+
After that, `pre-commit` will run automatically when triggered by git operations.
211+
191212
### Python setup
192213

193214
1. Create a Python virtual environment. To use Python's built-in `venv` package, run:
@@ -220,7 +241,8 @@ check/mypy
220241
### Linting and formatting
221242
222243
Code should meet common style standards for Python and be free of error-prone constructs. We use
223-
[Pylint](https://www.pylint.org/) to check for code lint and [Black](https://github.com/psf/black) for formatting code.
244+
[Pylint](https://www.pylint.org/) to check for code lint and [Black](https://github.com/psf/black)
245+
for formatting code.
224246
225247
* To check that code is formatted properly after editing Python files:
226248

0 commit comments

Comments
 (0)