libb.configure_environment

configure_environment(module, **config_overrides)[source]

Configure environment settings at runtime.

Dynamically sets configuration values on Setting objects in the provided module. Keys should follow the pattern setting_attribute or setting_nested_attribute.

Parameters:
  • module – The module containing Setting objects to configure.

  • config_overrides (Any) – Configuration values to set with keys as dotted paths.

Return type:

None

Example:

>>> from libb import create_mock_module
>>> Setting.unlock()
>>> db = Setting()
>>> db.host = 'localhost'
>>> Setting.lock()
>>> create_mock_module('my_config', {'db': db})
>>> import my_config
>>> configure_environment(my_config, db_host='remotehost')
>>> my_config.db.host
'remotehost'