Skip to content

Commit fe006c6

Browse files
Implement pre-commit hooks.
1 parent f0d4b40 commit fe006c6

File tree

3 files changed

+52
-19
lines changed

3 files changed

+52
-19
lines changed

.pre-commit-config.yaml

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# See https://pre-commit.com for more information
2-
# See https://pre-commit.com/hooks.html for more hooks
31
repos:
4-
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.4.0
6-
hooks:
7-
- id: trailing-whitespace
8-
- id: end-of-file-fixer
9-
- id: check-yaml
10-
- id: check-added-large-files
11-
- repo: https://github.com/akaihola/darker
12-
rev: 1.7.2
13-
hooks:
14-
- id: darker
15-
args:
16-
- --isort
17-
- --skip-string-normalization
18-
additional_dependencies:
19-
- isort~=5.13.1
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.2.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-json
8+
- id: check-yaml
9+
- id: check-added-large-files
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
rev: v0.3.4
12+
hooks:
13+
- id: ruff
14+
args: ["--fix", "--show-fixes"]
15+
- repo: https://github.com/psf/black-pre-commit-mirror
16+
rev: 24.3.0
17+
hooks:
18+
- id: black-jupyter
19+
language_version: python3.11

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,39 @@ newest relate of the code (starting at the top of the file).
140140
## vX.Y.Z
141141
```
142142

143+
### pre-commit hooks:
144+
145+
This repository uses [pre-commit](https://pre-commit.com/) to enable pre-commit
146+
checking the repository for some coding standard best practices. These include:
147+
148+
* Removing trailing whitespaces.
149+
* Removing blank lines at the end of a file.
150+
* JSON files have valid formats.
151+
* [ruff](https://github.com/astral-sh/ruff) Python linting checks.
152+
* [black](https://black.readthedocs.io/en/stable/index.html) Python code
153+
formatting checks.
154+
155+
To enable these checks:
156+
157+
```bash
158+
# Install pre-commit Python package as part of test requirements:
159+
pip install -r tests/pip_test_requirements.txt
160+
161+
# Install the git hook scripts:
162+
pre-commit install
163+
164+
# (Optional) Run against all files:
165+
pre-commit run --all-files
166+
```
167+
168+
When you try to make a new commit locally, `pre-commit` will automatically run.
169+
If any of the hooks detect non-compliance (e.g., trailing whitespace), that
170+
hook will state it failed, and also try to fix the issue. You will need to
171+
review and `git add` the changes before you can make a commit.
172+
173+
It is planned to implement additional hooks, possibly including tools such as
174+
`mypy`.
175+
143176
## Releasing a new version of the service:
144177

145178
Once a new Docker image has been published with a new semantic version tag,

tests/unit/test_adapter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest import TestCase, skip
1+
from unittest import TestCase
22

33
from harmony.message import Message
44
from harmony.util import config

0 commit comments

Comments
 (0)