MCPcopy
hub / github.com/python-trio/trio / format_host_port

Function format_host_port

src/trio/_highlevel_open_tcp_stream.py:157–162  ·  view source on GitHub ↗
(host: str | bytes, port: int | str)

Source from the content-addressed store, hash-verified

155
156
157def format_host_port(host: str | bytes, port: int | str) -> str:
158 host = host.decode("ascii") if isinstance(host, bytes) else host
159 if ":" in host:
160 return f"[{host}]:{port}"
161 else:
162 return f"{host}:{port}"
163
164
165# Twisted's HostnameEndpoint has a good set of configurations:

Callers 2

test_format_host_portFunction · 0.90
open_tcp_streamFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_format_host_portFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…