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 parsing Nodes as PathLike #4696

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Repiteo
Copy link
Contributor

@Repiteo Repiteo commented Mar 10, 2025

Adds __fspath__ to the Node class so they can be passed directly as pathlike arguments.

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt and RELEASE.txt (and read the README.rst).
  • I have updated the appropriate documentation

@mwichmann
Copy link
Collaborator

This looks reasonable to me, after scanning through it in more detail than the first glance.

I'll want to think about where this has doc impacts, I think we talk about using str() to get the file name string somewhere. Being a PathLike object means that's handled for file-ish uses such open, checks like isdir, etc. but doesn't work when you need to get the string to do something else with (like printing for debug - that's the most frequent use by far in the docs). I see that came up a few times in the tests. Probably the Node Objects section.

@mwichmann
Copy link
Collaborator

Adding for reviewer reference - the protocol used came in via PEP 519, introduced in Python 3.6.

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

Successfully merging this pull request may close these issues.

2 participants