You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for pandas.read_csv(...) states that it can support anything that adheres to the os.PathLike protocol, but the definition of FilePathOrBuffer is too strict.
PathLike is in quotes because PathLike only supports __class_getitem__ for Python 3.9 and later and PathLike alone might be too broad, assuming you don't want to support byte-encoded paths.
Thanks!
The text was updated successfully, but these errors were encountered:
Replacing pathlib.Path with os.PathLike[str] should definitely work! Most (all?) IO calls go through get_handle which internally calls stringify_path which converts all os.PathLike[str] using __fspath__ to a string. Unless you add a decode function to stringify_path, I wouldn't add os.PathLike[bytes].
I think we already have tests for non-pathlib.Path PathLike objects.
From what I gathered through @twoertwein comment, the PathLike[str] change will bring the definition of FilePathorBuffer closer to being in-line with the documentation for pandas.read_csv(...). Should I go ahead and make that change?
The documentation for
pandas.read_csv(...)
states that it can support anything that adheres to theos.PathLike
protocol, but the definition ofFilePathOrBuffer
is too strict.pandas/pandas/_typing.py
Line 138 in 08e4baf
where
Path
is apathlib.Path
object.Could this be changed to use
os.PathLike[str]
or justos.PathLike
?PathLike
is in quotes becausePathLike
only supports__class_getitem__
for Python 3.9 and later andPathLike
alone might be too broad, assuming you don't want to support byte-encoded paths.Thanks!
The text was updated successfully, but these errors were encountered: