22from glob import glob
33from io import BytesIO
44from numbers import Number
5- from pathlib import Path
65from typing import (
76 TYPE_CHECKING ,
87 Callable ,
@@ -808,7 +807,7 @@ def open_mfdataset(
808807 - "override": if indexes are of same size, rewrite indexes to be
809808 those of the first object with that dimension. Indexes for the same
810809 dimension must have the same size in all objects.
811- attrs_file : str or pathlib.Path , optional
810+ attrs_file : str or path-like , optional
812811 Path of the file used to read global attributes from.
813812 By default global attributes are read from the first file provided,
814813 with wildcard matches sorted by filename.
@@ -868,7 +867,7 @@ def open_mfdataset(
868867 elif isinstance (paths , os .PathLike ):
869868 paths = [os .fspath (paths )]
870869 else :
871- paths = [str (p ) if isinstance (p , Path ) else p for p in paths ]
870+ paths = [os . fspath (p ) if isinstance (p , os . PathLike ) else p for p in paths ]
872871
873872 if not paths :
874873 raise OSError ("no files to open" )
@@ -960,8 +959,8 @@ def multi_file_closer():
960959
961960 # read global attributes from the attrs_file or from the first dataset
962961 if attrs_file is not None :
963- if isinstance (attrs_file , Path ):
964- attrs_file = str (attrs_file )
962+ if isinstance (attrs_file , os . PathLike ):
963+ attrs_file = os . fspath (attrs_file )
965964 combined .attrs = datasets [paths .index (attrs_file )].attrs
966965
967966 return combined
@@ -994,8 +993,8 @@ def to_netcdf(
994993
995994 The ``multifile`` argument is only for the private use of save_mfdataset.
996995 """
997- if isinstance (path_or_file , Path ):
998- path_or_file = str (path_or_file )
996+ if isinstance (path_or_file , os . PathLike ):
997+ path_or_file = os . fspath (path_or_file )
999998
1000999 if encoding is None :
10011000 encoding = {}
@@ -1136,7 +1135,7 @@ def save_mfdataset(
11361135 ----------
11371136 datasets : list of Dataset
11381137 List of datasets to save.
1139- paths : list of str or list of Path
1138+ paths : list of str or list of path-like objects
11401139 List of paths to which to save each corresponding dataset.
11411140 mode : {"w", "a"}, optional
11421141 Write ("w") or append ("a") mode. If mode="w", any existing file at
@@ -1304,7 +1303,7 @@ def check_dtype(var):
13041303
13051304def to_zarr (
13061305 dataset : Dataset ,
1307- store : Union [MutableMapping , str , Path ] = None ,
1306+ store : Union [MutableMapping , str , os . PathLike ] = None ,
13081307 chunk_store = None ,
13091308 mode : str = None ,
13101309 synchronizer = None ,
@@ -1328,7 +1327,7 @@ def to_zarr(
13281327 if v .size == 0 :
13291328 v .load ()
13301329
1331- # expand str and Path arguments
1330+ # expand str and path-like arguments
13321331 store = _normalize_path (store )
13331332 chunk_store = _normalize_path (chunk_store )
13341333
0 commit comments