kyegomez/swarms
[Cleanup] Four overlapping 'format any data structure as a string' helpers (~80 lines) — keep one
Offen
#1.851 geöffnet am 09.08.2026
good first issuetech-debtutils
Repository-Metriken
- Stars
- (7.040 Sterne)
- PR-Merge-Metriken
- (Durchschn. Merge 3T 5h) (17 gemergte PRs in 30 T)
Beschreibung
What
Four separate helpers recursively walk dict/list/tuple structures and produce an indented key: value string. They differ only in bracket and quote cosmetics.
| Function | Location | Lines | Callers |
|---|---|---|---|
format_data_structure |
swarms/utils/index.py:46-155 |
110 | agent.py ×7 |
format_dict_to_string |
swarms/utils/index.py:13-43 |
31 | 0 (only the __init__ re-export) |
any_to_str |
swarms/utils/any_to_str.py:4-63 |
60 | consistency_agent, swarm_rearrange, conversation, agent_rearrange, model_router |
function_to_str / functions_to_str |
swarms/tools/func_to_str.py |
42 | reachable only via the dead base_tool methods |
Analysis
format_dict_to_stringis strictly redundant —format_data_structurealready handles every case it does, and it has zero callers. Pure deletion.any_to_strandformat_data_structuregenuinely overlap — same traversal, different output cosmetics. They can be one function with astyle=parameter.func_to_str.pydies automatically with thebase_tool.pydead-method cleanup (see that issue) — nothing else reaches it.
Why it matters
Two of these are used by different parts of the same codebase to render the same kinds of objects, so the same dict can be printed two different ways depending on which call path reached it. Consolidating gives one predictable output format.
Scope
- Delete
format_dict_to_string(31 lines, 0 callers) and its__init__re-export - Fold
any_to_strintoformat_data_structurewith astyle=flag; update the 5 call sites, keepingany_to_stras a thin alias if churn is a concern - Confirm
func_to_str.pyis removed alongside thebase_toolcleanup - Add a table test pinning the exact output for a nested dict/list/tuple fixture in each style, so the consolidation is provably behavior-preserving
Context
From the code-waste audit (experimental/CODE_WASTE_AUDIT.md, section 3.5).
🤖 Generated with Claude Code