From d38c1867973633c47a016ffa88656346a2d57141 Mon Sep 17 00:00:00 2001 From: Fredrik Jansson Date: Tue, 5 Aug 2025 14:11:44 +0200 Subject: [PATCH 1/2] fsspec path handling Proposed as fix for #3201. Some filesystems need the scheme as part of the path, while others don't. FsspecStore.from_url() throws an exception if the scheme is left in the path, for any filesystem except http and https. However, the swift fs also needs the scheme in the path. This commit removes the exception, rather than adding more special cases. --- src/zarr/storage/_fsspec.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/zarr/storage/_fsspec.py b/src/zarr/storage/_fsspec.py index c5afed521c..7945fba467 100644 --- a/src/zarr/storage/_fsspec.py +++ b/src/zarr/storage/_fsspec.py @@ -138,10 +138,6 @@ def __init__( category=ZarrUserWarning, stacklevel=2, ) - if "://" in path and not path.startswith("http"): - # `not path.startswith("http")` is a special case for the http filesystem (¯\_(ツ)_/¯) - scheme, _ = path.split("://", maxsplit=1) - raise ValueError(f"path argument to FsspecStore must not include scheme ({scheme}://)") @classmethod def from_upath( @@ -246,12 +242,6 @@ def from_url( if not fs.async_impl: fs = _make_async(fs) - # fsspec is not consistent about removing the scheme from the path, so check and strip it here - # https://github.com/fsspec/filesystem_spec/issues/1722 - if "://" in path and not path.startswith("http"): - # `not path.startswith("http")` is a special case for the http filesystem (¯\_(ツ)_/¯) - path = fs._strip_protocol(path) - return cls(fs=fs, path=path, read_only=read_only, allowed_exceptions=allowed_exceptions) def with_read_only(self, read_only: bool = False) -> FsspecStore: From e3273e8c12ff7f6d27d8c1af5cc4cea4ae2ca54d Mon Sep 17 00:00:00 2001 From: Fredrik Jansson Date: Thu, 18 Sep 2025 12:08:59 +0200 Subject: [PATCH 2/2] fsspec path handling: remove test for scheme in path --- tests/test_store/test_fsspec.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/test_store/test_fsspec.py b/tests/test_store/test_fsspec.py index e970c674d4..1e3ed26568 100644 --- a/tests/test_store/test_fsspec.py +++ b/tests/test_store/test_fsspec.py @@ -238,14 +238,6 @@ def test_from_upath(self) -> None: assert result.fs.asynchronous assert result.path == f"{test_bucket_name}/foo/bar" - def test_init_raises_if_path_has_scheme(self, store_kwargs: dict[str, Any]) -> None: - # regression test for https://github.com/zarr-developers/zarr-python/issues/2342 - store_kwargs["path"] = "s3://" + store_kwargs["path"] - with pytest.raises( - ValueError, match="path argument to FsspecStore must not include scheme .*" - ): - self.store_cls(**store_kwargs) - def test_init_warns_if_fs_asynchronous_is_false(self) -> None: try: from fsspec import url_to_fs