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
@@ -1,5 +1,3 @@
|
||||
"""Pairing module for DM sender approval."""
|
||||
|
||||
from nanobot.pairing.store import (
|
||||
approve_code,
|
||||
clear_channel,
|
||||
@@ -16,7 +14,6 @@ from nanobot.pairing.store import (
|
||||
revoke_channel,
|
||||
)
|
||||
|
||||
# Metadata keys used by channels and commands to tag pairing-related messages.
|
||||
PAIRING_CODE_META_KEY = "_pairing_code"
|
||||
PAIRING_COMMAND_META_KEY = "_pairing_command"
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"""Transport-independent pairing snapshot invalidation."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from nanobot.events import AgentEvent
|
||||
|
||||
@@ -26,8 +26,8 @@ from nanobot.utils.helpers import _write_text_atomic # pyright: ignore[reportPr
|
||||
# sub-millisecond operations) the brief block is acceptable.
|
||||
_LOCK = threading.Lock()
|
||||
_ALPHABET = string.ascii_uppercase + string.digits
|
||||
_CODE_LENGTH = 8 # e.g. ABCD-EFGH
|
||||
_TTL_DEFAULT_S = 600 # 10 minutes
|
||||
_CODE_LENGTH = 8
|
||||
_TTL_DEFAULT_S = 600
|
||||
|
||||
|
||||
def _store_path() -> Path:
|
||||
@@ -63,7 +63,6 @@ def _load() -> dict[str, Any]:
|
||||
pending = cast(dict[str, Any], raw_pending) if isinstance(raw_pending, dict) else {}
|
||||
data["pending"] = pending
|
||||
|
||||
# Convert approved lists to str sets for O(1) lookup.
|
||||
for channel, users in approved.items():
|
||||
if not isinstance(users, list):
|
||||
users = []
|
||||
@@ -74,7 +73,6 @@ def _load() -> dict[str, Any]:
|
||||
def _save(data: dict[str, Any]) -> None:
|
||||
path = _store_path()
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
# Convert sets back to lists for JSON serialization
|
||||
raw_approved = data.get("approved")
|
||||
approved = cast(dict[str, Any], raw_approved) if isinstance(raw_approved, dict) else {}
|
||||
raw_pending = data.get("pending")
|
||||
@@ -97,7 +95,6 @@ def _notify_changed(on_change: Callable[[], object] | None) -> None:
|
||||
|
||||
|
||||
def _gc_pending(data: dict[str, Any]) -> None:
|
||||
"""Remove expired pending entries in-place."""
|
||||
now = time.time()
|
||||
pending: dict[str, Any] = data.get("pending") or {}
|
||||
expired: list[str] = []
|
||||
|
||||
Reference in new issue
Block a user