yarl
yarl copied to clipboard
Allow scheme replacement for relative urls
URL('path/to').with_scheme('http')
should work.
Now it produces scheme replacement is not allowed for relative URLs
GitMate.io thinks possibly related issues are https://github.com/aio-libs/yarl/issues/185 (Allow joining URL and pathlib.Path), https://github.com/aio-libs/yarl/issues/99 (Document-relative urls like '?a=b'), https://github.com/aio-libs/yarl/issues/33 (Parse URL parameter), https://github.com/aio-libs/yarl/issues/272 (bool(URL()) should be False), and https://github.com/aio-libs/yarl/issues/24 (TypeError in URL.with_query).
File URLs that are absolute are also being blocked from updating the scheme:
>>> URL('file:///absolute/path').with_scheme('file')
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/.../lib/python3.7/site-packages/yarl/_url.py()", line 794, in with_scheme
raise ValueError("scheme replacement is not allowed for relative URLs")
ValueError: scheme replacement is not allowed for relative URLs
This is rather a confusing error.