Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix retry() annotations with async sleep= function#555

Merged
mergify[bot] merged 3 commits into
jd:mainfrom
Zac-HD:fix-overloads
Feb 7, 2026
Merged

Fix retry() annotations with async sleep= function#555
mergify[bot] merged 3 commits into
jd:mainfrom
Zac-HD:fix-overloads

Conversation

@Zac-HD

@Zac-HD Zac-HD commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Closes #553.

Comment thread tenacity/__init__.py Outdated
Comment on lines +588 to +593
@t.overload
def __call__(self, fn: t.Callable[P, types.CoroutineType[t.Any, t.Any, R]]) -> t.Callable[P, types.CoroutineType[t.Any, t.Any, R]]: ...
@t.overload
def __call__(self, fn: t.Callable[P, t.Coroutine[t.Any, t.Any, R]]) -> t.Callable[P, t.Coroutine[t.Any, t.Any, R]]: ...
@t.overload
def __call__(self, fn: t.Callable[P, t.Awaitable[R]]) -> t.Callable[P, t.Awaitable[R]]: ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typing.Coroutine == types.CoroutineType at runtime, but pyright distinguishes them by name and so I've provided separate overloads for them in addition to the wider Awaitable type.

Comment thread tenacity/__init__.py
Comment on lines +594 to +595
@t.overload
def __call__(self, fn: t.Callable[P, R]) -> t.Callable[P, t.Awaitable[R]]: ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then this is the "if wasn't a coroutine function or otherwise returning an awaitable, it is now" annotation

@mergify mergify Bot merged commit d4e868d into jd:main Feb 7, 2026
9 checks passed
@mergify

mergify Bot commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

✅ The pull request has been merged at 399b08c

This pull request spent 4 seconds in the queue, with no time running CI.
The checks were run in-place.

Required conditions to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tenacity.retry(sleep=...) fails type-checking with async sleep function

2 participants