-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Use ParamSpec for callables. #6353
Conversation
@overload | ||
def mustbe_deferred( | ||
f: Callable[_P, Deferred[_T]], *args: _P.args, **kw: _P.kwargs | ||
) -> Deferred[_T]: ... | ||
|
||
|
||
@overload | ||
def mustbe_deferred( | ||
f: Callable[_P, Coroutine[Deferred[Any], Any, _T]], | ||
*args: _P.args, | ||
**kw: _P.kwargs, | ||
) -> Deferred[_T]: ... | ||
|
||
|
||
@overload | ||
def mustbe_deferred( | ||
f: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs | ||
) -> Deferred[_T]: ... | ||
|
||
|
||
def mustbe_deferred( | ||
f: Callable[_P, Union[Deferred[_T], Coroutine[Deferred[Any], Any, _T], _T]], | ||
*args: _P.args, | ||
**kw: _P.kwargs, | ||
) -> Deferred[_T]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copied from maybeDeferred
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6353 +/- ##
==========================================
- Coverage 85.00% 84.86% -0.14%
==========================================
Files 161 161
Lines 11962 11996 +34
Branches 1872 1877 +5
==========================================
+ Hits 10168 10181 +13
- Misses 1512 1529 +17
- Partials 282 286 +4
|
And in all cases readability improved, in my opinion. Nice! |
I also changed most of
addCallbacks()
toaddCallback()
/addErrback()
, as the official docs say the former has worse type hints (the ones I kept need to stay for various reasons).I plan to add parameter specifications to more generics as separate PRs.