Skip to content

subclassing from UPath #26

@brl0

Description

@brl0

Not sure if I am doing this properly, but subclassing UPath is challenging, in part due to this check in the __new__ method:

https://github.com/Quansight/universal_pathlib/blob/dbc57f7ec4c8bb8b2e22975f6b62e25b2b82ecff/upath/core.py#L12

I am curious if this could be changed to:

        if issubclass(cls, UPath):

This would return True even for issubclass(UPath, UPath).

Happy to submit a PR if you are ok with this change.

My surprisingly challenging attempt to subclass UPath to add some convenience methods has really grown my appreciation for what this project has accomplished.

On a related note, after digging deeper into the code, and exploring the pathlib implementation, I am wondering if UPath would benefit from having something like a _URI_Flavour derived from the pathlib._Flavour class. This might make it easier to have consistent path handling across the fsspec based implementations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions