# Buggy code
def _get_server_start_message(
    host_ip_version: _IPKind = _IPKind.IPv4,
) -> Tuple[str, str]:
    if host_ip_version is _IPKind.IPv6:
        ip_repr = "%s://[%s]:%d"
    else:
        ip_repr = "%s://%s:%d"
    message = f"Uvicorn running on {ip_repr} (Press CTRL+C to quit)"
    color_message = (
        "Uvicorn running on "
        + click.style(ip_repr, bold=True)
        + " (Press CTRL+C to quit)"
    )
    return message, color_message


# Traceback (ValueError)
.py thon/debugpy/launcher 61232 -- /Users/paulafernandez/Sandbox/test/test/start
INFO:     Started server process [43171]
INFO:     Waiting for application startup.
INFO:     ASGI 'lifespan' protocol appears unsupported.
INFO:     Application startup complete.
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/paulafernandez/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module>
cli.main()
File "/Users/paulafernandez/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/Users/paulafernandez/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 267, in run_file
runpy.run_path(options.target, run_name=compat.force_str("__main__"))
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/paulafernandez/Sandbox/test/test/start.py", line 18, in <module>
uvicorn.run(
File "/Users/paulafernandez/Library/Caches/pypoetry/virtualenvs/test-8kdwd4GS-py3.8/lib/python3.8/site-packages/uvicorn/main.py", line 391, in run
server.run()
File "/Users/paulafernandez/Library/Caches/pypoetry/virtualenvs/test-8kdwd4GS-py3.8/lib/python3.8/site-packages/uvicorn/main.py", line 419, in run
loop.run_until_complete(self.serve(sockets=sockets))
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/Users/paulafernandez/Library/Caches/pypoetry/virtualenvs/test-8kdwd4GS-py3.8/lib/python3.8/site-packages/uvicorn/main.py", line 436, in serve
await self.startup(sockets=sockets)
File "/Users/paulafernandez/Library/Caches/pypoetry/virtualenvs/test-8kdwd4GS-py3.8/lib/python3.8/site-packages/uvicorn/main.py", line 526, in startup
if isinstance(ip_address(config.host), IPv6Address):
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ipaddress.py", line 53, in ip_address
raise ValueError('%r does not appear to be an IPv4 or IPv6 address' %
ValueError: 'localhost' does not appear to be an IPv4 or IPv6 address

# Fixed code
def _get_server_start_message(is_ipv6_message: bool = False) -> Tuple[str, str]:
    if is_ipv6_message:
        ip_repr = "%s://[%s]:%d"
    else:
        ip_repr = "%s://%s:%d"
    message = f"Uvicorn running on {ip_repr} (Press CTRL+C to quit)"
    color_message = (
        "Uvicorn running on "
        + click.style(ip_repr, bold=True)
        + " (Press CTRL+C to quit)"
    )
    return message, color_message