Is your feature request related to a problem?
No
Describe the solution you'd like
Return NotImplemented in URL.__truediv__ when called with an improper type. This will allow external classes to extend the functionality.
Here's my dream example:
class CustomPath(PurePosixPath):
@tp.overload
def __rtruediv__(self, key: PurePosixPath) -> PurePosixPath:
pass
@tp.overload
def __rtruediv__(self, key: URL) -> URL:
pass
def __rtruediv__(
self, key: tp.Union[PurePosixPath, URL]
) -> tp.Union[PurePosixPath, URL]:
if isinstance(key, URL):
breakpoint() # michael
return key / str(self)
return super().__rtruediv__(key)
if __name__ == "__main__":
p = CustomPath("abc/file.txt")
u = URL("http://beefslab.com/yes")
print(f"{u=}")
print(f"{p=}")
print(f"{u / p=}")
Describe alternatives you've considered
Subclassing yarl.URL is not supported :(
Additional context
def __truediv__(self, name):
if not type(name) is str:
return NotImplemented
return self._make_child((name,))
Code of Conduct
Is your feature request related to a problem?
No
Describe the solution you'd like
Return
NotImplementedinURL.__truediv__when called with an improper type. This will allow external classes to extend the functionality.Here's my dream example:
Describe alternatives you've considered
Subclassing yarl.URL is not supported :(
Additional context
Code of Conduct