Skip to content

Commit ecec453

Browse files
committed
Readd isdir check, but only after shortcuts
1 parent 9df7c6d commit ecec453

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

fsspec/implementations/reference.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
from fsspec.callbacks import DEFAULT_CALLBACK
2323
from fsspec.core import filesystem, open, split_protocol
2424
from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper
25-
from fsspec.utils import get_file_extension, isfilelike, merge_offset_ranges, other_paths
25+
from fsspec.utils import (
26+
isfilelike,
27+
merge_offset_ranges,
28+
other_paths,
29+
)
2630

2731
logger = logging.getLogger("fsspec.reference")
2832

@@ -698,7 +702,9 @@ def __init__(
698702
**(ref_storage_args or target_options or {}), protocol=target_protocol
699703
)
700704
ref_fs, fo2 = fsspec.core.url_to_fs(fo, **dic)
701-
if get_file_extension(fo2) in {"parq", "parquet"}:
705+
if ".json" not in fo2 and (
706+
fo.endswith(("parq", "parquet", "/")) or ref_fs.isdir(fo2)
707+
):
702708
# Lazy parquet refs
703709
logger.info("Open lazy reference dict from URL %s", fo)
704710
self.references = LazyReferenceMapper(

fsspec/tests/test_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ def test_get_protocol(par):
338338
url, outcome = par
339339
assert get_protocol(url) == outcome
340340

341+
341342
@pytest.mark.parametrize(
342343
["url", "expected"],
343344
(
@@ -347,13 +348,14 @@ def test_get_protocol(par):
347348
("file:///home/user/no_extension", ""),
348349
("/local/path/to/file.json", "json"),
349350
("relative/path/file.yaml", "yaml"),
350-
)
351+
),
351352
)
352353
def test_get_file_extension(url, expected):
353354
actual = get_file_extension(url)
354355

355356
assert actual == expected
356357

358+
357359
@pytest.mark.parametrize(
358360
"par",
359361
[

fsspec/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,10 @@ def get_protocol(url: str) -> str:
437437
return parts[0]
438438
return "file"
439439

440+
440441
def get_file_extension(url: str) -> str:
441442
url = stringify_path(url)
442-
ext_parts = url.rsplit(".", 1)
443+
ext_parts = url.rsplit(".", 1)
443444
if len(ext_parts) > 1:
444445
return ext_parts[-1]
445446
return ""

0 commit comments

Comments
 (0)