Fix tee(0) contract violation, broken apidoc entry point, and doc errors#17
Merged
Conversation
- tee(n) now raises ValueError for n < 1 as its docstring has always promised (previously tee(0) silently discarded the iterator and returned an empty tuple) - remove the apidoc console script from [project.scripts]: the wheel does not package src/scripts, so every pip install shipped a broken apidoc command (ModuleNotFoundError). It is a dev-only tool; AGENTS.md now documents running it directly via uv - introspect.generate_apidoc now uses its cls parameter instead of hardcoding Itr - README: license badge pointed at the xenoform package instead of itrx; fix "accumulated" -> "accumulate" in the method list - docstring corrections (accumulate arg name, collect/next_chunk/skip/ skip_while/take_while return descriptions, map_dict type) and regenerated doc/apidoc.md Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reimplemented with Counter.most_common() instead of sort + groupby: results are ordered by descending count (ties by first appearance), items only need to be hashable rather than orderable, and counting is O(n) instead of O(n log n). Adds a doctest and tests for ordering and unorderable (complex) items; relnotes gain an Unreleased section covering this and the other behavioural changes in this PR. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug fixes from a full repo review
Code
tee(n)now raisesValueErrorforn < 1, as its docstring has always promised. Previouslytee(0)returned()and silently discarded the underlying iterator — the existing test even had thepytest.raisesassertion commented out. The test now asserts the documented behaviour and that the source iterator is left intact.value_countsnow behaves like pandas'value_counts(requested follow-up, closes the first item of Enhancement suggestions from repo review #18): reimplemented withCounter.most_common(), so results are ordered most-common-first (ties by first appearance) instead of sorted by key. Items now only need to be hashable rather than orderable (e.g.complexworks), and counting is O(n) instead of O(n log n). Breaking change, recorded in relnotes under Unreleased.Packaging
apidocconsole script from[project.scripts]. The wheel built by hatchling only packagessrc/itrx, notsrc/scripts, so everypip install itrxshipped anapidoccommand that immediately fails withModuleNotFoundError: scripts. It only worked locally because the dev venv uses an editable install. It's a dev-only tool, so rather than shipping thescriptspackage to PyPI, the entry point is dropped and AGENTS.md now documentsuv run python src/scripts/introspect.py.Doc generator
generate_apidoc(cls, file)ignored itsclsparameter and hardcodedItr(ingetattr, the doc header, and the class docstring). Now usescls, so output is unchanged forItrbut the function works as its signature advertises.Documentation
xenoformpackage instead ofitrx.accumulatedmethod (should beaccumulate).accumulatedocumented aninitial_valuearg (actual nameinitial) with a "will the the" typo;collectclaimed to return "a list";next_chunkclaimed to return a list (returns tuple);skip/skip_while/take_whileclaimed to returnSelf/"the iterator itself" (they return newItrinstances);map_dicthad a malformed type in its Args.doc/apidoc.md; added an Unreleased section torelnotes.md.Verification
All quality gates pass:
ruff check,ruff format --check,ty check src,pytest(145 tests, 100% coverage). Also rebuilt the wheel to confirm the staleentry_points.txtno longer ships.🤖 Generated with Claude Code