Skip to content

Commit 5584761

Browse files
committed
Disallow untyped defs
1 parent c1323c4 commit 5584761

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ disallow_any_generics = true
169169

170170
disallow_incomplete_defs = true
171171

172+
disallow_untyped_defs = true
173+
172174
[[tool.mypy.overrides]]
173175
module = [
174176
"zarr.v2._storage.store",
@@ -207,6 +209,17 @@ module = [
207209
]
208210
disallow_incomplete_defs = false
209211

212+
[[tool.mypy.overrides]]
213+
module = [
214+
"zarr.v2.*",
215+
"zarr.array_v2",
216+
"zarr.array",
217+
"zarr.common",
218+
"zarr.group",
219+
"zarr.metadata"
220+
]
221+
disallow_untyped_defs = false
222+
210223
[tool.pytest.ini_options]
211224
doctest_optionflags = [
212225
"NORMALIZE_WHITESPACE",

src/zarr/array.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
# from zarr.array_v2 import ArrayV2
2323
from zarr.codecs import BytesCodec
24+
from zarr.codecs.pipeline import CodecPipeline
2425
from zarr.common import (
2526
ZARR_JSON,
2627
ArraySpec,
@@ -55,7 +56,7 @@ class AsyncArray:
5556
runtime_configuration: RuntimeConfiguration
5657

5758
@property
58-
def codecs(self):
59+
def codecs(self) -> CodecPipeline:
5960
return self.metadata.codecs
6061

6162
def __init__(
@@ -402,7 +403,7 @@ async def update_attributes(self, new_attributes: Dict[str, Any]) -> AsyncArray:
402403
await (self.store_path / ZARR_JSON).set(new_metadata.to_bytes())
403404
return replace(self, metadata=new_metadata)
404405

405-
def __repr__(self):
406+
def __repr__(self) -> str:
406407
return f"<AsyncArray {self.store_path} shape={self.shape} dtype={self.dtype}>"
407408

408409
async def info(self):
@@ -542,7 +543,7 @@ def update_attributes(self, new_attributes: Dict[str, Any]) -> Array:
542543
)
543544
)
544545

545-
def __repr__(self):
546+
def __repr__(self) -> str:
546547
return f"<Array {self.store_path} shape={self.shape} dtype={self.dtype}>"
547548

548549
def info(self):

src/zarr/attributes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22
from collections.abc import MutableMapping
3-
from typing import TYPE_CHECKING, Any, Union
3+
from typing import TYPE_CHECKING, Any, Iterator, Union
44

55
if TYPE_CHECKING:
66
from zarr.group import Group
@@ -12,21 +12,21 @@ def __init__(self, obj: Union[Array, Group]):
1212
# key=".zattrs", read_only=False, cache=True, synchronizer=None
1313
self._obj = obj
1414

15-
def __getitem__(self, key):
15+
def __getitem__(self, key: str) -> Any:
1616
return self._obj.metadata.attributes[key]
1717

18-
def __setitem__(self, key, value):
18+
def __setitem__(self, key: str, value: Any) -> None:
1919
new_attrs = dict(self._obj.metadata.attributes)
2020
new_attrs[key] = value
2121
self._obj = self._obj.update_attributes(new_attrs)
2222

23-
def __delitem__(self, key):
23+
def __delitem__(self, key: str) -> None:
2424
new_attrs = dict(self._obj.metadata.attributes)
2525
del new_attrs[key]
2626
self._obj = self._obj.update_attributes(new_attrs)
2727

28-
def __iter__(self):
28+
def __iter__(self) -> Iterator[str]:
2929
return iter(self._obj.metadata.attributes)
3030

31-
def __len__(self):
31+
def __len__(self) -> int:
3232
return len(self._obj.metadata.attributes)

src/zarr/indexing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def _err_too_many_indices(selection: SliceSelection, shape: ChunkCoords) -> None
1919
)
2020

2121

22-
def _err_negative_step():
22+
def _err_negative_step() -> None:
2323
raise IndexError("only slices with step >= 1 are supported")
2424

2525

@@ -50,7 +50,7 @@ class _ChunkDimProjection(NamedTuple):
5050
dim_out_sel: Optional[slice]
5151

5252

53-
def _ceildiv(a, b):
53+
def _ceildiv(a: float, b: float) -> int:
5454
return math.ceil(a / b)
5555

5656

0 commit comments

Comments
 (0)