Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow repeated extra arguments #1673

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
)
Loading