Repository navigation
Conversation
|
An optional test-only commit, based directly on your branch. Your consumption test checks that the source's values remain available. This adds a guard that raises if Two small checks worth keeping: rejection before source initialization, and both error paths (nonpositive integer sizes and a non-integral size). No real files or network calls are involved. On Python 3.14.4, all three cases pass your head with zero source starts; the base hits the exact source-start guard. The unchanged normal To run the added file in your tree: |
Wkhanex
left a comment
There was a problem hiding this comment.
Verified 491414b against 504 independently constructed batch expectations: sizes 1–8, source lengths 0–20, and list, tuple and iterator inputs. Each size was a custom __index__ object with a call counter. Every result matched ordinary sequence slicing, including short final batches, and each size was normalized exactly once.
Five invalid-size cases (zero, two negatives, float and string) also left a one-shot source's values untouched. These 1,013 assertions passed on CPython 3.12.14; the base fails on a custom-index size. The four existing partition_all tests pass. This does not add a full-suite or multi-version result.
Review prepared with Codex assistance; the checks described above were executed locally.
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 raiseTypeErrorlater when a short final batch requires arithmetic on the original object.Normalize the batch size once using
operator.indexand 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 --checkpass. Nonpositive sizes now raiseValueErrorwhen the generator is advanced; non-integral sizes remainTypeError.