Skip to content

Commit 6a0be8c

Browse files
authored
Merge branch 'main' into refactor/metadata-package
2 parents 4b5bd11 + c4730be commit 6a0be8c

17 files changed

Lines changed: 54 additions & 54 deletions

File tree

src/zarr/core/buffer/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def all_equal(self, other: Any, equal_nan: bool = True) -> bool:
535535
and self._data.dtype.kind not in ("U", "S", "T", "O", "V")
536536
):
537537
_data, other = np.broadcast_arrays(self._data, np.asarray(other, self._data.dtype))
538-
void_dtype = "V" + str(_data.dtype.itemsize)
538+
void_dtype = f"V{_data.dtype.itemsize}"
539539
return np.array_equal(_data.view(void_dtype), other.view(void_dtype))
540540
# use array_equal to obtain equal_nan=True functionality
541541
# Since fill-value is a scalar, isn't there a faster path than allocating a new array for fill value

src/zarr/core/group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ def name(self) -> str:
840840
# follow h5py convention: add leading slash
841841
name = self.path
842842
if name[0] != "/":
843-
name = "/" + name
843+
name = f"/{name}"
844844
return name
845845
return "/"
846846

src/zarr/registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _reload_config() -> None:
133133

134134
def fully_qualified_name(cls: type) -> str:
135135
module = cls.__module__
136-
return module + "." + cls.__qualname__
136+
return f"{module}.{cls.__qualname__}"
137137

138138

139139
def register_codec(key: str, codec_cls: type[Codec], *, qualname: str | None = None) -> None:

