Skip to content

Commit fdfbc3d

Browse files
author
Claude Subagent
committed
fix: Resolve linting/formatting failures (prek compliance)
1 parent 22a368c commit fdfbc3d

Some content is hidden

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

79 files changed

+994
-283
lines changed

examples/custom_dtype/custom_dtype.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,11 @@ def from_json_scalar(self, data: JSON, *, zarr_format: ZarrFormat) -> ml_dtypes.
220220
def test_custom_dtype(tmp_path: Path, zarr_format: ZarrFormat) -> None:
221221
# create array and write values
222222
z_w = zarr.create_array(
223-
store=tmp_path, shape=(4,), dtype="int2", zarr_format=zarr_format, compressors=None
223+
store=tmp_path,
224+
shape=(4,),
225+
dtype="int2",
226+
zarr_format=zarr_format,
227+
compressors=None,
224228
)
225229
z_w[:] = [-1, -2, 0, 1]
226230

src/zarr/abc/buffer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
from zarr.core.buffer.core import ArrayLike, Buffer, BufferPrototype, NDArrayLike, NDBuffer
1+
from zarr.core.buffer.core import (
2+
ArrayLike,
3+
Buffer,
4+
BufferPrototype,
5+
NDArrayLike,
6+
NDBuffer,
7+
)
28

