Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Allow passing os.PathLike as an alternative to strings to represent node paths #282

Closed
wants to merge 3 commits into from

Conversation

TomNicholas
Copy link
Member

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.

  • Closes part of Use path-like tools with DataTree #281
  • Tests added
  • Passes pre-commit run --all-files
  • New functions/methods are listed in api.rst
  • Changes are summarized in docs/source/whats-new.rst

@TomNicholas
Copy link
Member Author

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)

@keewis
Copy link
Contributor

keewis commented Oct 8, 2024

closing in favor of the upstream issue (pydata/xarray#9448)

@keewis keewis closed this Oct 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants