We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__rtruediv__
No
Return NotImplemented in URL.__truediv__ when called with an improper type. This will allow external classes to extend the functionality.
NotImplemented
URL.__truediv__
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=}")
Subclassing yarl.URL is not supported :(
def __truediv__(self, name): if not type(name) is str: return NotImplemented return self._make_child((name,))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Is your feature request related to a problem?
No
Describe the solution you'd like
Return
NotImplemented
inURL.__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
The text was updated successfully, but these errors were encountered: