diff --git a/fsspec/core.py b/fsspec/core.py index de66be28d..f53d64268 100644 --- a/fsspec/core.py +++ b/fsspec/core.py @@ -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"} diff --git a/fsspec/tests/test_core.py b/fsspec/tests/test_core.py index 53592aff9..1cdeec90c 100644 --- a/fsspec/tests/test_core.py +++ b/fsspec/tests/test_core.py @@ -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://DIR@ACCOUNT.blob.core.windows.net/DATA", + anon=False, + account_name="ACCOUNT", + ) + assert fs.storage_options == {"account_name": "ACCOUNT", "anon": False} + with pytest.raises(TypeError): + url_to_fs( + "az://DIR@ACCOUNT.blob.core.windows.net/DATA", + anon=False, + account_name="OTHER", + )