Skip to content

fix: return an empty iterator for empty worksheets - #238

Merged
dimastbk merged 1 commit into
dimastbk:masterfrom
ryanduguid:fix/empty-sheet-iteration
Oct 8, 2026
Merged

dimastbk merged 1 commit into
dimastbk:masterfrom
ryanduguid:fix/empty-sheet-iteration

Conversation

@ryanduguid

@ryanduguid ryanduguid commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Calling iter_rows() on an empty worksheet raises PanicException because its range has no start coordinate. Default the private coordinate and return exhaustion before updating the counter for an empty range, so repeated next() calls also stay exhausted.

The regression reuses the existing XLSX, XLS, XLSB and ODS fixtures and covers empty iteration, repeated StopIteration and an identity sentinel default.

Verification

  • An initial empty-iteration regression fails all four formats on unchanged compiled source with Python 3.12.15; its original suite passes 51 tests with one existing expected failure.
  • On Linux with Python 3.12.14, pip install -e . succeeds, pytest passes 55 tests with that same expected failure, and all 14 pre-commit run --all-files hooks pass.
  • Six non-empty fixture samples have matching JSON-rendered values and offsets, including sheets starting at (1, 1). Their iterators also work after external workbook/sheet references are gone.
  • A temporary module-private Rust test-profile probe passes repeated empty calls at u32::MAX; removing only the empty guard produces an arithmetic overflow. The probe restores the source and is outside this PR.

Risks and unverified checks

This changes empty-range iterator construction and exhaustion. Final Windows/macOS native builds, other Python versions, PyPy, free-threaded Python, PyEmscripten, release wheels, coverage and successful upstream CI remain unverified. The existing unsafe lifetime arrangement has not received a general audit.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b6c29140-d30e-4018-8045-30895b2b5ebc
📥 Commits

Reviewing files that changed from the base of the PR and between 84fa0e4 and f582568.

📒 Files selected for processing (2)
  • src/types/sheet.rs
  • tests/test_base.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Empty sheet ranges now initialize without a missing-start panic and stop iteration immediately. Tests cover empty sheets in XLSX, XLS, XLSB, and ODS workbooks.

Changes

Empty Sheet Iteration

Layer / File(s) Summary
Empty range handling
src/types/sheet.rs, tests/test_base.py
from_range defaults a missing range start to (0, 0). __next__ returns None for an empty range. Tests check unset sheet bounds, repeated exhaustion, and next() with a default across four workbook formats.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to f5825

Empty worksheets now yield no rows and remain exhausted on subsequent calls. The reviewed change presents no actionable merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: empty worksheets now produce an empty iterator.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

A rabbit checks a sheet so wide,
Finds no rows waiting there inside.
It takes one step, then stops with care,
No bounds to find, no cells to share.
Four formats pass; the burrow cheers!

Comment @coderabbitai help to get the list of available commands.

@dimastbk
dimastbk merged commit 8331442 into dimastbk:master Oct 8, 2026
32 checks passed
@dimastbk

dimastbk commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants