-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loss of typing information on composed functions #569
Comments
Additional note: calling
But I suspect this is done at runtime, so there is no benefit for my use case. I am curious now: what would a language such as OCaml do? n.b.: I also tried a different library, more limited in scope (https://pypi.org/project/compose/), which behaves exactly as |
Update re: last comment: my https://pypi.org/project/compose/ now has optional type hints (available in https://pypi.org/project/compose-stubs/ ) Notes for the toolz community based on my experience type-hinting
|
Passing any function through
compose()
seems to strip away all the information about the types of those functions.Minimal example:
Testing on python 3.11 yields:
I expected that the static type checker would have printed
builtins.str
even forg(1)
.This is a stripped down example of a larger problem I had early on on a project of mine, where I wrongly assumed that composed functions would have brought over the type information about their signature. I ended up introducing a bug in my project because of this assumption.
Is this use case something that
toolz
could ever support? I have no idea if this is due to a deep limitation in the Python language or is simply something that eventually needs to be worked on.I also read #496, but I do not know if my problem could be solved by working on that issue.
Thank you for the library.
The text was updated successfully, but these errors were encountered: