contains-io/typet

Add base classes SingletonObject and StrictSingletonObject

dangle opened this issue · 1 comments

Create a SingletonObject by creating a private metaclass that inherits from Singleton and _ObjectMeta and a metaclass for a StrictSingletonObject that inherits from Singleton and _StrictObjectMeta.

The proposed use case would be a global settings object:

from typet import SingletonObject, File

class _Configuration(SingletonObject):
    config: File = '~/.my_config'

settings = _Configuration()

Closed in favor of #8