Add initial type hinting support across the project (beta) #117
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.
This PR introduces comprehensive type annotations across the project. While not yet fully complete, the current implementation provides strong type support for the majority of the pipes and utilities, and can be considered a solid beta version.
The goal is to improve developer experience with better autocomplete, editor support, and static analysis via tools like MyPy, PyCharm, and VSCode.
✅ Summary of Type Hinting Coverage
TypeGuard
/TypeIs
not yet supportedr
param (e.g.r=2
->Iterator[tuple[T, T]]
,r=3
->Iterator[tuple[T, T, T]]
)Iterable[T | Iterable[T]]
(withT
beforeIterable[T]
)TypeGuard
/TypeIs
not yet supportedIterable[Iterable[T]]
, not with unioned inner lists✨ New Features
cast
pipe, which allows casting input to an explicitly specified output type.Still under discussion: whether it should include runtime type-checking or stay purely static.
mypy
currently throws errors onchain_with
andizip
, although the type inference works as expected.🧪 Testing
❓ Questions
I'd appreciate input on whether we should default to
Any
orobject
in places where we can't infer precise types.Any
tells the type checker “skip checking” - everything is allowed.object
is the true top type - everything is compatible with it, but you can't do anything with it without a cast or check.Using
object
encourages safer code but can feel more restrictive during prototyping. Let me know what you prefer for this codebase.I'd love to hear your thoughts on this — especially around the new cast pipe and any ideas for improving support in VSCode. If you spot anything unclear, inconsistent, or just plain wrong, feel free to point it out. Feedback is super welcome, and I’m happy to iterate on this.
Thanks!