Skip to content

Commit

Permalink
allow repeated extra arguments (#1673)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Durant <[email protected]>
  • Loading branch information
karasikov and martindurant authored Oct 16, 2024
1 parent 952cd98 commit 9d56f92
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fsspec/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,10 @@ def _un_chain(path, kwargs):
kws = kwargs.pop(protocol, {})
if bit is bits[0]:
kws.update(kwargs)
kw = dict(**extra_kwargs, **kws)
kw = dict(
**{k: v for k, v in extra_kwargs.items() if k not in kws or v != kws[k]},
**kws,
)
bit = cls._strip_protocol(bit)
if (
protocol in {"blockcache", "filecache", "simplecache"}
Expand Down
18 changes: 18 additions & 0 deletions fsspec/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,21 @@ def test_chained_url(ftp_writable):
def test_automkdir_local():
fs, _ = fsspec.core.url_to_fs("file://", auto_mkdir=True)
assert fs.auto_mkdir is True


def test_repeated_argument():
pytest.importorskip("adlfs")
from fsspec.core import url_to_fs

fs, url = url_to_fs(
"az://[email protected]/DATA",
anon=False,
account_name="ACCOUNT",
)
assert fs.storage_options == {"account_name": "ACCOUNT", "anon": False}
with pytest.raises(TypeError):
url_to_fs(
"az://[email protected]/DATA",
anon=False,
account_name="OTHER",
)

0 comments on commit 9d56f92

Please sign in to comment.