from typing import TYPE_CHECKING if TYPE_CHECKING: from .data_loader import DataLoader class classproperty(property): def __get__(self, obj, objtype=None): return super(classproperty, self).__get__(objtype) def __set__(self, obj, value): super(classproperty, self).__set__(type(obj), value) def __delete__(self, obj): super(classproperty, self).__delete__(type(obj)) class DataloaderContext: _instance: 'DataloaderContext' = None def __init__(self) -> None: self.dataloader: 'DataLoader' = None @classproperty def instance(cls) -> 'DataloaderContext': if cls._instance is None: cls._instance = DataloaderContext() return cls._instance