mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-07-01 20:26:27 +00:00
refactor: Database
class
This commit is contained in:
12
src/arcaea_offline/singleton.py
Normal file
12
src/arcaea_offline/singleton.py
Normal 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
|
Reference in New Issue
Block a user