My problem can be explained with this simple example:
from typing import Any, Type
class CallMe:
def __init__(self, *args: Any, **kwargs: Any) -> None:
pass
def callme_factory(c) -> Type[CallMe]:
return CallMe
@callme_factory
class DoNotCall:
pass
print(CallMe(1,2,3))
print(DoNotCall(1,2,3))
It runs and outputs two CallMe objects:
<__main__.CallMe object at 0x0000017E6C5EF280>
<__main__.CallMe object at 0x0000017E6C5EF280>
But when I run mypy for it, it raises an error:
test_mypy.py:15: error: Too many arguments for "DoNotCall"
Found 1 error in 1 file (checked 1 source file)
That happens even though I annotate that callme_factory() returns a subclass of the CallMe class.
My question is:
Why does mypy miss this?
How do I get it to read the code correctly?