fix(etree): return list instead of calling reply per line#25
Conversation
|
Warning Review limit reached
More reviews will be available in 54 minutes. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesEtymology Tree Command Refactor
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
plugins/etymology.py (1)
23-26: Approveetymology_treeoutput shaping (empty handling + return-to-chat contract)
str(ety.tree(...))is already newline-trimmed, andEtyTree.__str__returns""when treelib can’t render the tree (sotree.strip()correctly maps toNone;split("\n")won’t produce a trailing blank line).- CloudBot’s
@hook.post_hook(plugins/core/core_hooks.py:do_reply) sends command return values to chat (list/tuple->reply(*result)), so returninglist[str]/None(rather than callingreply()inside the handler) matches the framework contract.No repo tests reference
etymology_tree/etree; consider adding coverage for both the empty/unknown case and a non-empty tree case.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@plugins/etymology.py` around lines 23 - 26, Add unit tests for etymology_tree to cover both the empty/unknown case and a non-empty tree case: mock or instantiate EtyTree so EtyTree.__str__ returns "" to assert etymology_tree(...) yields None, and a rendered multiline string to assert etymology_tree(...) returns a list of lines (no trailing empty line); ensure the tests exercise ety.tree via the etymology_tree function and confirm compatibility with the framework behavior in do_reply (i.e., function returns list[str] or None rather than calling reply()).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@plugins/etymology.py`:
- Around line 23-26: Add unit tests for etymology_tree to cover both the
empty/unknown case and a non-empty tree case: mock or instantiate EtyTree so
EtyTree.__str__ returns "" to assert etymology_tree(...) yields None, and a
rendered multiline string to assert etymology_tree(...) returns a list of lines
(no trailing empty line); ensure the tests exercise ety.tree via the
etymology_tree function and confirm compatibility with the framework behavior in
do_reply (i.e., function returns list[str] or None rather than calling reply()).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fb07b790-95ac-48eb-ad62-d51a15dbae9f
📒 Files selected for processing (1)
plugins/etymology.py
Problem:
.etreewas callingreply()for every line of the etymology tree, spamming the channel with individual messages.Fix: Changed
etymology_treeto return alist[str]instead. CloudBot's hook system handles list returns by sending each element as a separate message — same net effect for output, but cleaner internally (no directreplycalls, proper return-value pattern matching the rest of the plugin).Changes:
nickandreplyparams (unused now)Noneif tree is empty (no output)