Skip to content

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

Closed

Description

@MacHu-GWU

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

Activity

  1. MacHu-GWU commented on Apr 8, 2023

    @MacHu-GWU
    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

  2. grantjenks commented on Apr 8, 2023

    @grantjenks
    Owner

    Let’s discuss in the PR.

  3. phi-friday commented on May 16, 2024

    @phi-friday

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions