fix: repair Notes folder desired keys#211
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Pylint (4.0.5)pyicloud/services/notes/service.pyThanks 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)
pyicloud/services/notes/service.py (1)
280-285: Useget_value()directly forHasSubfolderextraction.Line 280-Line 284 can be simplified without changing behaviour;
get_value()already returnsNonewhen the field is missing, which preserves your tri-state handling.♻️ Proposed refactor
- has_sub_value = getattr( - rec.fields.get_field(_HAS_SUBFOLDER_FIELD) or (), - "value", - None, - ) + has_sub_value = rec.fields.get_value(_HAS_SUBFOLDER_FIELD) has_sub = None if has_sub_value is None else bool(has_sub_value)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pyicloud/services/notes/service.py` around lines 280 - 285, Replace the getattr-based extraction with a direct call to the fields helper: call rec.fields.get_value(_HAS_SUBFOLDER_FIELD) to get the raw value (it already returns None if the field is missing) and then set has_sub = None if that returned value is None else bool(value); this removes the getattr(...) "value" lookup and keeps the tri-state semantics for has_sub.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pyicloud/services/notes/service.py`:
- Around line 280-285: Replace the getattr-based extraction with a direct call
to the fields helper: call rec.fields.get_value(_HAS_SUBFOLDER_FIELD) to get the
raw value (it already returns None if the field is missing) and then set has_sub
= None if that returned value is None else bool(value); this removes the
getattr(...) "value" lookup and keeps the tri-state semantics for has_sub.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6be23549-661f-41e5-9cc2-ecccfd9b4425
📒 Files selected for processing (2)
pyicloud/services/notes/service.pytests/test_notes.py
|
LGTM: Thanks for your update. |
Summary
This fixes a Notes service bug in
NotesService.folders().folders()referencedNotesDesiredKey.TITLE_MODIFICATION_DATEandNotesDesiredKey.HAS_SUBFOLDER, but those enum members do not exist. That caused folder listing to raiseAttributeErrorbefore the query could complete.This change fixes the crash by:
NotesService.folders()HasSubfolderfield directlyImpact
Validation
UV_CACHE_DIR=/tmp/uv-cache PATH=$HOME/.local/bin:$PATH UV_NO_EDITABLE=1 uv run --no-sync ruff check pyicloud/services/notes/service.py tests/test_notes.pyUV_CACHE_DIR=/tmp/uv-cache PATH=$HOME/.local/bin:$PATH UV_NO_EDITABLE=1 uv run --no-sync python -m pytest tests/test_notes.py -qnotes foldersstopped crashing when this fix was applied onto the CLI branch