Skip to content

Commit

Permalink
normalize remotestore __str__ method
Browse files Browse the repository at this point in the history
  • Loading branch information
d-v-b committed Jun 12, 2024
1 parent 1948628 commit 68f9d2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/zarr/store/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class RemoteStore(Store):
supports_listing: bool = True

_fs: AsyncFileSystem
_url: str
path: str
allowed_exceptions: tuple[type[Exception], ...]

Expand All @@ -51,7 +52,7 @@ def __init__(
"""

super().__init__(mode=mode)

self._url = url
if isinstance(url, str):
self._fs, self.path = fsspec.url_to_fs(url, **storage_options)
elif hasattr(url, "protocol") and hasattr(url, "fs"):
Expand All @@ -71,10 +72,10 @@ def __init__(
raise TypeError("FileSystem needs to support async operations")

def __str__(self) -> str:
return f"Remote fsspec store: {type(self._fs).__name__} , {self.path}"
return f"{self._url}"

def __repr__(self) -> str:
return f"<RemoteStore({type(self._fs).__name__} , {self.path})>"
return f"<RemoteStore({type(self._fs).__name__}, {self.path})>"

async def get(
self,
Expand Down
4 changes: 1 addition & 3 deletions tests/v3/test_store/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ def set(self, store: RemoteStore, key: str, value: Buffer) -> None:
self._fs.write_bytes(f"{store.path}/{key}", value.to_bytes())

def test_store_repr(self, store: RemoteStore) -> None:
rep = str(store)
assert "fsspec" in rep
assert store.path in rep
assert str(store) == f"{store._url}"

def test_store_supports_writes(self, store: RemoteStore) -> None:
assert True
Expand Down

0 comments on commit 68f9d2c

Please sign in to comment.