From 2d2da5282979819c276f21b89db3956e27e19f2a Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 10 Apr 2024 11:19:14 +0100 Subject: [PATCH] Check untyped defs --- pyproject.toml | 20 +++++++++++++++++++- src/zarr/attrs.py | 3 ++- src/zarr/n5.py | 5 ++--- src/zarr/v3/sync.py | 5 +++-- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9f21a84ae..ba8287f3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -148,10 +148,28 @@ extend-exclude = [ ] [tool.mypy] -python_version = "3.8" +python_version = "3.10" ignore_missing_imports = true follow_imports = "silent" +check_untyped_defs = true + +[[tool.mypy.overrides]] +module = [ + "zarr._storage.store", + "zarr._storage.v3_storage_transformers", + "zarr.v3.group", + "zarr.core", + "zarr.hierarchy", + "zarr.indexing", + "zarr.storage", + "zarr.sync", + "zarr.util", + "tests.*", +] +check_untyped_defs = false + + [tool.pytest.ini_options] doctest_optionflags = [ "NORMALIZE_WHITESPACE", diff --git a/src/zarr/attrs.py b/src/zarr/attrs.py index e967c5b85..e589bc902 100644 --- a/src/zarr/attrs.py +++ b/src/zarr/attrs.py @@ -1,3 +1,4 @@ +from typing import Any import warnings from collections.abc import MutableMapping @@ -39,7 +40,7 @@ def _get_nosync(self): try: data = self.store[self.key] except KeyError: - d = dict() + d: dict[str, Any] = dict() if self._version > 2: d["attributes"] = {} else: diff --git a/src/zarr/n5.py b/src/zarr/n5.py index 44b44e69e..79bab2057 100644 --- a/src/zarr/n5.py +++ b/src/zarr/n5.py @@ -325,10 +325,9 @@ class N5FSStore(FSStore): def __init__(self, *args, **kwargs): if "dimension_separator" in kwargs: - kwargs.pop("dimension_separator") warnings.warn("Keyword argument `dimension_separator` will be ignored") - dimension_separator = "." - super().__init__(*args, dimension_separator=dimension_separator, **kwargs) + kwargs["dimension_separator"] = "." + super().__init__(*args, **kwargs) @staticmethod def _swap_separator(key: str): diff --git a/src/zarr/v3/sync.py b/src/zarr/v3/sync.py index 2e94a815c..41dfeadba 100644 --- a/src/zarr/v3/sync.py +++ b/src/zarr/v3/sync.py @@ -90,8 +90,9 @@ def _get_loop(): # repeat the check just in case the loop got filled between the # previous two calls from another thread if loop[0] is None: - loop[0] = asyncio.new_event_loop() - th = threading.Thread(target=loop[0].run_forever, name="zarrIO") + new_loop = asyncio.new_event_loop() + loop[0] = new_loop + th = threading.Thread(target=new_loop.run_forever, name="zarrIO") th.daemon = True th.start() iothread[0] = th