Skip to content

Commit 2616b2f

Browse files
Apply suggestion for try; except shortening
Co-authored-by: Tom Nicholas <[email protected]>
1 parent 4e099e4 commit 2616b2f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/zarr/storage/_common.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,15 @@ async def open(cls, store: Store, path: str, mode: AccessModeLiteral | None = No
116116
elif mode == "r":
117117
# Create read-only copy for read mode on writable store
118118
try:
119-
self = await cls._create_open_instance(store.with_read_only(True), path)
119+
read_only_store = store.with_read_only(True)
120120
except NotImplementedError as e:
121121
raise ValueError(
122-
"Store is not read-only but mode is 'r'. Unable to create a read-only copy of the store."
122+
"Store is not read-only but mode is 'r'. Unable to create a read-only copy of the store. "
123+
"Please use a read-only store or a storage class that implements .with_read_only()"
123124
) from e
125+
self = await cls._create_open_instance(read_only_store, path)
124126
else:
125127
# writable store and writable mode
126-
await store._ensure_open()
127128
self = await cls._create_open_instance(store, path)
128129

129130
# Handle mode-specific operations

0 commit comments

Comments
 (0)