-
Notifications
You must be signed in to change notification settings - Fork 3
🏷️ Adding Type Annotations #5
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
Comments
Cheers! My current plan is to release type hints for I'm not sure how soon I'll get to it, and there are some tricky things to figure out. (I wrote a little bit more on that in the comments of this StackOverflow question.) |
So here's the situation when I last looked into it: Problem: there's no way to do just one type-hint for variadic from typing import Callable, TypeVar, ParamSpec, overload
P = ParamSpec('P')
R1 = TypeVar('R1')
R2 = TypeVar('R2')
R3 = TypeVar('R3')
R4 = TypeVar('R4')
@overload
def compose(f2: Callable[[R1], R2], f1: Callable[P, R1]) -> Callable[P, R2]:
...
@overload
def compose(f3: Callable[[R2], R3], f2: Callable[[R1], R2], f1: Callable[P, R1]) -> Callable[P, R3]:
...
@overload
def compose(f4: Callable[[R3], R4], f3: Callable[[R2], R3], f2: Callable[[R1], R2], f1: Callable[P, R1]) -> Callable[P, R4]:
...
# and so on, up to some large number When I last tried that, it seemed that MyPy had issues with (I'm hoping that the above type-hint overloads work well enough for most cases despite |
Finally got around to sitting down and trying the typing stubs package approach. It works! Confirmed with MyPy, Pyre, and Pyright. |
Implemented in I'll promote the stubs to stable v1 release (and push out a |
Okay, |
Request:
The text was updated successfully, but these errors were encountered: