1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
from __future__ import annotations
class _Url:
"""Base URL class."""
def __init__(self, url: str | _Url):
if not isinstance(url, (str, _Url)):
raise TypeError(
f"`url` must be a str or an instance of _Url, "
f"got {url.__class__} instance instead"
)
self._url = str(url)
def __str__(self) -> str:
return self._url
def __repr__(self) -> str:
return f"{self.__class__.__name__}({self._url!r})"
class ResponseUrl(_Url):
"""URL of the response"""
class RequestUrl(_Url):
"""URL of the request"""
|