Make pathlib extensible

I think letting the user define a custom __init__ signature is a quite important feature.

  1. For the end user, this is the most natural option
  2. 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:

p = upath.UPath('gs://bucket/f.txt', asynchronous=True)
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.

3 Likes