I have a class I would like to add typehints to that looks as following:
import yaml
class TestClass(dict):
@classmethod
def load(cls, fname) -> "TestClass":
return cls(yaml.safe_load(""))
@property
@abc.abstractmethod
def test(self):
raise
when I run mypy on a module containing only this class I get the following error message:
error: Cannot instantiate abstract class 'TestClass' with abstract attribute 'test'
From what I have understood from other posts this has something to do with when the 'test' method is instantiated when executing the load method. Is there a way to fix this issue using typehints alone or would I need to adjust my code here?