This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from typing import Any, Dict | |
class Singleton(type): | |
_instances: Dict[Any, Any] = {} | |
def __call__(cls, *args: Any, **kwargs: Any) -> Any: | |
if cls not in cls._instances: | |
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) |