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

cached does not preserve type signature #16

Closed
bmc-msft opened this issue Oct 29, 2020 · 1 comment
Closed

cached does not preserve type signature #16

bmc-msft opened this issue Oct 29, 2020 · 1 comment
Labels
bug Something isn't working priority-0-high This issue has a high priority

Comments

@bmc-msft
Copy link

Using cached does not preserve the type signature.

from memoization import cached
import inspect


def foo(a: str) -> int:
    return int(a)


def bar(a: str) -> int:
    return int(a)


@cached
def baz(a: str) -> int:
    return int(a)


assert inspect.getfullargspec(foo) == inspect.getfullargspec(bar), "foo != bar"
assert inspect.getfullargspec(foo) == inspect.getfullargspec(baz), "foo != baz"

Expected: No output

Actual result:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError: foo != baz

This prevents using type validation tools, such as mypy, from being used to validate the usage of methods wrapped in cached.

@lonelyenvoy
Copy link
Owner

Resolved in v0.3.2. Now available at PyPI or GitHub Releases.

I also added full support for static type checking and it should work fine with validation tools.
Thanks for the issue and your interest in this work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-0-high This issue has a high priority
Projects
None yet
Development

No branches or pull requests

2 participants