Skip to content

Commit c82b34a

Browse files
authored
Merge branch 'v3' into batched-codec-pipeline
2 parents 51d3c92 + a33ebf2 commit c82b34a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+163
-380
lines changed

.flake8

Lines changed: 0 additions & 2 deletions
This file was deleted.

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# lint codebase with black and ruff
22
4e348d6b80c96da461fd866576c971b8a659ba15
3+
# migrate from black to ruff format
4+
22cea005629913208a85799372e045f353744add

.github/workflows/test-v3.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,22 @@ on:
1010
branches: [ v3 ]
1111

1212
jobs:
13-
run-tests:
13+
test:
14+
name: py=${{ matrix.python-version }}, np=${{ matrix.numpy-version }}, deps=${{ matrix.dependency-set }}
1415

1516
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: ['3.10', '3.11']
20+
numpy-version: ['1.24', '1.26']
21+
dependency-set: ["minimal", "optional"]
22+
1623
steps:
1724
- uses: actions/checkout@v3
1825
- name: Set up Python
1926
uses: actions/setup-python@v4
2027
with:
21-
python-version: '3.11'
28+
python-version: ${{ matrix.python-version }}
2229
cache: 'pip'
2330
- name: Install Hatch
2431
run: |
@@ -29,8 +36,8 @@ jobs:
2936
hatch env create
3037
- name: Run Tests
3138
run: |
32-
hatch run test:run
39+
hatch env run --env test.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} run
3340
- name: Run mypy
3441
continue-on-error: true
3542
run: |
36-
hatch run test:run-mypy
43+
hatch run test:run-mypy

.pre-commit-config.yaml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,25 @@ default_language_version:
77
python: python3
88
repos:
99
- repo: https://github.com/charliermarsh/ruff-pre-commit
10-
# Ruff version.
11-
rev: 'v0.0.224'
10+
rev: 'v0.2.1'
1211
hooks:
1312
- id: ruff
14-
# Respect `exclude` and `extend-exclude` settings.
15-
args: ["--force-exclude"]
16-
- repo: https://github.com/psf/black
17-
rev: 22.12.0
18-
hooks:
19-
- id: black
13+
args: ["--fix", "--show-fixes"]
14+
- id: ruff-format
2015
- repo: https://github.com/codespell-project/codespell
21-
rev: v2.2.5
16+
rev: v2.2.6
2217
hooks:
2318
- id: codespell
2419
args: ["-L", "ba,ihs,kake,nd,noe,nwo,te,fo,zar", "-S", "fixture"]
2520
- repo: https://github.com/pre-commit/pre-commit-hooks
26-
rev: v4.4.0
21+
rev: v4.5.0
2722
hooks:
2823
- id: check-yaml
2924
- repo: https://github.com/pre-commit/mirrors-mypy
30-
rev: v1.7.1
25+
rev: v1.8.0
3126
hooks:
3227
- id: mypy
3328
files: src
34-
exclude: ^src/zarr/v3
3529
args: []
3630
additional_dependencies:
3731
- types-redis

bench/compress_normal.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from zarr import blosc
99

1010
if __name__ == "__main__":
11-
1211
sys.path.insert(0, "..")
1312

1413
# setup

docs/installation.rst

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,4 @@ latest GitHub main::
1919

2020
$ pip install git+https://github.com/zarr-developers/zarr-python.git
2121

22-
To work with Zarr source code in development, install from GitHub::
23-
24-
$ git clone --recursive https://github.com/zarr-developers/zarr-python.git
25-
$ cd zarr-python
26-
$ python -m pip install -e .
27-
28-
To verify that Zarr has been fully installed, run the test suite::
29-
30-
$ pip install pytest
31-
$ python -m pytest -v --pyargs zarr
22+
To work with Zarr source code in development, see `Contributing <contributing.html>`_.

pyproject.toml

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ serve = "sphinx-autobuild docs docs/_build --ignore 'docs/_autoapi/**/*' --host
127127

