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

-2
View File
@@ -1,5 +1,3 @@
"""Session management module."""
from nanobot.session.manager import Session, SessionManager
__all__ = ["SessionManager", "Session"]
-2
View File
@@ -1,5 +1,3 @@
"""Shared contracts for session-bound automation sources."""
from __future__ import annotations
from collections.abc import Callable, Mapping
-2
View File
@@ -1,5 +1,3 @@
"""Shared handling for session-bound automation turns."""
from __future__ import annotations
from collections.abc import Mapping
-2
View File
@@ -1,5 +1,3 @@
"""Durable display facts, separate from provider/model messages and transports."""
from __future__ import annotations
import json
-2
View File
@@ -1,5 +1,3 @@
"""Read searchable conversation text from persisted session records."""
from __future__ import annotations
from collections.abc import Mapping
-2
View File
@@ -1,5 +1,3 @@
"""Visibility helpers for persisted session history messages."""
from __future__ import annotations
from collections.abc import Mapping
-2
View File
@@ -1,5 +1,3 @@
"""Shared session key constants and helpers."""
from __future__ import annotations
from collections.abc import Mapping, MutableMapping
-2
View File
@@ -1,5 +1,3 @@
"""Stable workspace identity and private session storage locations."""
from __future__ import annotations
import errno
-4
View File
@@ -1,5 +1,3 @@
"""Session management for conversation history."""
from __future__ import annotations
import asyncio
@@ -73,7 +71,6 @@ def _sanitize_assistant_replay_text(content: str) -> str:
def _text_preview(content: object) -> str:
"""Return compact display text for session lists."""
if isinstance(content, str):
text = content
elif isinstance(content, list):
@@ -247,7 +244,6 @@ class Session:
sliced = sliced[start:]
break
# Drop orphan tool results at the front.
start = find_legal_message_start(sliced)
if start:
sliced = sliced[start:]
-2
View File
@@ -1,5 +1,3 @@
"""Session-scoped model preset metadata."""
from __future__ import annotations
from collections.abc import Mapping
-3
View File
@@ -1,5 +1,3 @@
"""Durable session checkpoints and pending-turn recovery state."""
from __future__ import annotations
import asyncio
@@ -186,7 +184,6 @@ def _checkpoint_tool_call_ids(
*,
result_rows: bool = False,
) -> list[str] | None:
"""Validate checkpoint tool rows and return their stable IDs."""
if not isinstance(value, list):
return None
ids: list[str] = []
-4
View File
@@ -1,5 +1,3 @@
"""Short, pronounceable public handles for persisted sessions."""
from __future__ import annotations
import hashlib
@@ -103,7 +101,6 @@ def _tier_size(syllable_count: int) -> int:
def _name_parts_at(syllable_count: int, index: int) -> tuple[str, ...]:
"""Decode one permutation index without materializing the candidate space."""
size = _tier_size(syllable_count)
if not 0 <= index < size:
raise ValueError("session handle candidate index is invalid")
@@ -118,7 +115,6 @@ def _name_parts_at(syllable_count: int, index: int) -> tuple[str, ...]:
def _candidate_indexes(syllable_count: int):
"""Visit every candidate once in a stable, non-alphabetical order."""
size = _tier_size(syllable_count)
seed = hashlib.sha256(f"nanobot-handle-v1:{syllable_count}".encode()).digest()
start = int.from_bytes(seed[:8], "big") % size
-2
View File
@@ -1,5 +1,3 @@
"""Metadata carried by user input sent between persisted sessions."""
from __future__ import annotations
import re
-3
View File
@@ -1,5 +1,3 @@
"""Transactional SQLite storage for private conversation state."""
from __future__ import annotations
import json
@@ -528,7 +526,6 @@ class SqliteSessionStore:
ORDER BY sessions.updated_at DESC
)
""").fetchone()[0]
# The SQL projection constructs this list and its dictionary fields.
rows = cast(list[dict[str, Any]], json.loads(encoded))
for row in rows:
row["path"] = str(self.path)
-3
View File
@@ -1,5 +1,3 @@
"""Ordered session operations with detached reads and durable acknowledgements."""
from __future__ import annotations
import asyncio
@@ -139,7 +137,6 @@ class SessionState:
operation_name: str,
barrier: bool = True,
) -> _T:
"""Admit bounded work with FIFO key affinity or a global barrier."""
self._bind_loop()
name = operation_name
if key is None:
-2
View File
@@ -1,5 +1,3 @@
"""Helpers for validated session-summary metadata."""
from __future__ import annotations
from collections.abc import Mapping
-2
View File
@@ -232,7 +232,6 @@ def _save_skip_for_turn(
initial_message_count: int,
input_persisted_early: bool,
) -> int:
"""Return the persisted-message append boundary for this turn."""
if message_metadata and message_metadata.get(SKIP_USER_PERSIST_META) is True:
return initial_message_count
if internal_continuation_inbound(message_metadata):
@@ -306,7 +305,6 @@ def _strip_terminal_assistant(
messages: list[dict[str, Any]],
final_content: str | None,
) -> list[dict[str, Any]]:
"""Drop the synthetic max-iteration assistant message before saving history."""
if not messages:
return messages
last = messages[-1]
-2
View File
@@ -1,5 +1,3 @@
"""Session kinds declare their public identity and history access."""
from __future__ import annotations
from collections.abc import Mapping
-4
View File
@@ -1,5 +1,3 @@
"""Session turn helpers for WebUI-capable WebSocket sessions."""
from __future__ import annotations
import re
@@ -101,7 +99,6 @@ def _session_message_public_metadata(
def _validated_llm_runtime(value: object) -> LLMRuntime | None:
"""Keep runtime-event consumers defensive if an external publisher violates the contract."""
return value if isinstance(value, LLMRuntime) else None
@@ -172,7 +169,6 @@ def _title_inputs(session: Session) -> tuple[str, str]:
def _latest_title_inputs(session: Session) -> tuple[str, str]:
"""Latest user/assistant texts, for turns executed on a shared session."""
user_text = ""
assistant_text = ""
for message in reversed(session.messages):