Repository navigation
Fix decorator in retry module - #5482
Conversation
hauntsaninja
left a comment
There was a problem hiding this comment.
Thanks, this looks good to me.
For the record, I think this might be a bug in mypy, since:
diff --git a/stubs/retry/retry/api.pyi b/stubs/retry/retry/api.pyi
index 88f274b9..6e1a0edd 100644
--- a/stubs/retry/retry/api.pyi
+++ b/stubs/retry/retry/api.pyi
@@ -25,4 +25,4 @@ def retry(
backoff: float = ...,
jitter: Union[Tuple[float, float], float] = ...,
logger: Optional[Logger] = ...,
-) -> _Decorator[_T]: ...
+) -> Callable[[_T], _T]: ...
is also enough to fix.
However, IIRC this shorthand where the TypeVar only occurs in the return type is sort of contentious syntax between type checkers, so using the callback protocol is probably for the best.
|
I extracted |
|
Thanks for having a look @hauntsaninja . |
|
Whatever you prefer, I can do it, or you can wait. |
|
Finish your work on 5483, I'll take care of retry later. |
|
#5483 is merged now. |
|
Merged master and updated to use IdentifyFunction. |
|
Thanks @srittau & @hauntsaninja ! |
Hi,
I'm afraid the type annotations for the retry module are incorrect, although it's possible that the real issue is in mypy; it's possible I don't understand typing annotations enough to be 100% sure.
I want to typecheck the following program with mypy:
Running with python3.7 (as provided by Debian) or 3.9.4 (latest version compiled locally) with mypy 0.820 and types-retry 0.1.1, I get the following:
Which is not right.
With the changes included in this PR, I get the expected errors from mypy:
I copied the definition of
_Decoratorfromstubs/click/click/decorators.pyi.