Closed wpbonelli closed 1 year ago
Thanks for raising this. I've been slowly working on this since October 2022, e.g. #1583, #1603. With some of the previous refactoring, I've generally found path manipulation with pathlib
to be simpler and easier to read than os.path
.
Some general tips:
pathlib
and os
module functionsif isinstance(file_name, os.PathLike)
, because there are other path-like classes e.g. path
Closed by #1730. Some notebooks and tests still use strings instead of paths, but maybe not a terrible idea to keep it that way to exercise both options
Is your feature request related to a problem? Please describe. FloPy currently expects strings for some path parameters (files/dirs to read from or write to, etc). #1712 recently added support for
pathlib.Path
to some internals, allowing path-like objects to be passed e.g. toMFSimulation
's ctor.Describe the solution you'd like Extending path-like support to all user-facing APIs would be convenient for use with modern
pathlib.Path
, removing the need to wrap withstr(...)
, without breaking existing string usages. Type hintUnion[str, os.PathLike]
could be used in the spirit of PEP 519 — further SO discussions here and here. In many casesPath
/path-like are already implicitly supported and docstrings could just be updated, but this is not universally true and some refactoring would be needed.