Repository navigation
feat: error contract completion — DocumentClosedError, error fields, find_text parity (ISSUES.md #42) - #59
Conversation
…find_text parity (ISSUES.md #42) - New DocumentClosedError(DocxEditError) with path field, raised by the _ensure_open() choke point instead of a bare ValueError; message says how to recover (reopen with Document.open). Breaking for callers catching ValueError around post-close calls (pre-1.0, per task spec). - Structured keyword-only fields, messages unchanged: DocumentNotFoundError.path, WorkspaceSyncError.workspace_path/ .source_path, CommentError.comment_id, RevisionError.revision_id/ .group_id. Populated at every raise site that has the value in scope. - find_text(text, occurrence=0, paragraph=None): paragraph scoping parity with find_all (occurrence counts within the paragraph when scoped), shared non-empty-text guard, negative occurrence returns None instead of wrapping around. - Docs: SKILL.md error table rows + scoped-search prose; docs/api.md find_text signature, close() note, exception entries.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthrough
ChangesSearch and structured error contracts
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Document
participant RevisionManager
participant ParagraphSearch
Document->>RevisionManager: find_text(text, occurrence, paragraph)
RevisionManager->>ParagraphSearch: find_all(text, paragraph)
ParagraphSearch-->>RevisionManager: scoped matches
RevisionManager-->>Document: SearchResult or None
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #59 +/- ##
=====================================
Coverage 95.7% 95.7%
=====================================
Files 11 11
Lines 3721 3740 +19
Branches 742 744 +2
=====================================
+ Hits 3562 3581 +19
Misses 73 73
Partials 86 86 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…rity-format accept/reject, session perf (ISSUES.md #59) (#70) * docs: round-4 dogfood notes — PEP-668 venv, group-reopen caveat, majority-format accept/reject, session perf (ISSUES.md #59) Fold four documentation-only findings from round-4 dogfood testing into the SKILL and mirror docs, each re-verified by execution: - Installation: PEP-668 externally-managed refusal → venv recipe (ensurepip / python3-venv remedy, uv + pipx alternatives) in SKILL.md and docs/index.md. - Revision groups: caveat that same-paragraph batch_edit/batch_rewrite ops share one changeset date and reconstruct as a single inferred group after reopen; use separate calls to keep them independently resolvable. - Replace formatting: accept leaves the replacement uniformly in the majority rPr while each deletion run keeps its own, so a reject restores the mix (SKILL.md + docs/api.md). - Session mode: never one exec per edit (~250ms/round-trip; loop in-kernel or batch_edit); project fields kernel-side for large find_all reads. * docs: address multi-review nits — reconcile session-perf figures, api.md accept/reject parity, PEP-668 link - Session perf: the batched "one exec" path can't be quoted below the ~250ms round-trip floor; state ~0.3s (one round-trip + in-kernel loop), ~40x less overhead, instead of ~0.2s/~60x. - docs/api.md majority-format clause: mirror SKILL.md's clearer two-sentence phrasing ("its own original formatting"; bold Accepting/reject). - SKILL.md PEP-668 note: hyperlink PEP-668 to match the docs/index.md copy.
Summary
Completes the error contract for the LLM-facing API (ISSUES.md #42, dogfooding round 2, target 0.6.1):
DocumentClosedError(DocxEditError)with apathfield, raised by the_ensure_open()choke point instead of a bareValueError. The message says how to recover (reopen withDocument.open). Breaking for callers catchingValueErroraround post-close calls (pre-1.0, per task spec).DocumentNotFoundError.path,WorkspaceSyncError.workspace_path/.source_path,CommentError.comment_id,RevisionError.revision_id/.group_id. Populated at every raise site that has the value in scope; leftNonewhere no meaningful value exists.revision_idhas no populating site today (accept_revision/reject_revisionreturnbool) — it exists for a stable contract.find_text(text, occurrence=0, paragraph=None): paragraph-scoping parity withfind_all.occurrencecounts within the paragraph when scoped, document-wide otherwise; negative occurrence returnsNoneinstead of wrapping around; empty text raisesValueError(same guard both branches).find_textsignature,close()post-close note, exception entries with field docs.Test plan
TestDocumentClosedError: 7 operation kinds post-close raise the typed error withpathset and recovery hint in the message.TestLifecycleErrorFields: field assertions for all four extended classes, including None-when-not-applicable cases.TestFindTextScoped: scoped hit with coordinate-system proof, scoped miss, out-of-range/negative occurrence →None, stale hash, malformed ref, out-of-range index, empty text scoped+unscoped.pytest.raises(ValueError)assertions migrated toDocumentClosedError.ruff check+ruff format --checkclean;ty checkdiagnostics identical to baseline (7 pre-existing).Summary by CodeRabbit
New Features
DocumentClosedError, now available from the top-level package.Bug Fixes
Documentation