Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memoize decorate will remove the type hint of the original function #276

Closed
MacHu-GWU opened this issue Apr 7, 2023 · 3 comments
Closed

Comments

@MacHu-GWU
Copy link

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 ...
@MacHu-GWU
Copy link
Author

@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

#277

@grantjenks
Copy link
Owner

Let’s discuss in the PR.

@phi-friday
Copy link

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).

arg types

스크린샷 2024-05-16 오후 3 42 43

__cache_key__

스크린샷 2024-05-16 오후 3 43 02

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

No branches or pull requests

3 participants