Memoize decorate will remove the type hint of the original function
MacHu-GWU opened this issue · comments
Sanhe Hu commented
If you put Cache.memoize on a custom function, you will lose the type hint when using that function
from diskcache import Cache
cache = Cache(directory=...)
@cache.memorize
def hello(name: str):
return f"hello {name}"
hello(...) # when you type this, you won't see name as argument in VSCode PyCharm etc ...
Sanhe Hu commented
@grantjenks thank you for the great work!
I found an issue and also send a PR to fix it. Wish I could contribute a little
Grant Jenks commented
Let’s discuss in the PR.
phi-friday commented
Using diskcache-stubs
solves this problem.
I have confirmed that it works for pyright
,
For mypy
, I have confirmed that it works in the latest commit (which will be deployed in a new release soon).