settei.base — Basic app object

class settei.base.Configuration(config: typing.Mapping[str, object] = {}, **kwargs)

Application instance with its settings e.g. database. It implements read-only Mapping protocol as well, so you can treat it as a dictionary of string keys.

classmethod from_file(file) → settei.base.Configuration

Load settings from the given file and instantiate an Configuration instance from that.

Parameters:file – the file object that contains TOML settings
Returns:an instantiated configuration
Return type:Configuration
classmethod from_path()

Load settings from the given path and instantiate an Configuration instance from that.

Parameters:path (pathlib.Path) – the file path that contains TOML settings
Returns:an instantiated configuration
Return type:Configuration
exception settei.base.ConfigWarning

Warning category which raised when a default configuration is used instead due to missing required configuration.

class settei.base.config_property(key: str, cls, docstring: str = None, **kwargs) → None

Declare configuration key with type hints, default value, and docstring.

Parameters:
  • key (str) – the dotted string of key path. for example abc.def looks up config['abc']['def']
  • cls (type) – the allowed type of the configuration
  • docstring (str) – optional documentation about the configuration. it will be set to __doc__ attribute
  • default – keyword only argument. optional default value used for missing case. cannot be used with default_func at a time
  • default_func (collections.abc.Callable) – keyword only argument. optional callable which returns a default value for missing case. it has to take an App mapping, and return a default value. cannot be used with default at a time
  • default_warning (bool) – keyword only argument. whether to warn when default value is used. does not warn by default. this option is only available when default value is provided
docstring

(str) The propertly indented __doc__ string.