39
__all__ = [
410
"ArrayLike",

src/zarr/abc/codec.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
from abc import abstractmethod
44
from collections.abc import Mapping
5-
from typing import TYPE_CHECKING, Generic, Protocol, TypeGuard, TypeVar, runtime_checkable
5+
from typing import (
6+
TYPE_CHECKING,
7+
Generic,
8+
Protocol,
9+
TypeGuard,
10+
TypeVar,
11+
runtime_checkable,
12+
)
613

714
from typing_extensions import ReadOnly, TypedDict
815

src/zarr/abc/store.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ async def get(
219219
...
220220

221221
async def _get_bytes(
222-
self, key: str, *, prototype: BufferPrototype, byte_range: ByteRequest | None = None
222+
self,
223+
key: str,
224+
*,
225+
prototype: BufferPrototype,
226+
byte_range: ByteRequest | None = None,
223227
) -> bytes:
224228
"""
225229
Retrieve raw bytes from the store asynchronously.
@@ -267,7 +271,11 @@ async def _get_bytes(
267271
return buffer.to_bytes()
268272

269273
def _get_bytes_sync(
270-
self, key: str = "", *, prototype: BufferPrototype, byte_range: ByteRequest | None = None
274+
self,
275+
key: str = "",
276+
*,
277+
prototype: BufferPrototype,
278+
byte_range: ByteRequest | None = None,
271279
) -> bytes:
272280
"""
273281
Retrieve raw bytes from the store synchronously.
@@ -318,7 +326,11 @@ def _get_bytes_sync(
318326
return sync(self._get_bytes(key, prototype=prototype, byte_range=byte_range))
319327

320328
async def _get_json(
321-
self, key: str, *, prototype: BufferPrototype, byte_range: ByteRequest | None = None
329+
self,
330+
key: str,
331+
*,
332+
prototype: BufferPrototype,
333+
byte_range: ByteRequest | None = None,
322334
) -> Any:
323335
"""
324336
Retrieve and parse JSON data from the store asynchronously.
@@ -368,7 +380,11 @@ async def _get_json(
368380
return json.loads(await self._get_bytes(key, prototype=prototype, byte_range=byte_range))
369381

370382
def _get_json_sync(
371-
self, key: str = "", *, prototype: BufferPrototype, byte_range: ByteRequest | None = None
383+
self,
384+
key: str = "",
385+
*,
386+
prototype: BufferPrototype,
387+
byte_range: ByteRequest | None = None,
372388
) -> Any:
373389
"""
374390
Retrieve and parse JSON data from the store synchronously.

src/zarr/api/asynchronous.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ def _infer_overwrite(mode: AccessModeLiteral) -> bool:
108108
return mode in _OVERWRITE_MODES
109109

110110

111-
def _get_shape_chunks(a: ArrayLike | Any) -> tuple[tuple[int, ...] | None, tuple[int, ...] | None]:
111+
def _get_shape_chunks(
112+
a: ArrayLike | Any,
113+
) -> tuple[tuple[int, ...] | None, tuple[int, ...] | None]:
112114
"""Helper function to get the shape and chunks from an array-like object"""
113115
shape = None
114116
chunks = None
@@ -179,7 +181,9 @@ def _handle_zarr_version_or_format(
179181
)
180182
if zarr_version is not None:
181183
warnings.warn(
182-
"zarr_version is deprecated, use zarr_format", ZarrDeprecationWarning, stacklevel=2
184+
"zarr_version is deprecated, use zarr_format",
185+
ZarrDeprecationWarning,
186+
stacklevel=2,
183187
)
184188
return zarr_version
185189
return zarr_format
@@ -386,7 +390,9 @@ async def open(
386390
is_v3_array = zarr_format == 3 and _metadata_dict.get("node_type") == "array"
387391
if is_v3_array or zarr_format == 2:
388392
return AsyncArray(
389-
store_path=store_path, metadata=_metadata_dict, config=kwargs.get("config")
393+
store_path=store_path,
394+
metadata=_metadata_dict,
395+
config=kwargs.get("config"),
390396
)
391397
except (AssertionError, FileNotFoundError, NodeTypeValidationError):
392398
pass

src/zarr/api/synchronous.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,12 @@ def save(
266266
"""
267267
return sync(
268268
async_api.save(
269-
store, *args, zarr_version=zarr_version, zarr_format=zarr_format, path=path, **kwargs
269+
store,
270+
*args,
271+
zarr_version=zarr_version,
272+
zarr_format=zarr_format,
273+
path=path,
274+
**kwargs,
270275
)
271276
)
272277

src/zarr/codecs/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@
8383
register_codec("numcodecs.fletcher32", Fletcher32, qualname="zarr.codecs.numcodecs.Fletcher32")
8484
register_codec("numcodecs.gzip", GZip, qualname="zarr.codecs.numcodecs.GZip")
8585
register_codec(
86-
"numcodecs.jenkins_lookup3", JenkinsLookup3, qualname="zarr.codecs.numcodecs.JenkinsLookup3"
86+
"numcodecs.jenkins_lookup3",
87+
JenkinsLookup3,
88+
qualname="zarr.codecs.numcodecs.JenkinsLookup3",
8789
)
8890
register_codec("numcodecs.pcodec", PCodec, qualname="zarr.codecs.numcodecs.PCodec")
8991
register_codec("numcodecs.packbits", PackBits, qualname="zarr.codecs.numcodecs.PackBits")

src/zarr/codecs/blosc.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212

1313
from zarr.abc.codec import BytesBytesCodec
1414
from zarr.core.buffer.cpu import as_numpy_array_wrapper
15-
from zarr.core.common import JSON, NamedRequiredConfig, parse_enum, parse_named_configuration
15+
from zarr.core.common import (
16+
JSON,
17+
NamedRequiredConfig,
18+
parse_enum,
19+
parse_named_configuration,
20+
)
1621
from zarr.core.dtype.common import HasItemSize
1722

1823
if TYPE_CHECKING:

src/zarr/codecs/crc32c_.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ def _encode_sync(
6666
data = chunk_bytes.as_numpy_array()
6767
# Calculate the checksum and "cast" it to a numpy array
6868
checksum = np.array(
69-
[google_crc32c.value(cast("typing_extensions.Buffer", data))], dtype=np.uint32
69+
[google_crc32c.value(cast("typing_extensions.Buffer", data))],
70+
dtype=np.uint32,
7071
)
7172
# Append the checksum (as bytes) to the data
7273
return chunk_spec.prototype.buffer.from_array_like(np.append(data, checksum.view("B")))

src/zarr/codecs/sharding.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ async def from_bytes(
244244

245245
@classmethod
246246
def create_empty(
247-
cls, chunks_per_shard: tuple[int, ...], buffer_prototype: BufferPrototype | None = None
247+
cls,
248+
chunks_per_shard: tuple[int, ...],
249+
buffer_prototype: BufferPrototype | None = None,
248250
) -> _ShardReader:
249251
if buffer_prototype is None:
250252
buffer_prototype = default_buffer_prototype()
@@ -297,7 +299,9 @@ def to_dict_vectorized(
297299

298300
@dataclass(frozen=True)
299301
class ShardingCodec(
300-
ArrayBytesCodec, ArrayBytesCodecPartialDecodeMixin, ArrayBytesCodecPartialEncodeMixin
302+
ArrayBytesCodec,
303+
ArrayBytesCodecPartialDecodeMixin,
304+
ArrayBytesCodecPartialEncodeMixin,
301305
):
302306
"""Sharding codec"""
303307

@@ -312,7 +316,7 @@ def __init__(
312316
chunk_shape: ShapeLike,
313317
codecs: Iterable[Codec | dict[str, JSON]] = (BytesCodec(),),
314318
index_codecs: Iterable[Codec | dict[str, JSON]] = (BytesCodec(), Crc32cCodec()),
315-
index_location: ShardingCodecIndexLocation | str = ShardingCodecIndexLocation.end,
319+
index_location: (ShardingCodecIndexLocation | str) = ShardingCodecIndexLocation.end,
316320
) -> None:
317321
chunk_shape_parsed = parse_shapelike(chunk_shape)
318322
codecs_parsed = parse_codecs(codecs)
@@ -585,7 +589,9 @@ async def _encode_partial_single(
585589

586590
indexer = list(
587591
get_indexer(
588-
selection, shape=shard_shape, chunk_grid=RegularChunkGrid(chunk_shape=chunk_shape)
592+
selection,
593+
shape=shard_shape,
594+
chunk_grid=RegularChunkGrid(chunk_shape=chunk_shape),
589595
)
590596
)
591597

@@ -701,7 +707,8 @@ def _shard_index_size(self, chunks_per_shard: tuple[int, ...]) -> int:
701707
get_pipeline_class()
702708
.from_codecs(self.index_codecs)
703709
.compute_encoded_size(
704-
16 * product(chunks_per_shard), self._get_index_chunk_spec(chunks_per_shard)
710+
16 * product(chunks_per_shard),
711+
self._get_index_chunk_spec(chunks_per_shard),
705712
)
706713
)
707714

@@ -746,7 +753,8 @@ async def _load_shard_index_maybe(
746753
)
747754
else:
748755
index_bytes = await byte_getter.get(
749-
prototype=numpy_buffer_prototype(), byte_range=SuffixByteRequest(shard_index_size)
756+
prototype=numpy_buffer_prototype(),
757+
byte_range=SuffixByteRequest(shard_index_size),
750758
)
751759
if index_bytes is not None:
752760
return await self._decode_shard_index(index_bytes, chunks_per_shard)
@@ -760,7 +768,10 @@ async def _load_shard_index(
760768
) or _ShardIndex.create_empty(chunks_per_shard)
761769

762770
async def _load_full_shard_maybe(
763-
self, byte_getter: ByteGetter, prototype: BufferPrototype, chunks_per_shard: tuple[int, ...]
771+
self,
772+
byte_getter: ByteGetter,
773+
prototype: BufferPrototype,
774+
chunks_per_shard: tuple[int, ...],
764775
) -> _ShardReader | None:
765776
shard_bytes = await byte_getter.get(prototype=prototype)
766777

0 commit comments

Comments
 (0)