Skip to content

Commit 30760c4

Browse files
authored
Use prek for code standards (#11)
* Use prek for code standards * Add h5py to test deps
1 parent b920d33 commit 30760c4

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

.github/workflows/lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
lint:
16+
name: Lint
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v6
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v5
22+
- name: Install prek
23+
run: uv tool install prek
24+
- name: Run prek
25+
run: prek run --all-files

docs/index.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,57 @@ data = cached_reader.readall() # Read entire file from memory cache
6262
2. Install development dependencies: `uv sync --all-groups`
6363
3. Run the test suite: `uv run --all-groups pytest`
6464

65+
### Code standards - using prek
66+
67+
> [!NOTE]
68+
> These instructions are replicated from [zarr-python](https://github.com/zarr-developers/zarr-python).
69+
70+
All code must conform to the PEP8 standard. Regarding line length, lines up to 100 characters are allowed, although please try to keep under 90 wherever possible.
71+
72+
`Obspec-utils` uses a set of git hooks managed by [`prek`](https://github.com/j178/prek), a fast, Rust-based pre-commit hook manager that is fully compatible with `.pre-commit-config.yaml` files. `prek` can be installed locally by running:
73+
74+
```bash
75+
uv tool install prek
76+
```
77+
78+
or:
79+
80+
```bash
81+
pip install prek
82+
```
83+
84+
The hooks can be installed locally by running:
85+
86+
```bash
87+
prek install
88+
```
89+
90+
This would run the checks every time a commit is created locally. The checks will by default only run on the files modified by a commit, but the checks can be triggered for all the files by running:
91+
92+
```bash
93+
prek run --all-files
94+
```
95+
96+
You can also run hooks only for files in a specific directory:
97+
98+
```bash
99+
prek run --directory src/obspec_utils
100+
```
101+
102+
Or run hooks for files changed in the last commit:
103+
104+
```bash
105+
prek run --last-commit
106+
```
107+
108+
To list all available hooks:
109+
110+
```bash
111+
prek list
112+
```
113+
114+
If you would like to skip the failing checks and push the code for further discussion, use the `--no-verify` option with `git commit`.
115+
65116
## License
66117

67118
`obspec-utils` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ test = [
5454
xarray = [
5555
"xarray",
5656
"h5netcdf",
57+
"h5py",
5758
]
5859
fsspec = [
5960
"s3fs",

0 commit comments

Comments
 (0)