Skip to content

Commit 3c878f7

Browse files
author
will
committed
fix ty checks
1 parent baac4b4 commit 3c878f7

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/funlib/persistence/arrays/datasets.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from collections.abc import Sequence
3-
from typing import Any, Optional, Union
3+
from typing import Any, Literal, Optional, Union
44

55
import numpy as np
66
import zarr
@@ -14,7 +14,7 @@
1414

1515
def open_ds(
1616
store,
17-
mode: str = "r",
17+
mode: Literal["r", "r+", "a", "w", "w-"] = "r",
1818
metadata_format: Optional[MetaDataFormat] = None,
1919
offset: Optional[Sequence[int]] = None,
2020
voxel_size: Optional[Sequence[int]] = None,
@@ -131,7 +131,7 @@ def prepare_ds(
131131
types: Optional[Sequence[str]] = None,
132132
chunk_shape: Optional[Sequence[int]] = None,
133133
dtype: DTypeLike = np.float32,
134-
mode: str = "a",
134+
mode: Literal["r", "r+", "a", "w", "w-"] = "a",
135135
custom_metadata: dict[str, Any] | None = None,
136136
**kwargs,
137137
) -> Array:

src/funlib/persistence/arrays/metadata.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import warnings
2-
from collections.abc import Sequence
2+
from collections.abc import Mapping, Sequence
33
from pathlib import Path
44
from typing import Any, Optional
55

@@ -268,7 +268,7 @@ class Config:
268268
extra = "forbid"
269269

270270
def fetch(
271-
self, data: dict[str | int, Any], key: str
271+
self, data: Mapping[str, Any], key: str
272272
) -> Sequence[str | int | None] | None:
273273
"""
274274
Given a dictionary of attributes from e.g. zarr.open(...).attrs, fetch the value
@@ -292,7 +292,7 @@ def fetch(
292292
keys = key.split("/")
293293

294294
def recurse(
295-
data: dict[str | int, Any] | list[Any], keys: list[str]
295+
data: Any, keys: list[str]
296296
) -> Sequence[str | int | None] | str | int | None:
297297
current_key: str | int
298298
current_key, *keys = keys
@@ -304,7 +304,7 @@ def recurse(
304304
# base case
305305
if len(keys) == 0:
306306
# this key returns the data we want
307-
if isinstance(data, (dict, zarr.core.attributes.Attributes)):
307+
if isinstance(data, Mapping):
308308
return data.get(str(current_key), None)
309309
elif isinstance(data, list):
310310
assert isinstance(current_key, int), current_key
@@ -336,7 +336,7 @@ def recurse(
336336
def parse(
337337
self,
338338
shape: Sequence[int],
339-
data: dict[str | int, Any],
339+
data: Mapping[str, Any],
340340
offset: Optional[Sequence[int]] = None,
341341
voxel_size: Optional[Sequence[int]] = None,
342342
axis_names: Optional[Sequence[str]] = None,

src/funlib/persistence/arrays/ome_datasets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def open_ome_ds(
6363

6464
metadata = MetaData(
6565
shape=dataset.shape,
66-
offset=offset, # type: ignore[arg-type]
67-
voxel_size=scale, # type: ignore[arg-type]
66+
offset=offset,
67+
voxel_size=scale,
6868
axis_names=axis_names,
6969
units=units,
7070
types=types,

0 commit comments

Comments
 (0)