Coverage for glotter/singleton.py: 100%
10 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-12 02:25 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-12 02:25 +0000
1class Singleton(type):
2 _instances = {}
4 def __call__(cls, *args, **kwargs):
5 if cls not in cls._instances:
6 instance = super().__call__(*args, **kwargs)
7 cls._instances[cls] = instance
8 return cls._instances[cls]
10 @staticmethod
11 def clear():
12 Singleton._instances = {}