Skip to content

Mypy Error with Decorator Handling Both Sync and Async Functions #1930

Answered by Daverball
FelixSiegel asked this question in Q&A
Discussion options

You must be logged in to vote

You need to swap the two overloads, the non-async overload is broader than the async one and will match all async functions as well. So you always end up with RetType | None as the return type, which in case of your async function will be Coroutine[Any, Any, int] | None.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@FelixSiegel
Comment options

Answer selected by FelixSiegel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants