Skip to content

Commit 8136713

Browse files
committed
minor docstring fixes
add assert statements to test_capabilities
1 parent 30afcbb commit 8136713

3 files changed

Lines changed: 20 additions & 21 deletions

File tree

‎zarr/hierarchy.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def __enter__(self):
254254
return self
255255

256256
def __exit__(self, exc_type, exc_val, exc_tb):
257-
"""If the underlying Store should always heave a ``close`` method, call it."""
257+
"""Call the close method of the underlying Store."""
258258
self.store.close()
259259

260260
def info_items(self):

‎zarr/storage.py‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@
8282
class Store(MutableMapping):
8383
"""Base class for stores implementation.
8484
85-
86-
Provide a number of default method as well as other typing guaranties for mypy.
85+
Provide a number of default method as well as other typing guaranties for
86+
mypy.
8787
8888
Stores cannot be mutable mapping as they do have a couple of other
8989
requirements that would break Liskov substitution principle (stores only
@@ -96,7 +96,7 @@ class Store(MutableMapping):
9696
9797
Stores can be used as context manager to make sure they close on exit.
9898
99-
.. added: 2.5.0
99+
.. added: 2.9.0
100100
101101
"""
102102

@@ -135,7 +135,7 @@ def listdir(self, path: str = "") -> List[str]:
135135
def rename(self, src_path: str, dst_path: str) -> None:
136136
if not self.is_erasable():
137137
raise NotImplementedError(
138-
f'{type(self)} is not erasable, cannot call "rmdir"'
138+
f'{type(self)} is not erasable, cannot call "rename"'
139139
) # pragma: no cover
140140
_rename_from_keys(self, src_path, dst_path)
141141

@@ -154,9 +154,9 @@ def close(self) -> None:
154154
@staticmethod
155155
def _ensure_store(store):
156156
"""
157-
We want to make sure internally that zarr storage are internally always
158-
a class with a specific interface derived from Store, which is slightly
159-
different than mutable mapping.
157+
We want to make sure internally that zarr stores are always a class
158+
with a specific interface derived from ``Store``, which is slightly
159+
different than ``MutableMapping``.
160160
161161
We'll do this conversion in a few places automatically
162162
"""
@@ -182,8 +182,8 @@ def _ensure_store(store):
182182
return KVStore(store)
183183

184184
raise ValueError(
185-
"Starting with Zarr X.y.z, stores must be subclasses of Store, if "
186-
"you store expose the MutableMapping interface wrap them in "
185+
"Starting with Zarr 2.9.0, stores must be subclasses of Store, if "
186+
"your store exposes the MutableMapping interface wrap it in "
187187
f"Zarr.storage.KVStore. Got {store}"
188188
)
189189

@@ -281,8 +281,8 @@ def listdir(store: Store, path: Path = None):
281281
else:
282282
# slow version, iterate through all keys
283283
warnings.warn(
284-
"Store {store} has not `listdir` method. From zarr 2.5 you may want"
285-
"to inherit from `Store`.".format(store=store),
284+
f"Store {store} has no `listdir` method. From zarr 2.9 onwards "
285+
"may want to inherit from `Store`.",
286286
stacklevel=2,
287287
)
288288
return _listdir_from_keys(store, path)
@@ -641,10 +641,10 @@ def _dict_store_keys(d: Dict, prefix="", cls=dict):
641641

642642
class KVStore(Store):
643643
"""
644-
This provide an default implementation of a store interface around
645-
a mutable mapping, to avoid having to test stores for presence of methods
644+
This provides a default implementation of a store interface around
645+
a mutable mapping, to avoid having to test stores for presence of methods.
646646
647-
This, for most method should just be a pass-through to the underlying KV
647+
This, for most methods should just be a pass-through to the underlying KV
648648
store which is likely to expose a MuttableMapping interface,
649649
"""
650650

‎zarr/tests/test_storage.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ class InvalidStore:
6868

6969
def test_capabilities():
7070
s = KVStore(dict())
71-
s.is_readable()
72-
s.is_listable()
73-
s.is_erasable()
74-
s.is_writeable()
75-
71+
assert s.is_readable()
72+
assert s.is_listable()
73+
assert s.is_erasable()
74+
assert s.is_writeable()
7675

7776
def test_getsize_non_implemented():
7877
assert getsize(object()) == -1
@@ -90,7 +89,7 @@ def test_coverage_rename():
9089

9190
def test_deprecated_listdir_nosotre():
9291
store = dict()
93-
with pytest.warns(UserWarning, match="has not `listdir`"):
92+
with pytest.warns(UserWarning, match="has no `listdir`"):
9493
listdir(store)
9594

9695

0 commit comments

Comments
 (0)