feat: surface quotedFileContent (anchor text) in comment reading - #489
Conversation
When reading comments via read_document_comments / read_spreadsheet_comments / read_presentation_comments, the Drive API's quotedFileContent.value field is now requested and displayed as "Quoted text:" in the output. This shows which specific text in the document each comment is anchored to. Comments without anchor text (document-level comments) omit the line. Relates to taylorwilsdon#210 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe changes enhance comment handling in Google Docs by extracting and displaying quoted text from comments. The read/list API now includes the quotedFileContent field, extracts its value as quoted_text, and conditionally appends "Quoted text: ..." to comment output. Comprehensive async tests validate quoted text inclusion, empty comment handling, and reply scenarios. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/core/test_comments.py (1)
3-10: Consider avoiding runtime sys.path mutation in tests.
If possible, prefer configuring the test runner’s Python path (e.g., viapyproject.toml/pytest.ini) or installing the package in editable mode to keep imports clean.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/core/test_comments.py` around lines 3 - 10, Remove the runtime sys.path mutation in the test (the sys.path.insert(...) line) and instead import the module via the package import path used in the project (so the test imports core.comments._read_comments_impl directly without modifying sys.path) or configure the test runner to recognize the package (e.g., via pytest.ini/pyproject.toml or running in editable install) so the test uses the normal package import resolution rather than mutating sys.path at runtime.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/core/test_comments.py`:
- Around line 3-10: Remove the runtime sys.path mutation in the test (the
sys.path.insert(...) line) and instead import the module via the package import
path used in the project (so the test imports core.comments._read_comments_impl
directly without modifying sys.path) or configure the test runner to recognize
the package (e.g., via pytest.ini/pyproject.toml or running in editable install)
so the test uses the normal package import resolution rather than mutating
sys.path at runtime.
|
Another excellent one, thanks! |
Summary
quotedFileContentto the Drive API fields requested when reading document/spreadsheet/presentation commentsCloses #210
Changes
core/comments.py: AddedquotedFileContentto thefieldsparameter in the Drive API call, and added output formatting for the quoted texttests/core/test_comments.py: 3 new async tests verifying quoted text is surfaced, empty quoted content is handled, and replies are included correctlytests/core/__init__.py: New init file for test packageTest plan
pytest tests/core/test_comments.py)🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Tests