Closed mgrover1 closed 8 months ago
Uh oh! Perhaps it wasn't so clever to subclass a class from the pathlib standard libary :sweat_smile:
@TomNicholas - from the highlights, it looks like subclassing the pathlib.Path class is now supported directly
Significant improvements in the standard library:
The pathlib.Path class now supports subclassing
The os module received several improvements for Windows support
A command-line interface has been added to the sqlite3 module
Oh interesting! I deliberately didn't subclass Path
though because (a) these paths should not be linked to the filesystem and (b) I don't want the direction of the separator slashes flipping on Windows systems. (Also do the docs clearly state which classes do and don't support subclassing...?)
Those are great questions... I am not sure. Also it is unclear of what exactly changed here that is causing the lack of those methods...
@TomNicholas from further down the page:
Add support for subclassing pathlib.PurePath and pathlib.Path, plus their Posix- and Windows-specific variants. Subclasses may override the pathlib.PurePath.with_segments() method to pass information between path instances.
@TomNicholas - how difficult of a fix would you think this would be? I am happy to help where possible.
how difficult of a fix would you think this would be? I am happy to help where possible.
Probably really easy - I suspect that we would just need to rewrite NodePath
to initialize using whatever the newly-recommended approach is. (Looks like we can just use __init__
now.) NodePath
doesn't even add any functionality on top of using PurePosixPath
, it just forbids some obviously-invalid path strings, so we can just keep those checks in the new __init__
.
To make it work on different versions of python I think we would need to wrap the definition of NodePath
within an if else
check of sys.version
.
It might also be good to add a test that specifically checks that we can create a NodePath
object and successfully do whatever it is that causes those errors (looks like simply viewing the repr
?)
@TomNicholas - once #260 is merged, would you be willing to cut a new release for datatree, which would release 3.12 wheels?
As of now, several components break with Python 3.12. Here is a sample of the output after installing Python 3.12 in the datatree dev environment. It appears to be related to pathlib, but I am not exactly sure. Any thoughts here?