Skip to content

Commit

Permalink
minor docstring fixes
Browse files Browse the repository at this point in the history
add assert statements to test_capabilities
  • Loading branch information
grlee77 committed Jun 23, 2021
1 parent 30afcbb commit 8136713
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion zarr/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def __enter__(self):
return self

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

def info_items(self):
Expand Down
28 changes: 14 additions & 14 deletions zarr/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
class Store(MutableMapping):
"""Base class for stores implementation.
Provide a number of default method as well as other typing guaranties for mypy.
Provide a number of default method as well as other typing guaranties for
mypy.
Stores cannot be mutable mapping as they do have a couple of other
requirements that would break Liskov substitution principle (stores only
Expand All @@ -96,7 +96,7 @@ class Store(MutableMapping):
Stores can be used as context manager to make sure they close on exit.
.. added: 2.5.0
.. added: 2.9.0
"""

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

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

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

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

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

Expand Down
11 changes: 5 additions & 6 deletions zarr/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ class InvalidStore:

def test_capabilities():
s = KVStore(dict())
s.is_readable()
s.is_listable()
s.is_erasable()
s.is_writeable()

assert s.is_readable()
assert s.is_listable()
assert s.is_erasable()
assert s.is_writeable()

def test_getsize_non_implemented():
assert getsize(object()) == -1
Expand All @@ -90,7 +89,7 @@ def test_coverage_rename():

def test_deprecated_listdir_nosotre():
store = dict()
with pytest.warns(UserWarning, match="has not `listdir`"):
with pytest.warns(UserWarning, match="has no `listdir`"):
listdir(store)


Expand Down

0 comments on commit 8136713

Please sign in to comment.