refactor: Database class

This commit is contained in:
2023-08-26 16:52:19 +08:00
parent a7533a7c08
commit 003e1a7289
4 changed files with 57 additions and 16 deletions

View File

@ -0,0 +1,12 @@
from typing import Generic, TypeVar
T = TypeVar("T")
class Singleton(type, Generic[T]):
_instance = None
def __call__(cls, *args, **kwargs) -> T:
if cls._instance is None:
cls._instance = super().__call__(*args, **kwargs)
return cls._instance