Skip to content

Fix tee(0) contract violation, broken apidoc entry point, and doc errors#17

Merged
virgesmith merged 2 commits into
mainfrom
fix/review-bugfixes
Jul 5, 2026
Merged

Fix tee(0) contract violation, broken apidoc entry point, and doc errors#17
virgesmith merged 2 commits into
mainfrom
fix/review-bugfixes

Conversation

@virgesmith

@virgesmith virgesmith commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Bug fixes from a full repo review

Code

  • tee(n) now raises ValueError for n < 1, as its docstring has always promised. Previously tee(0) returned () and silently discarded the underlying iterator — the existing test even had the pytest.raises assertion commented out. The test now asserts the documented behaviour and that the source iterator is left intact.
  • value_counts now behaves like pandas' value_counts (requested follow-up, closes the first item of Enhancement suggestions from repo review #18): reimplemented with Counter.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. complex works), and counting is O(n) instead of O(n log n). Breaking change, recorded in relnotes under Unreleased.

Packaging

  • Removed the apidoc console script from [project.scripts]. The wheel built by hatchling only packages src/itrx, not src/scripts, so every pip install itrx shipped an apidoc command that immediately fails with ModuleNotFoundError: scripts. It only worked locally because the dev venv uses an editable install. It's a dev-only tool, so rather than shipping the scripts package to PyPI, the entry point is dropped and AGENTS.md now documents uv run python src/scripts/introspect.py.

Doc generator

  • generate_apidoc(cls, file) ignored its cls parameter and hardcoded Itr (in getattr, the doc header, and the class docstring). Now uses cls, so output is unchanged for Itr but the function works as its signature advertises.

Documentation

  • README license badge pointed at the xenoform package instead of itrx.
  • README listed a non-existent accumulated method (should be accumulate).
  • Docstring corrections: accumulate documented an initial_value arg (actual name initial) with a "will the the" typo; collect claimed to return "a list"; next_chunk claimed to return a list (returns tuple); skip/skip_while/take_while claimed to return Self/"the iterator itself" (they return new Itr instances); map_dict had a malformed type in its Args.
  • Regenerated doc/apidoc.md; added an Unreleased section to relnotes.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 stale entry_points.txt no longer ships.

🤖 Generated with Claude Code

- 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>
@virgesmith virgesmith merged commit 10b1f2c into main Jul 5, 2026
9 checks passed
@virgesmith virgesmith deleted the fix/review-bugfixes branch July 5, 2026 07:40
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