I think letting the user define a custom __init__
signature is a quite important feature.
- For the end user, this is the most natural option
- This is how existing pathlib-like API are currently implemented. So not supporting it will either break existing code, or prevent codebase from migrating (defeating the purpose of
AbstractPath
).
For example:
-
universal_pathlib
: universal_pathlib/core.py at f551c5914479c61b2af2c0827f98e499e4473740 · fsspec/universal_pathlib · GitHub
p = upath.UPath('gs://bucket/f.txt', asynchronous=True)
-
zipfile.Path
: cpython/zipfile.py at b62d37c4a5016b3239c72c147de7f04a9be66e02 · python/cpython · GitHub
p = zipfile.Path('archive.zip', at='folder/f.txt')
Internally, zipfile use a _next
function to create other path sharing the same state. Maybe something similar could be used here.