universal_pathlib icon indicating copy to clipboard operation
universal_pathlib copied to clipboard

upath.extensions.ProxyUPath: provide a way to define supported protocols

Open ap-- opened this issue 5 months ago • 0 comments

In case you want to extend the UPath API it's common that you only need a subset of filesystems. We should provide a convenient way to do this.

from upath.extensions import ProxyUPath

# maybe this?
class MyUPath(ProxyUPath, restrict_protocols=("s3", "gcs", "az", "file")):
    def hello_world(self):
        return f"Hello {self!r} World!"

# or this?
class MyUPath(ProxyUPath):
    supported_protocols = ("s3", "gcs", "az", "file")

    def hello_world(self):
        return f"Hello {self!r} World!"

ap-- avatar Oct 06 '25 09:10 ap--