src/zarr/storage/_fsspec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ async def get_partial_values(
408408
async def list(self) -> AsyncIterator[str]:
409409
# docstring inherited
410410
allfiles = await self.fs._find(self.path, detail=False, withdirs=False)
411-
for onefile in (a.removeprefix(self.path + "/") for a in allfiles):
411+
for onefile in (a.removeprefix(f"{self.path}/") for a in allfiles):
412412
yield onefile
413413

414414
async def list_dir(self, prefix: str) -> AsyncIterator[str]:
@@ -418,7 +418,7 @@ async def list_dir(self, prefix: str) -> AsyncIterator[str]:
418418
allfiles = await self.fs._ls(prefix, detail=False)
419419
except FileNotFoundError:
420420
return
421-
for onefile in (a.replace(prefix + "/", "") for a in allfiles):
421+
for onefile in (a.replace(f"{prefix}/", "") for a in allfiles):
422422
yield onefile.removeprefix(self.path).removeprefix("/")
423423

424424
async def list_prefix(self, prefix: str) -> AsyncIterator[str]:

src/zarr/storage/_memory.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ async def list_dir(self, prefix: str) -> AsyncIterator[str]:
217217
# a pseudo directory when there's a nested item and we're listing an
218218
# intermediate level.
219219
keys_unique = {
220-
key.removeprefix(prefix + "/").split("/")[0]
220+
key.removeprefix(f"{prefix}/").split("/")[0]
221221
for key in self._store_dict
222-
if key.startswith(prefix + "/") and key != prefix
222+
if key.startswith(f"{prefix}/") and key != prefix
223223
}
224224

225225
for key in keys_unique:
@@ -822,7 +822,7 @@ async def delete(self, key: str) -> None:
822822

823823
async def list(self) -> AsyncIterator[str]:
824824
# docstring inherited
825-
prefix = self.path + "/" if self.path else ""
825+
prefix = f"{self.path}/" if self.path else ""
826826
async for key in super().list():
827827
if key.startswith(prefix):
828828
yield key.removeprefix(prefix)
@@ -832,7 +832,7 @@ async def list_prefix(self, prefix: str) -> AsyncIterator[str]:
832832
# Manual concatenation instead of _join_paths because we need "path/"
833833
# as the prefix when prefix is empty (to list all keys under self.path)
834834
full_prefix = f"{self.path}/{prefix}" if self.path else prefix
835-
path_prefix = self.path + "/" if self.path else ""
835+
path_prefix = f"{self.path}/" if self.path else ""
836836
async for key in super().list_prefix(full_prefix):
837837
yield key.removeprefix(path_prefix)
838838

src/zarr/storage/_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ def _relativize_path(*, path: str, prefix: str) -> str:
220220
if prefix == "":
221221
return path
222222
else:
223-
_prefix = prefix + "/"
223+
_prefix = f"{prefix}/"
224224
if not path.startswith(_prefix):
225225
raise ValueError(f"The first component of {path} does not start with {prefix}.")
226-
return path.removeprefix(f"{prefix}/")
226+
return path.removeprefix(_prefix)
227227

228228

229229
def _normalize_paths(paths: Iterable[str]) -> tuple[str, ...]:

src/zarr/storage/_zip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ async def list_dir(self, prefix: str) -> AsyncIterator[str]:
285285
yield key
286286
else:
287287
for key in keys:
288-
if key.startswith(prefix + "/") and key.strip("/") != prefix:
289-
k = key.removeprefix(prefix + "/").split("/")[0]
288+
if key.startswith(f"{prefix}/") and key.strip("/") != prefix:
289+
k = key.removeprefix(f"{prefix}/").split("/")[0]
290290
if k not in seen:
291291
seen.add(k)
292292
yield k

src/zarr/testing/store.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ async def test_list(self, store: S) -> None:
449449
prefix = "foo"
450450
data = self.buffer_cls.from_bytes(b"")
451451
store_dict = {
452-
prefix + "/zarr.json": data,
453-
**{prefix + f"/c/{idx}": data for idx in range(10)},
452+
f"{prefix}/zarr.json": data,
453+
**{f"{prefix}/c/{idx}": data for idx in range(10)},
454454
}
455455
await store._set_many(store_dict.items())
456456
expected_sorted = sorted(store_dict.keys())
@@ -536,10 +536,10 @@ async def test_list_dir(self, store: S) -> None:
536536
await store._set_many(store_dict.items())
537537

538538
keys_observed = await _collect_aiterator(store.list_dir(root))
539-
keys_expected = {k.removeprefix(root + "/").split("/")[0] for k in store_dict}
539+
keys_expected = {k.removeprefix(f"{root}/").split("/")[0] for k in store_dict}
540540
assert sorted(keys_observed) == sorted(keys_expected)
541541

542-
keys_observed = await _collect_aiterator(store.list_dir(root + "/"))
542+
keys_observed = await _collect_aiterator(store.list_dir(f"{root}/"))
543543
assert sorted(keys_expected) == sorted(keys_observed)
544544

545545
async def test_set_if_not_exists(self, store: S) -> None:

src/zarr/testing/strategies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def arrays(
323323
assert a.fill_value is not None
324324
assert a.name is not None
325325
assert a.path == normalize_path(array_path)
326-
assert a.name == "/" + a.path
326+
assert a.name == f"/{a.path}"
327327
assert isinstance(root[array_path], Array)
328328
assert nparray.shape == a.shape
329329

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async def parse_store(
8787
if store == "fsspec":
8888
return await FsspecStore.open(url=path)
8989
if store == "zip":
90-
return await ZipStore.open(path + "/zarr.zip", mode="w")
90+
return await ZipStore.open(f"{path}/zarr.zip", mode="w")
9191
if store == "memory_get_latency":
9292
return LatencyStore(MemoryStore(), get_latency=0.0001, set_latency=0)
9393
raise AssertionError
@@ -143,7 +143,7 @@ async def store2(request: pytest.FixtureRequest, tmpdir: LEGACY_PATH) -> Store:
143143
def sync_store(request: pytest.FixtureRequest, tmp_path: LEGACY_PATH) -> Store:
144144
result = sync(parse_store(request.param, str(tmp_path)))
145145
if not isinstance(result, Store):
146-
raise TypeError("Wrong store class returned by test fixture! got " + result + " instead")
146+
raise TypeError(f"Wrong store class returned by test fixture! got {result} instead")
147147
return result
148148

149149

0 commit comments

Comments
 (0)