I updated mypy to 0.790, This error has occurred.
error: "ttl_cache" does not return a value
[func-returns-value]
@ttl_cache(maxsize=1, ttl=60 * 30)
^
Using 0.782 does not have this error.
Can you show us what ttl_cache is? Is it from a library?
Can you show us what
ttl_cacheis? Is it from a library?
It is from cachetools 4.1.1 https://pypi.org/project/cachetools/
This was fixed in python/typeshed#4556. Edit: mypy 0.790 ships with new stubs for cachetools. They were partly faulty, but will be fixed with the next mypy release.
Thanks, closing this then
If anyone is looking for a quick and dirty hack to get on with your life while you wait for the new version this worked for me, as I only had ttl_cache used in one file in our project. If you're using this more extensively, you should probably vendor in the stubs from typeshed and make sure your MYPYPATH is configured right.
from typing import cast, Any, Callable, TypeVar
from cachetools.func import ttl_cache as _ttl_cache
# TODO: remove type hack when new mypy version is released
# see: https://github.com/python/mypy/issues/9594
_F = TypeVar("_F", bound=Callable[..., Any])
_RET = Callable[[_F], _F]
_T_TTL_CACHE = Callable[..., _RET]
ttl_cache = cast(_T_TTL_CACHE, _ttl_cache)
Most helpful comment
If anyone is looking for a quick and dirty hack to get on with your life while you wait for the new version this worked for me, as I only had
ttl_cacheused in one file in our project. If you're using this more extensively, you should probably vendor in the stubs from typeshed and make sure yourMYPYPATHis configured right.