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:
1 parent
cb3ba45317
commit
a4d2430140
922 files changed
+406
-7738
No files matched your search
@@ -261,7 +261,6 @@ def _build_runnable_dream(
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dream_advances_cursor_when_diff_nonempty(tmp_path) -> None:
|
||||
"""A completed run with a real file delta advances the cursor."""
|
||||
ctx, store = _build_runnable_dream(tmp_path, initialized=True, content_diff="SOUL.md: +1 -0")
|
||||
await _run_dream_command(ctx)
|
||||
assert store._last_dream_cursor == 42
|
||||
@@ -269,7 +268,6 @@ async def test_dream_advances_cursor_when_diff_nonempty(tmp_path) -> None:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dream_advances_cursor_on_completed_noop(tmp_path) -> None:
|
||||
"""A completed no-op has processed the batch and must not repeat it."""
|
||||
ctx, store = _build_runnable_dream(tmp_path, initialized=True, content_diff="")
|
||||
await _run_dream_command(ctx)
|
||||
assert store._last_dream_cursor == 42
|
||||
@@ -278,7 +276,6 @@ async def test_dream_advances_cursor_on_completed_noop(tmp_path) -> None:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dream_keeps_cursor_when_incomplete_with_diff(tmp_path) -> None:
|
||||
"""An incomplete run remains retryable even if it left a partial edit."""
|
||||
ctx, store = _build_runnable_dream(
|
||||
tmp_path,
|
||||
initialized=True,
|
||||
@@ -292,7 +289,6 @@ async def test_dream_keeps_cursor_when_incomplete_with_diff(tmp_path) -> None:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dream_advances_cursor_when_completed_after_tool_error(tmp_path) -> None:
|
||||
"""A handled tool failure does not invalidate a normally completed run."""
|
||||
ctx, store = _build_runnable_dream(
|
||||
tmp_path,
|
||||
initialized=True,
|
||||
@@ -306,7 +302,6 @@ async def test_dream_advances_cursor_when_completed_after_tool_error(tmp_path) -
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dream_noop_batch_unlocks_following_history(tmp_path) -> None:
|
||||
"""A no-op first batch must not starve later history entries."""
|
||||
workspace = tmp_path / "workspace"
|
||||
workspace.mkdir()
|
||||
store = MemoryStore(workspace)
|
||||
@@ -354,12 +349,11 @@ async def test_dream_noop_batch_unlocks_following_history(tmp_path) -> None:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dream_non_git_falls_back_to_completion_gate(tmp_path) -> None:
|
||||
"""Non-git workspaces use the same normal-completion gate."""
|
||||
ctx, store = _build_runnable_dream(
|
||||
tmp_path, initialized=False, content_diff="", stop_reason="completed",
|
||||
)
|
||||
await _run_dream_command(ctx)
|
||||
assert store._last_dream_cursor == 42 # advanced via completion fallback
|
||||
assert store._last_dream_cursor == 42
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"""Manual context compaction command behavior."""
|
||||
|
||||
import asyncio
|
||||
import sqlite3
|
||||
import threading
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"""Tests for CommandRouter.is_dispatchable_command and mid-turn command interception."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from inspect import Parameter, signature
|
||||
@@ -22,7 +20,6 @@ def test_command_context_requires_loop_as_keyword_dependency() -> None:
|
||||
|
||||
|
||||
class TestIsDispatchableCommand:
|
||||
"""Unit tests for the is_dispatchable_command() predicate."""
|
||||
|
||||
@pytest.fixture()
|
||||
def router(self) -> CommandRouter:
|
||||
@@ -52,8 +49,6 @@ class TestIsDispatchableCommand:
|
||||
assert router.is_dispatchable_command("/__shell pwd")
|
||||
|
||||
def test_priority_commands_not_matched(self, router: CommandRouter) -> None:
|
||||
# Priority commands are NOT in the dispatchable tiers — they are
|
||||
# handled by is_priority() separately.
|
||||
assert not router.is_dispatchable_command("/stop")
|
||||
assert not router.is_dispatchable_command("/restart")
|
||||
|
||||
@@ -132,7 +127,6 @@ class TestMidTurnCommandDispatchedDirectly:
|
||||
async def test_new_dispatched_with_session_none(
|
||||
self, router: CommandRouter, fake_loop: MagicMock, fake_msg: MagicMock,
|
||||
) -> None:
|
||||
"""cmd_new works when session=None (mid-turn dispatch path)."""
|
||||
ctx = CommandContext(
|
||||
msg=fake_msg, session=None,
|
||||
key="test:chat1", raw="/new", loop=fake_loop,
|
||||
@@ -161,8 +155,6 @@ class TestMidTurnCommandDispatchedDirectly:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_prefix_command_args_populated(self, router: CommandRouter) -> None:
|
||||
"""Prefix commands have args populated correctly in mid-turn path."""
|
||||
# Use a custom prefix handler to avoid needing full mock setup.
|
||||
custom = CommandRouter()
|
||||
captured_args = []
|
||||
|
||||
@@ -189,7 +181,6 @@ class TestMidTurnCommandDispatchedDirectly:
|
||||
self, router: CommandRouter, fake_loop: MagicMock, fake_msg: MagicMock,
|
||||
content: str,
|
||||
) -> None:
|
||||
"""Regular text returns None from dispatch (not a command)."""
|
||||
ctx = CommandContext(
|
||||
msg=fake_msg, session=None,
|
||||
key="test:chat1", raw=content, loop=fake_loop,
|
||||
@@ -217,7 +208,6 @@ class TestMidTurnCommandDispatchedDirectly:
|
||||
)
|
||||
|
||||
class TestPairingCommandDispatch:
|
||||
"""Verify /pairing works via CommandRouter."""
|
||||
|
||||
@pytest.fixture()
|
||||
def router(self) -> CommandRouter:
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"""Tests for the /skill built-in command."""
|
||||
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
@@ -85,7 +83,6 @@ async def test_skill_command_lists_names_and_descriptions(tmp_path: Path) -> Non
|
||||
assert "Available skills (2):" in out.content
|
||||
assert "**weather** — Get current weather and forecasts" in out.content
|
||||
assert "**cron** — Schedule recurring tasks" in out.content
|
||||
# Must NOT contain file paths
|
||||
assert ".md" not in out.content
|
||||
assert "/skills/" not in out.content
|
||||
|
||||
@@ -120,7 +117,6 @@ async def test_skill_command_fallback_description(tmp_path: Path) -> None:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_skill_command_no_render_as_text(tmp_path: Path) -> None:
|
||||
"""Output is markdown; CLI should render it (not forced as plain text)."""
|
||||
loop = _make_loop(tmp_path)
|
||||
out = await cmd_skill(_ctx(loop))
|
||||
assert out.metadata.get("render_as") != "text"
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"""Test cmd_stop drains pending queue to prevent mid-turn injection deadlock."""
|
||||
|
||||
import asyncio
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
|
||||
@@ -12,7 +10,6 @@ from nanobot.command.router import CommandContext
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cmd_stop_drains_pending_queue():
|
||||
"""cmd_stop should drain pending queue in addition to cancelling active tasks."""
|
||||
mock_loop = MagicMock()
|
||||
mock_loop._cancel_active_tasks = AsyncMock(return_value=1)
|
||||
mock_loop._pending_queues = {}
|
||||
@@ -33,13 +30,12 @@ async def test_cmd_stop_drains_pending_queue():
|
||||
result = await cmd_stop(ctx)
|
||||
|
||||
assert isinstance(result, OutboundMessage)
|
||||
assert "Stopped 3 task(s)" in result.content # 1 cancelled + 2 drained
|
||||
assert "Stopped 3 task(s)" in result.content
|
||||
assert "test-session" not in mock_loop._pending_queues
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cmd_stop_with_empty_pending_queue():
|
||||
"""cmd_stop should work correctly when pending queue is empty."""
|
||||
mock_loop = MagicMock()
|
||||
mock_loop._cancel_active_tasks = AsyncMock(return_value=2)
|
||||
mock_loop._pending_queues = {}
|
||||
@@ -63,7 +59,6 @@ async def test_cmd_stop_with_empty_pending_queue():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cmd_stop_no_pending_queue():
|
||||
"""cmd_stop should work when no pending queue exists."""
|
||||
mock_loop = MagicMock()
|
||||
mock_loop._cancel_active_tasks = AsyncMock(return_value=0)
|
||||
mock_loop._pending_queues = {}
|
||||
|
||||
Reference in new issue
Block a user