From 4d1683779e15d964e0b08059f6d75f167f21dff5 Mon Sep 17 00:00:00 2001 From: Mark Harfouche Date: Fri, 29 May 2026 12:08:54 -0400 Subject: [PATCH] Fix mypy failure: drop dead zarr<3 branch in invalid-store test (#11366)
Claude's draft `test_raises_key_error_on_invalid_zarr_store` branched on `zarr.__version__ < 3.0.0` and called `Group.create_dataset`, which no longer exists in zarr 3. Since xarray's minimum supported zarr is now 3.0, that branch is dead code and mypy fails with: "Group" has no attribute "create_dataset" [attr-defined] Drop the version guard and always use `Group.create_array`. Co-authored-by: Claude Resume this Claude session: ``` claude --resume 9faa34e9-aaf5-4e94-a2b7-b03f468175f8 ```
--- xarray/tests/test_backends.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index 6f9034249d0..e229f332aa9 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -7772,10 +7772,7 @@ def test_zarr_create_default_indexes(tmp_path, create_default_indexes) -> None: @pytest.mark.usefixtures("default_zarr_format") def test_raises_key_error_on_invalid_zarr_store(tmp_path): root = zarr.open_group(tmp_path / "tmp.zarr") - if Version(zarr.__version__) < Version("3.0.0"): - root.create_dataset("bar", shape=(3, 5), dtype=np.float32) - else: - root.create_array("bar", shape=(3, 5), dtype=np.float32) + root.create_array("bar", shape=(3, 5), dtype=np.float32) with pytest.raises(KeyError, match=r"xarray to determine variable dimensions"): xr.open_zarr(tmp_path / "tmp.zarr", consolidated=False)