Skip to content

Commit 9d56f92

Browse files
allow repeated extra arguments (#1673)
Co-authored-by: Martin Durant <[email protected]>
1 parent 952cd98 commit 9d56f92

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

fsspec/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ def _un_chain(path, kwargs):
346346
kws = kwargs.pop(protocol, {})
347347
if bit is bits[0]:
348348
kws.update(kwargs)
349-
kw = dict(**extra_kwargs, **kws)
349+
kw = dict(
350+
**{k: v for k, v in extra_kwargs.items() if k not in kws or v != kws[k]},
351+
**kws,
352+
)
350353
bit = cls._strip_protocol(bit)
351354
if (
352355
protocol in {"blockcache", "filecache", "simplecache"}

fsspec/tests/test_core.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,3 +465,21 @@ def test_chained_url(ftp_writable):
465465
def test_automkdir_local():
466466
fs, _ = fsspec.core.url_to_fs("file://", auto_mkdir=True)
467467
assert fs.auto_mkdir is True
468+
469+
470+
def test_repeated_argument():
471+
pytest.importorskip("adlfs")
472+
from fsspec.core import url_to_fs
473+
474+
fs, url = url_to_fs(
475+
"az://[email protected]/DATA",
476+
anon=False,
477+
account_name="ACCOUNT",
478+
)
479+
assert fs.storage_options == {"account_name": "ACCOUNT", "anon": False}
480+
with pytest.raises(TypeError):
481+
url_to_fs(
482+
"az://[email protected]/DATA",
483+
anon=False,
484+
account_name="OTHER",
485+
)

0 commit comments

Comments
 (0)