Aug-28-2020, 03:01 PM
Do you have to use typing? Why not simply write
from abc import ABC, abstractmethod, abstractproperty from collections import OrderedDict class DataCollector(ABC): def __init__(self): self.__data_dict = OrderedDict() @property @abstractmethod def data_structure(self): pass class Spam(DataCollector): @DataCollector.data_structure.getter def data_structure(self): return "stru" if __name__ == '__main__': s = Spam() print(s.data_structure)If you really want to clutter the code with use typing, note that
typing.OrderedDict
is not the same as collections.OrderedDict
. I guess you need to use the former in the type declarations.