boromir674/so-magic

View on GitHub
src/so_magic/utils/singleton.py

Summary

Maintainability
A
0 mins
Test Coverage

__all__ = ['Singleton']


class Singleton(type):
    _instances = {}

    def __call__(cls, *args, **kwargs):
        instance = cls._instances.get(cls)
        if not instance:
            instance = super(Singleton, cls).__call__(*args, **kwargs)
            cls._instances[cls] = instance
        return instance