diff --git a/xarray/backends/common.py b/xarray/backends/common.py index c51cf3d1964..534567221b5 100644 --- a/xarray/backends/common.py +++ b/xarray/backends/common.py @@ -136,14 +136,15 @@ def _find_absolute_paths( def _normalize_path_list( lpaths: NestedSequence[str | os.PathLike], ) -> NestedSequence[str]: - return [ - ( - _normalize_path(p) - if isinstance(p, str | os.PathLike) - else _normalize_path_list(p) - ) - for p in lpaths - ] + paths = [] + for p in lpaths: + if isinstance(p, str | os.PathLike): + paths.append(_normalize_path(p)) + elif isinstance(p, list): + paths.append(_normalize_path_list(p)) # type: ignore[arg-type] + else: + paths.append(p) # type: ignore[arg-type] + return paths return _normalize_path_list(paths) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index 7be6eb5ed0d..c543333c61e 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -5511,6 +5511,8 @@ def test_source_encoding_always_present_with_fsspec() -> None: fs = fsspec.filesystem("file") with fs.open(tmp) as f, open_dataset(f) as ds: assert ds.encoding["source"] == tmp + with fs.open(tmp) as f, open_mfdataset([f]) as ds: + assert "foo" in ds def _assert_no_dates_out_of_range_warning(record):