Skip to content

Enable warn_unreachable for mypy #1937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
3 changes: 0 additions & 3 deletions src/zarr/codecs/_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/zarr/codecs/blosc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down
9 changes: 3 additions & 6 deletions src/zarr/store/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/zarr/store/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}.")

Expand Down
Loading