From 96e5233122ec1346a21f80446d6598aeb86c30b9 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 18 Jun 2025 12:08:53 +0100 Subject: [PATCH] Use zarr-python default open mode when opening arrays --- xarray/backends/zarr.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xarray/backends/zarr.py b/xarray/backends/zarr.py index b86b5d0b374..2bd7b68f60a 100644 --- a/xarray/backends/zarr.py +++ b/xarray/backends/zarr.py @@ -639,7 +639,7 @@ def open_store( def open_group( cls, store, - mode: ZarrWriteModes = "r", + mode: ZarrWriteModes | None = None, synchronizer=None, group=None, consolidated=False, @@ -1561,7 +1561,7 @@ def open_dataset( use_cftime=None, decode_timedelta=None, group=None, - mode="r", + mode=None, synchronizer=None, consolidated=None, chunk_store=None, @@ -1746,6 +1746,9 @@ def _get_open_params( synchronizer=synchronizer, path=group, ) + if mode is None: + # Let zarr-python use its default open mode + open_kwargs.pop("mode") open_kwargs["storage_options"] = storage_options zarr_format = _handle_zarr_version_or_format(