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

+1 -3
View File
@@ -1,5 +1,3 @@
"""Reproducible, synthetic JSONL/SQLite storage and ownership comparison."""
from __future__ import annotations
import argparse
@@ -25,7 +23,7 @@ from pathlib import Path
try:
import resource
except ModuleNotFoundError: # Windows
except ModuleNotFoundError:
resource = None # type: ignore[assignment]
@@ -1,4 +1,3 @@
/** Check client imports without loading application or channel modules. */
import { Glob } from "bun";
import { readFileSync, readdirSync } from "node:fs";
import { createRequire } from "node:module";
-2
View File
@@ -1,5 +1,3 @@
"""Require success for selected jobs; never confuse a broken selector with no work."""
from __future__ import annotations
import json
-1
View File
@@ -115,7 +115,6 @@ def main() -> None:
assert request(api + "/v1/models")[0] == 401
print(f"PASS {label}: both default services, authenticated WebUI, API model-setup errors")
# Configure a provider without making external model requests.
saved["providers"]["custom"] = {
"apiKey": "smoke-provider-key", "apiBase": "http://127.0.0.1:9/v1",
}
-1
View File
@@ -258,7 +258,6 @@ function Install-WithPipx {
}
$Environment = Join-Path $ToolDir $Package
if (Test-Path -LiteralPath (Join-Path $Environment "pipx_metadata.json")) {
# Keep this stdlib bootstrap check in sync with install.sh.
$Inspect = @'
import json
import re
-2
View File
@@ -1,5 +1,3 @@
"""Install channel manifest dependencies for repository build and CI jobs."""
from __future__ import annotations
import sys
-2
View File
@@ -1,5 +1,3 @@
"""Bind native acceptance to the exact wheel produced by this workflow run."""
from __future__ import annotations
import hashlib
-2
View File
@@ -1,5 +1,3 @@
"""Opt-in pytest phase timings for CI artifacts (including xdist workers)."""
from __future__ import annotations
import json
-7
View File
@@ -86,7 +86,6 @@ def prepare_preview(root: Path, output: Path, *, source_commit: str, base: str,
if Version(base).release < current.release or _git(root, "tag", "--list", f"v{base}"):
raise ValueError("Preview base must not precede the source or reuse an existing stable tag")
changes = _version_changes(original["pyproject.toml"], original["nanobot/__init__.py"], version)
# A separate clone preserves the source parent without touching the caller's worktree.
_git(root, "clone", "--shared", "--no-checkout", "-c", "core.autocrlf=false", str(root), str(output))
hooks = output / ".git" / "candidate-hooks"
hooks.mkdir()
@@ -156,13 +155,9 @@ def _source_payload(root: Path, source: dict[str, bytes], prefix: str) -> dict[s
"""Bind shipped application files to the clean candidate, not its commit label."""
tracked = set(_git(root, "ls-files", "-z", trim=False).split("\0")) - {""}
build = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8"))["tool"]["hatch"]["build"]
# The sdist ships the tracked nanobot tree. Read its actual exclusions rather
# than maintaining a second list of channel test directories here.
exclusions = [*build.get("exclude", []), *build["targets"]["sdist"].get("exclude", [])]
expected = {name: name for name in tracked if name.startswith("nanobot/")
and not any(fnmatchcase(name, pattern) for pattern in exclusions)}
# The build hook copies tracked docs into the built-in documentation skill.
# Verify both copies: rebuilding the sdist must use the same reviewed bytes.
for name in tracked:
if (name.startswith("docs/") and name.endswith(".md")
and not any(fnmatchcase(name, pattern) for pattern in exclusions)):
@@ -314,8 +309,6 @@ def retain_candidate(root: Path, artifacts: Path, output: Path, *, source_commit
retained.mkdir()
for name in sorted(release_filenames(manifest.version) | {"release-manifest.json"}):
shutil.copyfile(artifacts / name, retained / name)
# Check the actual copies, not a report for the source directory. A future
# publisher must consume these bytes and verify this manifest again.
if ((retained / "release-manifest.json").read_bytes() != recorded
or verify_candidate(root, retained, source_commit=source_commit) != manifest):
raise ValueError("Retained artifacts differ from the reviewed candidate")
+1 -2
View File
@@ -55,7 +55,7 @@ def fetch_pages(endpoint: str, **params: str) -> list[object]:
while True:
query = urlencode({**params, "per_page": PER_PAGE, "page": page})
url = f"https://api.github.com/repos/{REPOSITORY}/{endpoint}?{query}"
with urlopen(Request(url, headers=headers), timeout=30) as response: # noqa: S310
with urlopen(Request(url, headers=headers), timeout=30) as response:
batch = json.load(response)
if not isinstance(batch, list):
raise ValueError("Expected a GitHub API list response")
@@ -68,7 +68,6 @@ def fetch_pages(endpoint: str, **params: str) -> list[object]:
def fetch_contributors(previous_wall: str = "") -> list[Contributor]:
# Shapes follow the GitHub contributors and commits REST response schemas.
entries = cast(list[Contributor], fetch_pages("contributors", anon="1"))
contributors = {
c["login"].lower(): c for c in entries
+2 -13
View File
@@ -192,7 +192,7 @@ def transport():
for name, content in files.items():
if name in info:
item = info[name]
item.filename = name # Retain native executable permissions.
item.filename = name
archive.writestr(item, content)
else:
archive.writestr(name, content)
@@ -253,7 +253,6 @@ def _dock_supported(root: Path) -> bool:
def _desktop_webui(root: Path) -> None:
# The real managed receipt must select automatic detachment, not a test flag.
subprocess.run([sys.executable, "-I", "-m", "nanobot", "webui", "--yes", "--no-open",
"--config", str(root / "account/.nanobot/config.json")], check=True, timeout=60)
@@ -406,7 +405,6 @@ def seed(root: Path) -> None:
"tokenIssueSecret": secrets.token_urlsafe(32), "websocketRequiresToken": True}
save_config(config, config_path)
seed_history(root)
# Keep a real durable result pending without attempting an external send.
with patch("nanobot.channels.outbox.time.time", return_value=time.time() + 3600):
DeliveryOutbox(config_path.parent / "delivery/outbox.sqlite3").record(OutboundMessage(
"whatsapp", "acceptance-offline", "Retain this scheduled result",
@@ -535,8 +533,6 @@ def verify_data(root: Path, expected: str) -> None:
from nanobot.gateway.runtime import GatewayInstance
instance = GatewayInstance.resolve(config_path=root / "account/.nanobot/config.json")
# A historical package without this feature cannot record desktop intent.
# After that first upgrade, exercise the real new launcher, then restart.
if not instance.paths.state_path.with_suffix(".dock").exists():
_desktop_webui(root)
_wait_dock(_dock_socket(root), present=True)
@@ -551,7 +547,6 @@ def verify_data(root: Path, expected: str) -> None:
assert canonical == before["canonical"]
delivery = root / "account/.nanobot/delivery/outbox.sqlite3"
assert canonical_records(delivery, ("deliveries",)) == before["delivery"]
# Display transcripts are not canonical agent context.
assert not any(row[0] == "websocket:display-only" for row in canonical["messages"])
for session_key in ("websocket:mixed-history", "websocket:canonical-only"):
messages = [json.loads(row[2]) for row in canonical["messages"] if row[0] == session_key]
@@ -661,7 +656,7 @@ def run_parallel(args, root: Path, target: Path, version: str, original_hash: st
for worker, selected in enumerate(groups, 1):
lane = root / f"lane-{worker}"
lane.mkdir(mode=0o700)
output = lane / "run" # The child exclusively creates this root.
output = lane / "run"
env = isolated_environment(lane)
# Controller dependencies are shared read-only; do not write
# bytecode into their environment from either lane.
@@ -706,8 +701,6 @@ def run_parallel(args, root: Path, target: Path, version: str, original_hash: st
print(f"FAIL lane-{worker}: controller exited with status {status}", flush=True)
finally:
cleanup_failed = False
# Finish or terminate every owned controller before importing JSON.
# An ordinary failing lane does not interrupt another lane's cleanup.
for _, selected, output, process, owner in jobs:
try:
stop_controller(process, owner)
@@ -747,8 +740,6 @@ def run_serial(args, root: Path, target: Path, version: str, original_hash: str,
if args.baseline_wheel:
baseline_version = str(parse_wheel_filename(baseline_source.name)[1])
else:
# A version-only fixture, not a claim about a published predecessor.
# Minor/major releases have a zero patch component (e.g. 0.4.0).
base = list(Version(version).release)
for index in reversed(range(len(base))):
if base[index]:
@@ -856,8 +847,6 @@ def run_serial(args, root: Path, target: Path, version: str, original_hash: str,
if config_file.exists():
config = read(config_file)
_wait_for_closed_listeners((config["gateway"]["port"], config["channels"]["websocket"]["port"]))
# No journey result exists on failure; successful journeys
# also retain the existing native Dock shutdown assertion.
if results and results[-1]["scenario"] == scenario:
results[-1]["gateway_process_stopped"] = True
dock_address = results[-1].get("dock_socket")