128128
[tool.ruff]
129129
line-length = 100
130-
exclude = [
130+
force-exclude = true
131+
extend-exclude = [
131132
".bzr",
132133
".direnv",
133134
".eggs",
@@ -146,25 +147,35 @@ exclude = [
146147
"docs"
147148
]
148149

149-
[tool.black]
150-
line-length = 100
151-
exclude = '''
152-
/(
153-
\.git
154-
| \.mypy_cache
155-
| \.venv
156-
| _build
157-
| buck-out
158-
| build
159-
| dist
160-
| docs
161-
)/
162-
'''
163-
164150
[tool.mypy]
165-
python_version = "3.8"
151+
python_version = "3.10"
166152
ignore_missing_imports = true
167-
follow_imports = "silent"
153+
namespace_packages = false
154+
155+
warn_unused_configs = true
156+
warn_redundant_casts = true
157+
warn_unused_ignores = true
158+
strict_equality = true
159+
strict_concatenate = true
160+
161+
check_untyped_defs = true
162+
disallow_untyped_decorators = true
163+
164+
[[tool.mypy.overrides]]
165+
module = [
166+
"zarr._storage.store",
167+
"zarr._storage.v3_storage_transformers",
168+
"zarr.v3.group",
169+
"zarr.core",
170+
"zarr.hierarchy",
171+
"zarr.indexing",
172+
"zarr.storage",
173+
"zarr.sync",
174+
"zarr.util",
175+
"tests.*",
176+
]
177+
check_untyped_defs = false
178+
168179

169180
[tool.pytest.ini_options]
170181
doctest_optionflags = [

src/zarr/_storage/absstore.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(
8787
"https://{}.blob.core.windows.net/".format(account_name),
8888
container,
8989
credential=account_key,
90-
**blob_service_kwargs
90+
**blob_service_kwargs,
9191
)
9292

9393
self.client = client
@@ -240,7 +240,6 @@ def __setitem__(self, key, value):
240240
super().__setitem__(key, value)
241241

242242
def rmdir(self, path=None):
243-
244243
if not path:
245244
# Currently allowing clear to delete everything as in v2
246245

src/zarr/_storage/store.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ def _rmdir_from_keys(store: StoreLike, path: Optional[str] = None) -> None:
629629

630630

631631
def _rmdir_from_keys_v3(store: StoreV3, path: str = "") -> None:
632-
633632
meta_dir = meta_root + path
634633
meta_dir = meta_dir.rstrip("/")
635634
_rmdir_from_keys(store, meta_dir)
@@ -643,10 +642,10 @@ def _rmdir_from_keys_v3(store: StoreV3, path: str = "") -> None:
643642
sfx = _get_metadata_suffix(store)
644643
array_meta_file = meta_dir + ".array" + sfx
645644
if array_meta_file in store:
646-
store.erase(array_meta_file) # type: ignore
645+
store.erase(array_meta_file)
647646
group_meta_file = meta_dir + ".group" + sfx
648647
if group_meta_file in store:
649-
store.erase(group_meta_file) # type: ignore
648+
store.erase(group_meta_file)
650649

651650

652651
def _listdir_from_keys(store: BaseStore, path: Optional[str] = None) -> List[str]:

src/zarr/_storage/v3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def _get_files_and_dirs_from_path(store, path):
118118

119119

120120
class FSStoreV3(FSStore, StoreV3):
121-
122121
# FSStoreV3 doesn't use this (FSStore uses it within _normalize_key)
123122
_META_KEYS = ()
124123

src/zarr/_storage/v3_storage_transformers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def erase_prefix(self, prefix):
367367

368368
def rmdir(self, path=None):
369369
path = normalize_storage_path(path)
370-
_rmdir_from_keys_v3(self, path) # type: ignore
370+
_rmdir_from_keys_v3(self, path)
371371

372372
def __contains__(self, key):
373373
if self._is_data_key(key):

src/zarr/attrs.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import Any
12
import warnings
23
from collections.abc import MutableMapping
34

@@ -26,7 +27,6 @@ class Attributes(MutableMapping):
2627
"""
2728

2829
def __init__(self, store, key=".zattrs", read_only=False, cache=True, synchronizer=None):
29-
3030
self._version = getattr(store, "_store_version", 2)
3131
_Store = Store if self._version == 2 else StoreV3
3232
self.store = _Store._ensure_store(store)
@@ -40,7 +40,7 @@ def _get_nosync(self):
4040
try:
4141
data = self.store[self.key]
4242
except KeyError:
43-
d = dict()
43+
d: dict[str, Any] = dict()
4444
if self._version > 2:
4545
d["attributes"] = {}
4646
else:
@@ -73,7 +73,6 @@ def __getitem__(self, item):
7373
return self.asdict()[item]
7474

7575
def _write_op(self, f, *args, **kwargs):
76-
7776
# guard condition
7877
if self.read_only:
7978
raise PermissionError("attributes are read-only")
@@ -89,7 +88,6 @@ def __setitem__(self, item, value):
8988
self._write_op(self._setitem_nosync, item, value)
9089

9190
def _setitem_nosync(self, item, value):
92-
9391
# load existing data
9492
d = self._get_nosync()
9593

@@ -106,7 +104,6 @@ def __delitem__(self, item):
106104
self._write_op(self._delitem_nosync, item)
107105

108106
def _delitem_nosync(self, key):
109-
110107
# load existing data
111108
d = self._get_nosync()
112109

@@ -128,7 +125,6 @@ def put(self, d):
128125
self._write_op(self._put_nosync, dict(attributes=d))
129126

130127
def _put_nosync(self, d):
131-
132128
d_to_check = d if self._version == 2 else d["attributes"]
133129
if not all(isinstance(item, str) for item in d_to_check):
134130
# TODO: Raise an error for non-string keys
@@ -178,7 +174,6 @@ def update(self, *args, **kwargs):
178174
self._write_op(self._update_nosync, *args, **kwargs)
179175

180176
def _update_nosync(self, *args, **kwargs):
181-
182177
# load existing data
183178
d = self._get_nosync()
184179

0 commit comments

Comments
 (0)