Mypy seems to have trouble understanding a property is not a callable method of a class:
from abc import abstractmethod
from typing import Type
class A:
pass
class B:
@abstractmethod
@property
@classmethod
def other_type(cls) -> Type[A]:
pass
@classmethod
def __init_subclass__(cls, **kwargs):
assert issubclass(cls.other_type, A)
Running mypy on the above example results in the following error:
error: Argument 1 to "issubclass" has incompatible type "Callable[[], Type[A]]"; expected "type" [arg-type]
How can I enforce the correct type, without # type: ignore[arg-type]
? I'm using mypy version 0.782 and python 3.7
(Note: I'm running mypy with the --check-untyped-defs
flag, so mypy should be scanning the __init_subclass__
method).