From 7d28517d0424d722d3f114c48265498415cf348b Mon Sep 17 00:00:00 2001 From: Mikhail Karasikov Date: Mon, 16 Sep 2024 16:16:42 +0200 Subject: [PATCH 1/5] allow repeated extra arguments --- fsspec/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsspec/core.py b/fsspec/core.py index de66be28d..a1df77630 100644 --- a/fsspec/core.py +++ b/fsspec/core.py @@ -346,7 +346,7 @@ 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"} From 74e023dcdb33824cf24058ca5ea30ea6d3cac61d Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Thu, 10 Oct 2024 10:11:27 -0400 Subject: [PATCH 2/5] lint --- fsspec/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fsspec/core.py b/fsspec/core.py index a1df77630..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(**{k: v for k, v in extra_kwargs.items() if k not in kws or v != kws[k]}, **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"} From 32b7a97e7a1af0bbdff01e1174a64e8e310d7aef Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Wed, 16 Oct 2024 16:26:06 -0400 Subject: [PATCH 3/5] test --- fsspec/tests/test_core.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fsspec/tests/test_core.py b/fsspec/tests/test_core.py index 53592aff9..c1c6dd947 100644 --- a/fsspec/tests/test_core.py +++ b/fsspec/tests/test_core.py @@ -465,3 +465,20 @@ 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(): + 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", + ) From 04c92296c2452593ae149d9fdf995e88882d8f6b Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Wed, 16 Oct 2024 16:34:30 -0400 Subject: [PATCH 4/5] move line --- fsspec/tests/test_async.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fsspec/tests/test_async.py b/fsspec/tests/test_async.py index aa3c9bd4f..7f8504c87 100644 --- a/fsspec/tests/test_async.py +++ b/fsspec/tests/test_async.py @@ -96,9 +96,10 @@ async def runner(): total_running += 1 await asyncio.sleep(0) + total_running -= 1 + if total_running > 4: raise ValueError("More than 4 coroutines are running together") - total_running -= 1 return 1 async def main(**kwargs): From 4071ba2ec3f8c77830a04483486a87a0e71a388f Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Wed, 16 Oct 2024 16:38:43 -0400 Subject: [PATCH 5/5] try again --- fsspec/tests/test_async.py | 3 +-- fsspec/tests/test_core.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsspec/tests/test_async.py b/fsspec/tests/test_async.py index 7f8504c87..aa3c9bd4f 100644 --- a/fsspec/tests/test_async.py +++ b/fsspec/tests/test_async.py @@ -96,10 +96,9 @@ async def runner(): total_running += 1 await asyncio.sleep(0) - total_running -= 1 - if total_running > 4: raise ValueError("More than 4 coroutines are running together") + total_running -= 1 return 1 async def main(**kwargs): diff --git a/fsspec/tests/test_core.py b/fsspec/tests/test_core.py index c1c6dd947..1cdeec90c 100644 --- a/fsspec/tests/test_core.py +++ b/fsspec/tests/test_core.py @@ -468,6 +468,7 @@ def test_automkdir_local(): def test_repeated_argument(): + pytest.importorskip("adlfs") from fsspec.core import url_to_fs fs, url = url_to_fs(