type signature preservation does not support class arguments
bmc-msft opened this issue · comments
bmc-msft commented
Example source:
from memoization import cached
import inspect
class A:
@cached(ttl=1)
def b(self, name: str) -> int:
return len(name) * 2
def a(self) -> bool:
return self.b('hello') == 10
Using mypy for the above example gives the error:
/tmp/as-class.py:10: error: Too few arguments for "b" of "A"
/tmp/as-class.py:10: error: Argument 1 to "b" of "A" has incompatible type "str"; expected "A"
If you comment out the @cached
line, mypy gives the response:
Success: no issues found in 1 source file
bmc-msft commented
Using the example I provided in #16, @cached
preserves the arguments as I expected.
Phil Elson commented
Came across this one today also.
lonelyenvoy commented
According to Guido van Rossum (python/typing#824), this should be a longstanding issue in mypy (python/mypy#10805). Until now, I did not find any workaround, but I will continue to work on it.
If anyone encounters this issue, I recommend using @bmc-msft's way to disable the cache before mypy checks and enable it afterwards.