Skip to content

Fix review issues: typing, return types, and minor correctness fixes#14

Merged
virgesmith merged 4 commits into
mainfrom
fix/review-issues
May 17, 2026
Merged

Fix review issues: typing, return types, and minor correctness fixes#14
virgesmith merged 4 commits into
mainfrom
fix/review-issues

Conversation

@virgesmith

Copy link
Copy Markdown
Owner

Summary

  • Fix duplicate repos: key in .pre-commit-config.yaml
  • Type self in unzip as Itr[tuple[U, V]] to express the pair constraint without a type: ignore comment
  • Fix max/min return type from objectT; key parameter uses Callable[[T], Any]
  • Fix last() return type to T (raises ValueError on empty, now documented)
  • Add input validation to nth() for n < 1
  • Replace interleave chain with an explicit generator to fix type inference
  • Use cast in chain and intersperse to resolve union return types cleanly
  • Fix group_by to avoid nested lambda on sorted groupby result
  • Fix bare return None in intersperse generator to return

Test plan

  • uv run ty check src — no errors
  • uv run ruff check src/itrx/ — no errors
  • uv run pytest — 138 passed, 100% coverage

🤖 Generated with Claude Code

- 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]>
Comment thread src/itrx/itr.py Outdated
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)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this achieves nothing

virgesmith and others added 3 commits May 17, 2026 09:07
- 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]>
@virgesmith virgesmith merged commit 6050958 into main May 17, 2026
9 checks passed
@virgesmith virgesmith deleted the fix/review-issues branch May 17, 2026 12:05
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