Closed
Description
What happened?
When I run mypy==1.12.0
on the example below, I get following errors:
testtyping.py:12: error: Returning Any from function declared to return "int" [no-any-return]
testtyping.py:12: error: No overload variant of "__get__" of "LRUAsyncCallable" matches argument types "A", "type[A]" [call-overload]
testtyping.py:12: note: Possible overload variant:
testtyping.py:12: note: def __get__(self, instance: None, owner: type | None = ...) -> LRUAsyncCallable[Callable[[A, int], Coroutine[Any, Any, int]]]
Without the @cache
decorator, there are no mypy errors. I'd expect the decorator to preserve the method annotation.
Minimal Reproducible Example
from asyncstdlib import cache
class A:
@cache
async def func(self, x: int) -> int:
return x + 1
async def my_func(self) -> int:
return await self.func(5)
Request Assignment [Optional]
- I already understand the cause and want to submit a bugfix.