From 7aec0a8dd82c1d625d048efbc7c7be9527468e08 Mon Sep 17 00:00:00 2001 From: Gregory Lee Date: Wed, 6 Jul 2022 11:39:51 -0400 Subject: [PATCH 1/2] remove option to return None when the input is None from _ensure_store This capability was contrary to the docstring and does not seem useful --- zarr/_storage/store.py | 4 +--- zarr/tests/test_storage.py | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/zarr/_storage/store.py b/zarr/_storage/store.py index 36a5c0bff5..6faf4a1250 100644 --- a/zarr/_storage/store.py +++ b/zarr/_storage/store.py @@ -100,9 +100,7 @@ def _ensure_store(store: Any): """ from zarr.storage import KVStore # avoid circular import - if store is None: - return None - elif isinstance(store, BaseStore): + if isinstance(store, BaseStore): if not store._store_version == 2: raise ValueError( f"cannot initialize a v2 store with a v{store._store_version} store" diff --git a/zarr/tests/test_storage.py b/zarr/tests/test_storage.py index abddb6965c..e6df4ac40c 100644 --- a/zarr/tests/test_storage.py +++ b/zarr/tests/test_storage.py @@ -73,8 +73,6 @@ class InvalidStore: with pytest.raises(ValueError): Store._ensure_store(KVStoreV3(dict())) - assert Store._ensure_store(None) is None - def test_capabilities(): s = KVStore(dict()) From af6f391f2e41ed60cc98c57c2dcd1c5aec687f97 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Mon, 11 Jul 2022 09:35:41 +0200 Subject: [PATCH 2/2] Add None test --- zarr/tests/test_storage.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zarr/tests/test_storage.py b/zarr/tests/test_storage.py index e6df4ac40c..a3e227ec86 100644 --- a/zarr/tests/test_storage.py +++ b/zarr/tests/test_storage.py @@ -73,6 +73,10 @@ class InvalidStore: with pytest.raises(ValueError): Store._ensure_store(KVStoreV3(dict())) + # cannot initialize without a store + with pytest.raises(ValueError): + Store._ensure_store(None) + def test_capabilities(): s = KVStore(dict())