Skip to content

Commit cc5813b

Browse files
address Copilot review on libp2p#1317
- _extract_host_port_from_sockname now takes sock_name: object rather than Any, matching the runtime isinstance checks and avoiding an unnecessary typing.Any dependency - The sockname-unrecognised warning branch now explicitly restores actual_host/actual_port from the requested host/port, so the 'falling back to requested host/port' log line is self-contained and the intent is obvious from the code flow
1 parent 623949f commit cc5813b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

libp2p/transport/websocket/listener.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
def _extract_host_port_from_sockname(
35-
sock_name: Any,
35+
sock_name: object,
3636
) -> tuple[str, int] | None:
3737
"""
3838
Return ``(host, port)`` from a ``socket.getsockname()`` return value, or
@@ -322,6 +322,9 @@ async def _run_server() -> None:
322322
if host_port is not None:
323323
actual_host, actual_port = host_port
324324
else:
325+
# Explicitly restore the requested host/port so the
326+
# fallback mentioned in the warning is self-contained.
327+
actual_host, actual_port = host, port
325328
logger.warning(
326329
"Unexpected getsockname() result %r; "
327330
"falling back to requested host/port",

0 commit comments

Comments
 (0)