diff --git a/pyproject.toml b/pyproject.toml index 66f06dfe5d..baacf2fc80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -188,7 +188,7 @@ ignore_missing_imports = true namespace_packages = false strict = true - +warn_unreachable = true enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] diff --git a/src/zarr/codecs/_v2.py b/src/zarr/codecs/_v2.py index ceb3de0a06..c4e4756094 100644 --- a/src/zarr/codecs/_v2.py +++ b/src/zarr/codecs/_v2.py @@ -21,9 +21,6 @@ async def _decode_single( chunk_bytes: Buffer, chunk_spec: ArraySpec, ) -> NDBuffer: - if chunk_bytes is None: - return None - if self.compressor is not None: compressor = numcodecs.get_codec(self.compressor) chunk_numpy_array = ensure_ndarray( diff --git a/src/zarr/codecs/blosc.py b/src/zarr/codecs/blosc.py index e8921b8beb..acba698d94 100644 --- a/src/zarr/codecs/blosc.py +++ b/src/zarr/codecs/blosc.py @@ -77,10 +77,10 @@ def parse_blocksize(data: JSON) -> int: class BloscCodec(BytesBytesCodec): is_fixed_size = False - typesize: int + typesize: int | None cname: BloscCname = BloscCname.zstd clevel: int = 5 - shuffle: BloscShuffle = BloscShuffle.noshuffle + shuffle: BloscShuffle | None = BloscShuffle.noshuffle blocksize: int = 0 def __init__( diff --git a/src/zarr/store/local.py b/src/zarr/store/local.py index 40abe12932..945c6160ad 100644 --- a/src/zarr/store/local.py +++ b/src/zarr/store/local.py @@ -120,9 +120,9 @@ async def get_partial_values( async def set(self, key: str, value: Buffer) -> None: self._check_writable() assert isinstance(key, str) - if isinstance(value, bytes | bytearray): + if isinstance(value, bytes | bytearray): # type:ignore[unreachable] # TODO: to support the v2 tests, we convert bytes to Buffer here - value = Buffer.from_bytes(value) + value = Buffer.from_bytes(value) # type:ignore[unreachable] if not isinstance(value, Buffer): raise TypeError("LocalStore.set(): `value` must a Buffer instance") path = self.root / key @@ -134,10 +134,7 @@ async def set_partial_values(self, key_start_values: list[tuple[str, int, bytes] for key, start, value in key_start_values: assert isinstance(key, str) path = self.root / key - if start is not None: - args.append((_put, path, value, start)) - else: - args.append((_put, path, value)) + args.append((_put, path, value, start)) await concurrent_map(args, to_thread, limit=None) # TODO: fix limit async def delete(self, key: str) -> None: diff --git a/src/zarr/store/memory.py b/src/zarr/store/memory.py index 74bb5454fe..fd6fadd3ee 100644 --- a/src/zarr/store/memory.py +++ b/src/zarr/store/memory.py @@ -52,9 +52,9 @@ async def exists(self, key: str) -> bool: async def set(self, key: str, value: Buffer, byte_range: tuple[int, int] | None = None) -> None: self._check_writable() assert isinstance(key, str) - if isinstance(value, bytes | bytearray): + if isinstance(value, bytes | bytearray): # type:ignore[unreachable] # TODO: to support the v2 tests, we convert bytes to Buffer here - value = Buffer.from_bytes(value) + value = Buffer.from_bytes(value) # type:ignore[unreachable] if not isinstance(value, Buffer): raise TypeError(f"Expected Buffer. Got {type(value)}.")