From 2107655b5bb6812789b8a6ea269a195618e4fa29 Mon Sep 17 00:00:00 2001 From: Tom Nicholas Date: Wed, 2 Jul 2025 14:15:35 -0400 Subject: [PATCH 1/2] add .with_read_only --- src/zarr/storage/_zip.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/zarr/storage/_zip.py b/src/zarr/storage/_zip.py index e52f160860..8785e5a5db 100644 --- a/src/zarr/storage/_zip.py +++ b/src/zarr/storage/_zip.py @@ -90,6 +90,16 @@ def __init__( self.compression = compression self.allowZip64 = allowZip64 + def with_read_only(self, read_only: bool = False) -> ZipStore: + # docstring inherited + return type(self)( + path=self.path, + mode='r', + read_only=read_only, + compression=self.compression, + allowZip64=self.allowZip64, + ) + def _sync_open(self) -> None: if self._is_open: raise ValueError("store is already open") From 41508c12725b8a05bba05c337f053d22a8252d4a Mon Sep 17 00:00:00 2001 From: Tom Nicholas Date: Wed, 2 Jul 2025 14:45:54 -0400 Subject: [PATCH 2/2] use _sync_open --- src/zarr/storage/_zip.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/zarr/storage/_zip.py b/src/zarr/storage/_zip.py index 8785e5a5db..e5e59bcc03 100644 --- a/src/zarr/storage/_zip.py +++ b/src/zarr/storage/_zip.py @@ -92,13 +92,15 @@ def __init__( def with_read_only(self, read_only: bool = False) -> ZipStore: # docstring inherited - return type(self)( + store = type(self)( path=self.path, mode='r', read_only=read_only, compression=self.compression, allowZip64=self.allowZip64, ) + store._sync_open() + return store def _sync_open(self) -> None: if self._is_open: