Skip to content

Commit e287e59

Browse files
committed
fix: clear ruff F811/F841 findings across frontends and helpers
Resolve all F811 (redefined-while-unused) and F841 (unused-local) issues reported by ruff so the lint baseline is cleaner: - frontends/tui_v3.py: drop a duplicate `from dataclasses import dataclass` line that was shadowed by the very next import; remove the dead `from prompt_toolkit.keys import Keys` block in _ptk_keypress_to_bytes — the symbol was never referenced in the function body, only `getattr(kp, 'key', None)` is used. - frontends/fsapp.py: handle_message unpacks data.event but never reads the event object — rename to `_event` to flag intent. - frontends/genericagent_acp_bridge.py: write_message computed `method` but only logged the payload — embed method in the ACP-BRIDGE log line so the local is used and debugging is easier. - frontends/qtapp.py: drop unused `as e` from an exception handler that already prints via traceback.print_exc(). - frontends/tuiapp.py: drop the unused `args` assignment in main(); parse_args still validates argv and surfaces errors. - memory/autonomous_operation_sop/helper.py: remove an unused `errors` list in complete_task. Verification: - `python3 -m py_compile` on all six files passes. - `ruff check <files> --select F811,F841` reports `All checks passed!`. - No behavioural change; the only logic tweak is the ACP-BRIDGE log gaining a `[method]` prefix.
1 parent 26257a1 commit e287e59

6 files changed

Lines changed: 4 additions & 12 deletions

File tree

frontends/fsapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ def _run_async(coro):
809809

810810

811811
def handle_message(data):
812-
event, message, sender = data.event, data.event.message, data.event.sender
812+
_event, message, sender = data.event, data.event.message, data.event.sender
813813
message_id = getattr(message, "message_id", "") or ""
814814
if not _claim_message_once(message_id):
815815
print(f"忽略重复飞书消息: {message_id}")

frontends/genericagent_acp_bridge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def write_message(self, msg: Dict[str, Any]) -> None:
147147
payload = compact_json(msg)
148148
raw = (payload + "\n").encode("utf-8")
149149
method = msg.get("method", msg.get("id", "?"))
150-
eprint(f"[ACP-BRIDGE] >>> {payload[:500]}")
150+
eprint(f"[ACP-BRIDGE] >>> [{method}] {payload[:500]}")
151151
try:
152152
with self._write_lock:
153153
self._json_out.write(raw)

frontends/qtapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ def _export_as_md(self):
833833
try:
834834
with open(file_path, "w", encoding="utf-8") as f:
835835
f.write(self._text)
836-
except Exception as e:
836+
except Exception:
837837
import traceback
838838
traceback.print_exc()
839839

frontends/tui_v3.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
sys.path.insert(0, _p)
2323

2424
from agentmain import GeneraticAgent
25-
from dataclasses import dataclass
2625
from dataclasses import dataclass, field
2726
from functools import lru_cache
2827
from io import StringIO
@@ -821,11 +820,6 @@ def _ptk_keypress_to_bytes(kp) -> bytes:
821820
ConPTY, mintty/msys pty) into symbolic Keys. Keep the editor core small by
822821
translating those symbols back to the bytes already handled by _feed/_keys.
823822
"""
824-
try:
825-
from prompt_toolkit.keys import Keys
826-
except Exception:
827-
Keys = None # type: ignore[assignment]
828-
829823
key = getattr(kp, 'key', None)
830824
data = getattr(kp, 'data', '') or ''
831825
mods = {str(m).lower().replace('_', '-') for m in (getattr(kp, 'modifiers', None) or ())}

frontends/tuiapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ def build_arg_parser() -> argparse.ArgumentParser:
721721

722722

723723
def main(argv: Optional[list[str]] = None) -> int:
724-
args = build_arg_parser().parse_args(argv)
724+
build_arg_parser().parse_args(argv)
725725
app = GenericAgentTUI()
726726
app.run()
727727
return 0

memory/autonomous_operation_sop/helper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ def complete_task(taskname: str, historyline: str, report_path: str) -> str:
7070
Returns:
7171
成功消息 + 改TODO指令,或错误消息
7272
"""
73-
errors = []
74-
7573
# ── 校验 ──
7674
if "\n" in historyline.strip():
7775
return "[ERROR] historyline 必须是单行,不能包含换行符"

0 commit comments

Comments
 (0)