Refactor _list_pools.py so all methods that handle D-Bus properties are grouped in Default parent class#1270
Conversation
fe9d3e4 to
906f313
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThe PR refactors alert computation logic in the pool listing functionality by renaming Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip You can get early access to new features in CodeRabbit.Enable the |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/stratis_cli/_actions/_list_pool.py (1)
313-322:⚠️ Potential issue | 🟡 MinorUpdate stale docstring type for
alertsparameter.Line 321 still documents
DefaultAlerts, but the signature now takesDeviceSizeChangedAlerts.✏️ Suggested docstring fix
- :param DefaultAlerts alerts: pool alerts + :param DeviceSizeChangedAlerts alerts: pool alerts🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/stratis_cli/_actions/_list_pool.py` around lines 313 - 322, The docstring for the method with signature (self, pool_object_path: str, mopool: Any, alerts: DeviceSizeChangedAlerts) incorrectly documents the alerts parameter as DefaultAlerts; update the docstring to reference DeviceSizeChangedAlerts (or the correct type alias/class) for the alerts parameter and adjust any param description text to match the new type name so the signature and docstring are consistent.
🧹 Nitpick comments (1)
src/stratis_cli/_actions/_list_pool.py (1)
328-331: Consider centralizing combined alert formatting logic.Both detail and table paths manually combine alert lists. A tiny helper for combining/sorting would reduce drift risk between views.
♻️ Optional refactor sketch
+def _combined_alerts( + pool_object_path: str, mopool: Any, alerts: DeviceSizeChangedAlerts +) -> list[Any]: + return _alert_codes(mopool) + alerts.alert_codes(pool_object_path) + @@ - alert_summary = sorted( - f"{code}: {code.summarize()}" - for code in alerts.alert_codes(pool_object_path) + _alert_codes(mopool) - ) + alert_summary = sorted( + f"{code}: {code.summarize()}" + for code in _combined_alerts(pool_object_path, mopool, alerts) + ) @@ - for code in ( - _alert_codes(mopool) + alerts.alert_codes(pool_object_path) - ) + for code in _combined_alerts(pool_object_path, mopool, alerts)Also applies to: 529-531
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/stratis_cli/_actions/_list_pool.py` around lines 328 - 331, The two places building alert_summary duplicate logic by combining alerts.alert_codes(pool_object_path) and _alert_codes(mopool) and sorting/formatting them; extract that into a small helper (e.g., a function named format_combined_alerts or get_sorted_alert_summaries) and replace the inline generator expressions in both locations (the alert_summary assignment at the current block and the one around lines 529-531) to call this helper so the combination, formatting (f"{code}: {code.summarize()}"), and sorting are centralized and consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/stratis_cli/_actions/_list_pool.py`:
- Around line 313-322: The docstring for the method with signature (self,
pool_object_path: str, mopool: Any, alerts: DeviceSizeChangedAlerts) incorrectly
documents the alerts parameter as DefaultAlerts; update the docstring to
reference DeviceSizeChangedAlerts (or the correct type alias/class) for the
alerts parameter and adjust any param description text to match the new type
name so the signature and docstring are consistent.
---
Nitpick comments:
In `@src/stratis_cli/_actions/_list_pool.py`:
- Around line 328-331: The two places building alert_summary duplicate logic by
combining alerts.alert_codes(pool_object_path) and _alert_codes(mopool) and
sorting/formatting them; extract that into a small helper (e.g., a function
named format_combined_alerts or get_sorted_alert_summaries) and replace the
inline generator expressions in both locations (the alert_summary assignment at
the current block and the one around lines 529-531) to call this helper so the
combination, formatting (f"{code}: {code.summarize()}"), and sorting are
centralized and consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 36a6a080-ffcc-40fd-acf4-381bc32b25ab
📒 Files selected for processing (1)
src/stratis_cli/_actions/_list_pool.py
906f313 to
3fc3504
Compare
The alerts regarding device size changes require searching the GetManagedObjects result, the other alerts only require looking at the properties of one pool. Calculating them together is awkward. Signed-off-by: mulhern <amulhern@redhat.com>
The are already sorted in table view, so might as well be consistent. Signed-off-by: mulhern <amulhern@redhat.com>
3fc3504 to
c895f03
Compare
To better localize D-Bus property using methods. Signed-off-by: mulhern <amulhern@redhat.com>
c895f03 to
5032781
Compare
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
No description provided.