Skip to content

Commit 44c5882

Browse files
committed
Merge branch 'main' of github.com:zarr-developers/zarr-python into feat/default-buffer
2 parents b205b35 + 0e61449 commit 44c5882

File tree

17 files changed

+141
-77
lines changed

17 files changed

+141
-77
lines changed

.github/workflows/check_changelogs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
12+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1313

1414
- name: Install uv
1515
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0

.github/workflows/codspeed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: Run benchmarks
1818
runs-on: codspeed-macro
1919
steps:
20-
- uses: actions/checkout@v5
20+
- uses: actions/checkout@v6
2121
with:
2222
fetch-depth: 0 # grab all branches and tags
2323
- name: Set up Python

.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, 3.1.x]
6+
pull_request:
7+
branches: [main, 3.1.x]
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

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
ci:
22
autoupdate_commit_msg: "chore: update pre-commit hooks"
33
autoupdate_schedule: "monthly"
4-
autofix_commit_msg: "style: pre-commit fixes"
54
autofix_prs: false
5+
skip: [] # pre-commit.ci only checks for updates, prek runs hooks locally
6+
67
default_stages: [pre-commit, pre-push]
78

89
default_language_version:

changes/3658.misc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Switch from `pre-commit` to [`prek`](https://github.com/j178/prek) for pre-commit checks.

docs/contributing.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,50 @@ All tests are automatically run via GitHub Actions for every pull request and mu
109109

110110
> **Note:** Previous versions of Zarr-Python made extensive use of doctests. These tests were not maintained during the 3.0 refactor but may be brought back in the future. See issue #2614 for more details.
111111
112-
### Code standards - using pre-commit
112+
### Code standards - using prek
113113

114114
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.
115115

116-
`Zarr` uses a set of `pre-commit` hooks and the `pre-commit` bot to format, type-check, and prettify the codebase. `pre-commit` can be installed locally by running:
116+
`Zarr` 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:
117117

118118
```bash
119-
python -m pip install pre-commit
119+
uv tool install prek
120+
```
121+
122+
or:
123+
124+
```bash
125+
pip install prek
120126
```
121127

122128
The hooks can be installed locally by running:
123129

124130
```bash
125-
pre-commit install
131+
prek install
132+
```
133+
134+
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:
135+
136+
```bash
137+
prek run --all-files
138+
```
139+
140+
You can also run hooks only for files in a specific directory:
141+
142+
```bash
143+
prek run --directory src/zarr
144+
```
145+
146+
Or run hooks for files changed in the last commit:
147+
148+
```bash
149+
prek run --last-commit
126150
```
127151

128-
This would run the checks every time a commit is created locally. These checks will also run on every commit pushed to an open PR, resulting in some automatic styling fixes by the `pre-commit` bot. 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:
152+
To list all available hooks:
129153

130154
```bash
131-
pre-commit run --all-files
155+
prek list
132156
```
133157

134158
If you would like to skip the failing checks and push the code for further discussion, use the `--no-verify` option with `git commit`.
@@ -143,7 +167,7 @@ Zarr strives to maintain 100% test coverage under the latest Python stable relea
143167
hatch env run --env test.py3.12-2.2-optional run-coverage
144168
```
145169

146-
will automatically run the test suite with coverage and produce a XML coverage report. This should be 100% before code can be accepted into the main code base.
170+
will automatically run the test suite with coverage and produce an XML coverage report. This should be 100% before code can be accepted into the main code base.
147171

148172
You can also generate an HTML coverage report by running:
149173

@@ -273,4 +297,4 @@ performance benchmarks as part of our test suite. The benchmarks can be are foun
273297
By default pytest is configured to run these benchmarks as plain tests (i.e., no benchmarking). To run
274298
a benchmark with timing measurements, use the `--benchmark-enable` when invoking `pytest`.
275299

276-
The benchmarks are run as part of the continuous integration suite through [codspeed](https://codspeed.io/zarr-developers/zarr-python).
300+
The benchmarks are run as part of the continuous integration suite through [codspeed](https://codspeed.io/zarr-developers/zarr-python).

docs/user-guide/storage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ print(group)
138138
```
139139

140140
The type of filesystem (e.g. S3, https, etc..) is inferred from the scheme of the url (e.g. s3 for "**s3**://noaa-nwm-retro-v2-zarr-pds").
141-
In case a specific filesystem is needed, one can explicitly create it. For example to create a S3 filesystem:
141+
In case a specific filesystem is needed, one can explicitly create it. For example to create an S3 filesystem:
142142

143143
```python exec="true" session="storage" source="above" result="ansi"
144144
# Note: requires s3fs to be installed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ maintainers = [
3030
{ name = "Deepak Cherian" }
3131
]
3232
requires-python = ">=3.11"
33-
# If you add a new dependency here, please also add it to .pre-commit-config.yml
33+
# If you add a new dependency here, please also add it to .pre-commit-config.yaml
3434
dependencies = [
3535
'packaging>=22.0',
3636
'numpy>=2.0',
@@ -428,6 +428,7 @@ markers = [
428428
ignore = [
429429
"PC111", # fix Python code in documentation - enable later
430430
"PC180", # for JavaScript - not interested
431+
"PC902", # pre-commit.ci custom autofix message - not using autofix
431432
]
432433

433434
[tool.numpydoc_validation]

src/zarr/abc/store.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ async def get(
221221
"""
222222
...
223223

224-
async def get_bytes(
224+
async def _get_bytes(
225225
self,
226226
key: str,
227227
*,
@@ -268,7 +268,7 @@ async def get_bytes(
268268
--------
269269
>>> store = await MemoryStore.open()
270270
>>> await store.set("data", Buffer.from_bytes(b"hello world"))
271-
>>> data = await store.get_bytes("data", prototype=default_buffer_prototype())
271+
>>> data = await store._get_bytes("data", prototype=default_buffer_prototype())
272272
>>> print(data)
273273
b'hello world'
274274
"""
@@ -277,7 +277,7 @@ async def get_bytes(
277277
raise FileNotFoundError(key)
278278
return buffer.to_bytes()
279279

280-
def get_bytes_sync(
280+
def _get_bytes_sync(
281281
self,
282282
key: str = "",
283283
*,
@@ -329,14 +329,14 @@ def get_bytes_sync(
329329
--------
330330
>>> store = MemoryStore()
331331
>>> await store.set("data", Buffer.from_bytes(b"hello world"))
332-
>>> data = store.get_bytes_sync("data", prototype=default_buffer_prototype())
332+
>>> data = store._get_bytes_sync("data", prototype=default_buffer_prototype())
333333
>>> print(data)
334334
b'hello world'
335335
"""
336336

337-
return sync(self.get_bytes(key, prototype=prototype, byte_range=byte_range))
337+
return sync(self._get_bytes(key, prototype=prototype, byte_range=byte_range))
338338

339-
async def get_json(
339+
async def _get_json(
340340
self,
341341
key: str,
342342
*,
@@ -387,14 +387,14 @@ async def get_json(
387387
>>> store = await MemoryStore.open()
388388
>>> metadata = {"zarr_format": 3, "node_type": "array"}
389389
>>> await store.set("zarr.json", Buffer.from_bytes(json.dumps(metadata).encode()))
390-
>>> data = await store.get_json("zarr.json", prototype=default_buffer_prototype())
390+
>>> data = await store._get_json("zarr.json", prototype=default_buffer_prototype())
391391
>>> print(data)
392392
{'zarr_format': 3, 'node_type': 'array'}
393393
"""
394394

395-
return json.loads(await self.get_bytes(key, prototype=prototype, byte_range=byte_range))
395+
return json.loads(await self._get_bytes(key, prototype=prototype, byte_range=byte_range))
396396

397-
def get_json_sync(
397+
def _get_json_sync(
398398
self,
399399
key: str = "",
400400
*,
@@ -451,12 +451,12 @@ def get_json_sync(
451451
>>> store = MemoryStore()
452452
>>> metadata = {"zarr_format": 3, "node_type": "array"}
453453
>>> store.set("zarr.json", Buffer.from_bytes(json.dumps(metadata).encode()))
454-
>>> data = store.get_json_sync("zarr.json", prototype=default_buffer_prototype())
454+
>>> data = store._get_json_sync("zarr.json", prototype=default_buffer_prototype())
455455
>>> print(data)
456456
{'zarr_format': 3, 'node_type': 'array'}
457457
"""
458458

459-
return sync(self.get_json(key, prototype=prototype, byte_range=byte_range))
459+
return sync(self._get_json(key, prototype=prototype, byte_range=byte_range))
460460

461461
@abstractmethod
462462
async def get_partial_values(

src/zarr/core/dtype/wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def to_json(self, zarr_format: ZarrFormat) -> DTypeSpec_V2 | DTypeSpec_V3:
191191
@abstractmethod
192192
def _check_scalar(self, data: object) -> bool:
193193
"""
194-
Check that an python object is a valid scalar value for the wrapped data type.
194+
Check that a python object is a valid scalar value for the wrapped data type.
195195
196196
Parameters
197197
----------

0 commit comments

Comments
 (0)