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

Expose NodePath? #205

Closed
TomNicholas opened this issue Jan 19, 2023 · 3 comments
Closed

Expose NodePath? #205

TomNicholas opened this issue Jan 19, 2023 · 3 comments
Labels
design question enhancement New feature or request

Comments

@TomNicholas
Copy link
Member

The concept of a file-like path between nodes is often useful. Internally I have an abstraction for this, the NodePath class, but publicly we currently only ever accept and return string paths.

NodePath is a powerful class because it inherits directly from pathlib.PurePosixPath, so it automatically has a .relative_to method, a .parts property, a .root, supports joining paths via the / operator, and is coercible into a string.

We could make NodePath public, and return it from node.path instead of a string as we currently do. This would be a breaking change, but would be nice for users for some tree manipulations, e.g. joining paths. They could still get to the string very easily via node.path.str.

What do we think about this? If we're going to change it we should change it sooner rather than later.

@TomNicholas TomNicholas added enhancement New feature or request design question labels Jan 19, 2023
@TomNicholas TomNicholas mentioned this issue Jan 20, 2023
5 tasks
@TomNicholas
Copy link
Member Author

(Turns out you do have to add .str on NodePath, as pathlib.Path only defines __str__.)

@satyamksharma
Copy link

hi there can you assign me to this issue

@TomNicholas
Copy link
Member Author

Closing as probably not that useful, see #281 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
design question enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants