Description
Downstream libraries often want to extend the UPath class interface with custom methods.
If you need support for multiple protocols this can be extremely annoying and cumbersome to implement, because of the implementation of UPath.__new__
which creates the correct UPath subclass for the specific protocol.
A user would have to subclass every UPath implementation they want to support and register those as default implementations.
As a workaround, _protocol_dispatch=False
was introduced and can currently be set on the UPath class, which prevents this mechanism, and only returns instances of the current class. But because some of the UPath implementations have fixes for UPath methods implemented by overriding individual methods of the UPath interface, these would all have to be reimplemented in the user subclass to support a specific protocol.
So this workaround is far from a good solution.
It would be better to have a custom base class user can derive from that delegates to the correct UPath subclass and hides the class inheritance tree from the user.