# Buggy code
def host(self) -> str:
    """
    The URL host as a string.
    Always normlized to lowercase, and IDNA encoded.

    Examples:

    url = httpx.URL("http://www.EXAMPLE.org")
    assert url.host == "www.example.org"

    url = httpx.URL("http://中国.icom.museum")
    assert url.host == "xn--fiqs8s.icom.museum"
    """
    return self._uri_reference.host or ""


# Traceback (httpcore.ConnectError)
<Response [200]>
<Response [200]>
<Response [200 OK]>
Traceback (most recent call last):
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpx/_exceptions.py", line 339, in map_exceptions
yield
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpx/_client.py", line 858, in _send_single_request
ext={"timeout": timeout.as_dict()},
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpcore/_sync/connection_pool.py", line 195, in request
method, url, headers=headers, stream=stream, ext=ext
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpcore/_sync/connection.py", line 87, in request
self.socket = self._open_socket(timeout)
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpcore/_sync/connection.py", line 113, in _open_socket
local_address=self.local_address,
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpcore/_backends/sync.py", line 144, in open_tcp_stream
return SyncSocketStream(sock=sock)
File "/home/user/.local/share/pyenv/versions/3.7.6/lib/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
raise to_exc(exc) from None
httpcore.ConnectError: [Errno -2] Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "kek.py", line 11, in <module>
print(httpx.get(url6))
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpx/_api.py", line 193, in get
trust_env=trust_env,
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpx/_api.py", line 104, in request
allow_redirects=allow_redirects,
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpx/_client.py", line 722, in request
request, auth=auth, allow_redirects=allow_redirects, timeout=timeout
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpx/_client.py", line 758, in send
history=[],
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpx/_client.py", line 795, in _send_handling_auth
history=history,
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpx/_client.py", line 823, in _send_handling_redirects
response = self._send_single_request(request, timeout)
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpx/_client.py", line 858, in _send_single_request
ext={"timeout": timeout.as_dict()},
File "/home/user/.local/share/pyenv/versions/3.7.6/lib/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/home/user/repos/lb-test/.venv/lib/python3.7/site-packages/httpx/_exceptions.py", line 356, in map_exceptions
raise mapped_exc(message, **kwargs) from exc  # type: ignore
httpx.ConnectError: [Errno -2] Name or service not known

# Fixed code
def host(self) -> str:
    """
    The URL host as a string.
    Always normlized to lowercase, and IDNA encoded.

    Examples:

    url = httpx.URL("http://www.EXAMPLE.org")
    assert url.host == "www.example.org"

    url = httpx.URL("http://中国.icom.museum")
    assert url.host == "xn--fiqs8s.icom.museum"

    url = httpx.URL("https://[::ffff:192.168.0.1]")
    assert url.host == "::ffff:192.168.0.1"
    """
    host: str = self._uri_reference.host

    if host and ":" in host and host[0] == "[":
        # it's an IPv6 address
        host = host.lstrip("[").rstrip("]")

    return host or ""