Skip to content

Validate and normalize partition_all batch sizes - #648

Open
muneikh wants to merge 1 commit into
pytoolz:masterfrom
muneikh:reject-nonpositive-partition-all-size
Open

muneikh wants to merge 1 commit into
pytoolz:masterfrom
muneikh:reject-nonpositive-partition-all-size

Conversation

@muneikh

@muneikh muneikh commented Oct 11, 2026

Copy link
Copy Markdown

partition_all(0, rows) and negative sizes silently produce an empty iterator even with nonempty input. A valid integer-index object is accepted when the iterator group is built, but can raise TypeError later when a short final batch requires arithmetic on the original object.

Normalize the batch size once using operator.index and require it to be positive before touching the source. Document the requirement and test empty/nonempty inputs, unchanged source consumption on invalid size, and an indexable size with a short final batch.

Validation: three regressions fail against the original code; the library and doctest suite passes with the fix (271 passed, 2 skipped). Configured pycodestyle and git diff --check pass. Nonpositive sizes now raise ValueError when the generator is advanced; non-integral sizes remain TypeError.

This branch has not been deployed

No deployments
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