Closed bmc-msft closed 3 years ago
Using cached does not preserve the type signature.
cached
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.
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.
Using
cached
does not preserve the type signature.Expected: No output
Actual result:
This prevents using type validation tools, such as mypy, from being used to validate the usage of methods wrapped in
cached
.