Skip to content

Return [] (not None) from empty-input chunk helpers#5

Open
shaunpatterson wants to merge 1 commit into
ekimetrics:mainfrom
shaunpatterson:fix/empty-list-contracts
Open

Return [] (not None) from empty-input chunk helpers#5
shaunpatterson wants to merge 1 commit into
ekimetrics:mainfrom
shaunpatterson:fix/empty-list-contracts

Conversation

@shaunpatterson

Copy link
Copy Markdown

Problem (Major, robustness)

find_chunks_start_and_end (hinted list[tuple[int, int]]) and repair_gaps_between_chunks (hinted list[str] | None) both returned None on empty input. Callers zip/iterate the result, so an empty document could raise TypeError rather than degrading gracefully — and the None contradicts the type hint.

Fix

Return [] from both on empty input, and tighten repair_gaps_between_chunks's return type to list[str]. Behavior on non-empty input is unchanged.

Tests

Added empty-input regression tests asserting [] for both helpers.

🤖 Generated with Claude Code

find_chunks_start_and_end and repair_gaps_between_chunks returned None on
empty input despite a list[...] return hint. Callers zip/iterate the
result, so an empty document could raise TypeError instead of degrading
gracefully. Return [] and tighten repair_gaps_between_chunks's hint to
list[str]. Adds empty-input regression tests for both.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant