not bother with the plumbing to do so.
"""
+from __future__ import annotations
+
import atexit
import datetime
import enum
@classmethod
@abstractmethod
- def load(cls: Type) -> Any:
+ def load(cls: Type[Persistent]) -> Optional[Persistent]:
"""Load this thing from somewhere and give back an instance which
will become the global singleton and which may (see
below) be saved (via :meth:`save`) at program exit time.
# Load the piece(s) of obj that you want to from somewhere.
obj._state = load_from_somewhere(somewhere)
return obj
+
+ Args:
+ cls: the class (type) that is being instantiated. That is, the
+ type to load.
+
+ Returns:
+ An instance of the requested type or None to indicate failure.
+
"""
pass
@classmethod
@overrides
- def load(cls) -> Optional[Any]:
+ def load(
+ cls: Type[PicklingFileBasedPersistent],
+ ) -> Optional[PicklingFileBasedPersistent]:
filename = cls.get_filename()
if cls.should_we_load_data(filename):
logger.debug("Attempting to load state from %s", filename)
@classmethod
@overrides
- def load(cls: Type) -> Any:
+ def load(cls: Type[JsonFileBasedPersistent]) -> Optional[JsonFileBasedPersistent]:
filename = cls.get_filename()
if cls.should_we_load_data(filename):
logger.debug("Trying to load state from %s", filename)