Fix review issues: typing, return types, and minor correctness fixes#14
Merged
Conversation
- Fix duplicate `repos:` key in .pre-commit-config.yaml - Type `self` in `unzip` as `Itr[tuple[U, V]]` to express the pair constraint without ignore comment - Change `max`/`min` return type from `object` to `T`; key param uses `Callable[[T], Any]` - Fix `last()` return type to `T` (raises ValueError on empty, documented) - Add input validation to `nth()` for n < 1 - Replace `interleave` chain with explicit generator to fix type inference - Use `cast` in `chain` and `intersperse` to resolve union return types - Fix `group_by` to avoid nested lambda on sorted groupby result - Fix bare `return None` in `intersperse` generator to `return` Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
virgesmith
commented
May 16, 2026
Comment on lines
+269
to
+271
| return Itr(itertools.groupby(sorted(self._it, key=grouper), key=grouper)).map(lambda g: (g[0], tuple(g[1]))) # ty: ignore[no-matching-overload] | ||
| groups = ((k, tuple(v)) for k, v in itertools.groupby(sorted(self._it, key=grouper), key=grouper)) # ty: ignore[no-matching-overload] | ||
| return Itr(groups) |
- exclude doc/ from ty checking (notebooks use display which is not importable)
- replace ty: ignore comments with cast() where possible for type-safe suppressions
- use cast("Callable[[T], Any]", grouper) in groupby to satisfy sorted() overload constraints
- remove spurious # ty: ignore[no-matching-overload] comment flagged in PR review
- fix test_flat_map_invalid_mapper to use ty: ignore instead of mypy-style type: ignore
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.
Summary
repos:key in.pre-commit-config.yamlselfinunzipasItr[tuple[U, V]]to express the pair constraint without atype: ignorecommentmax/minreturn type fromobject→T; key parameter usesCallable[[T], Any]last()return type toT(raisesValueErroron empty, now documented)nth()forn < 1interleavechain with an explicit generator to fix type inferencecastinchainandintersperseto resolve union return types cleanlygroup_byto avoid nested lambda on sorted groupby resultreturn Noneininterspersegenerator toreturnTest plan
uv run ty check src— no errorsuv run ruff check src/itrx/— no errorsuv run pytest— 138 passed, 100% coverage🤖 Generated with Claude Code