refactor: remove redundant comments and docstrings (#6527)

* refactor: remove redundant comments and docstrings

* fix(signal): annotate async context manager as a generator
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-30 13:07:03 +08:00
1 parent cb3ba45317
commit a4d2430140
922 files changed
+406 -7738

No files matched your search

-15
View File
@@ -1,4 +1,3 @@
"""Tests for MCP HTTP probe guard (prevents event-loop crash on unreachable servers)."""
from __future__ import annotations
import asyncio
@@ -27,13 +26,8 @@ def _clear_proxy_env(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr("nanobot.security.network.getproxies", getproxies_environment)
# ---------------------------------------------------------------------------
# _probe_http_url unit tests
# ---------------------------------------------------------------------------
@pytest.mark.asyncio
async def test_probe_returns_true_for_open_port(tmp_path):
"""Start a trivial TCP server, probe should return True."""
async def _close_connection(_reader, writer):
writer.close()
await writer.wait_closed()
@@ -60,7 +54,6 @@ async def test_probe_returns_true_for_open_port(tmp_path):
async def test_probe_returns_false_when_validated_target_refuses_connection(
monkeypatch: pytest.MonkeyPatch, url: str, expected_port: int,
):
"""Connection refusal on a validated address must fail on the selected port."""
attempts: list[tuple[str, int]] = []
monkeypatch.setattr(
@@ -141,17 +134,12 @@ async def test_probe_tries_next_validated_ip_when_first_is_unreachable(monkeypat
]
# ---------------------------------------------------------------------------
# connect_mcp_servers skips unreachable HTTP servers
# ---------------------------------------------------------------------------
def _make_http_cfg(url: str, transport: str = "streamableHttp"):
return MCPServerConfig(type=transport, url=url)
@pytest.mark.asyncio
async def test_connect_skips_unreachable_streamable_http():
"""Unreachable streamableHttp server should be skipped with a warning, no crash."""
async def _unreachable(_url: str, *, proxy: str | None = None) -> bool:
return False
@@ -165,7 +153,6 @@ async def test_connect_skips_unreachable_streamable_http():
@pytest.mark.asyncio
async def test_connect_skips_unreachable_sse():
"""Unreachable SSE server should be skipped with a warning, no crash."""
async def _unreachable(_url: str, *, proxy: str | None = None) -> bool:
return False
@@ -181,7 +168,6 @@ async def test_connect_skips_unreachable_sse():
async def test_connect_isolates_streamable_http_status_failure(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""A reachable endpoint returning HTTP 530 must not poison the event loop."""
async def _reachable(_url: str, *, proxy: str | None = None) -> bool:
return True
@@ -231,7 +217,6 @@ async def test_connect_isolates_streamable_http_status_failure(
@pytest.mark.asyncio
async def test_probe_not_called_for_stdio():
"""stdio transport should not be probed — it spawns a local process."""
called = False
original_probe = _probe_http_url