Configuration can be updated from the script before loading it and mutation can change types.
Limitations: mutation can not a local object or class instance.
Example
python
old_value = {"encoder": "E1", "decoder": "D1"}
old_value = "unet"
old_value = [1, 2, 3]
old_value = 5
new_value = "unet"
new_value = [1, 2, 3]
new_value = {"encoder": "E1", "decoder": "D1"}
new_value = 5
Create a configuration file:
filepath = os.path.join(dirname, "custom_module.py")
s = f"""
a = {old_value}
"""
with open(filepath, "w") as h:
h.write(s)
Load configuration:
config = ConfigObject(filepath, mutations={"a": new_value})
assert config.a == new_value
What's Changed
* Mutations can change types by vfdev-5 in https://github.com/vfdev-5/py_config_runner/pull/16
* Updated docstring by vfdev-5 in https://github.com/vfdev-5/py_config_runner/pull/17
**Full Changelog**: https://github.com/vfdev-5/py_config_runner/compare/v0.3.0...v0.3.1