datatree
datatree copied to clipboard
Allow passing os.PathLike as an alternative to strings to represent node paths
Broadens the types that getitem and setitem methods accept to include anything that follows the os.PathLike
protocol.
It's possible there are some additional edge cases here that we should forbid, such as passing a Windows-style path.
- [x] Closes part of #281
- [ ] Tests added
- [ ] Passes
pre-commit run --all-files
- [ ] ~~New functions/methods are listed in
api.rst
~~ - [x] Changes are summarized in
docs/source/whats-new.rst
The only reason I haven't merged this is that I can't see what mypy's problem with this is:
datatree/mapping.py:245: error: Argument 1 to "from_dict" of "DataTree" has incompatible type "dict[str, Any | None]"; expected "MutableMapping[str | PathLike[Any], Any | DataTree[Any] | None]" [arg-type]
Found 1 error in 1 file (checked 25 source files)