from urllib.parse import urlparse

class TCPConnection:
    def __init__(self, host, port, timeout, **kwargs):
        super().__init__(**kwargs)
        print(f"New TCPConnection with {host=}, {port=}, {timeout=}")


class HTTPConnection(TCPConnection):
    def __init__(self, url, method="GET", **kwargs):
        parsed = urlparse(url)
        try:
            host, port = parsed.netloc.split(":")
        except ValueError:
            host, port = parsed.netloc, 80 if url.startswith("http://") else 443
        print(f"New HTTPConnection with {url=}, {method=}")
        super().__init__(host=host, port=int(port), **kwargs)


HTTPConnection(url="https://mdk.fr", timeout=10, fail=42)
# HTTPConnection(url="https://mdk.fr", timeout=10)