[Cleanup] formatter.py — 3 dead print methods (~142 lines) and 8 collapsible log-strip regexes
#1 838 ouverte le 9 août 2026
Métriques du dépôt
- Stars
- (7 040 étoiles)
- Métriques de merge PR
- (Merge moyen 3j 5h) (17 PRs mergées en 30 j)
Description
What
swarms/utils/formatter.py (987 lines) carries three public methods with zero callers and a hardcoded regex block that collapses to two patterns.
1. Dead print methods (142 lines)
Verified 0 hits across swarms/, tests/, and examples/:
| Method | Lines | Span |
|---|---|---|
print_progress |
28 | 487-514 |
print_panel_token_by_token |
35 | 515-549 |
print_plan_tree |
79 | 750-828 |
2. print_markdown is a redundant alias (21 lines)
print_markdown (:446-466) is used only by tests/utils/test_formatter.py:120 — no production caller. Its body is self.markdown_handler.render_markdown_output(content, title, border_style), which is identical to the print_panel markdown branch at :434-437. Either delete it and update the test, or keep it as a documented one-line alias.
3. _clean_output — 8 near-identical regexes (~30 lines)
MarkdownOutputHandler._clean_output (:39-113) hardcodes eight re.sub log-stripping patterns at :44-79 that differ only by the log level name (INFO, DEBUG, WARNING, ERROR, …).
These collapse to two regexes using an alternation group, e.g. (?:INFO|DEBUG|WARNING|ERROR|SUCCESS|TRACE|CRITICAL). Besides being ~30 lines shorter, it removes the failure mode where a new log level is added and silently isn't stripped.
Broader note
Between this file and agent.py, the codebase has four bespoke panel printers sharing a ~12-line skeleton (_visualize_function_call, _visualize_handoff_call, pretty_print, print_dashboard in agent.py). That consolidation is tracked in the "smaller clones" issue.
Scope
- Delete
print_progress,print_panel_token_by_token,print_plan_tree - Resolve
print_markdown(delete + update test, or document as an alias) - Collapse the 8 log-strip regexes into 2 with an alternation group
- Add a
_clean_outputtest covering every log level, so the alternation is verifiably complete
Context
From the code-waste audit (experimental/CODE_WASTE_AUDIT.md, section 1.10).
🤖 Generated with Claude Code