Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

TomNicholas
Copy link
Collaborator

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
Collaborator 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant