python-configuration
python-configuration copied to clipboard
Dot-based keys don't interpolate
values_1 = {"a.b": "value"}
values_2 = {"var": "{a.b}"}
cfg = config(
values_2,
values_1,
lowercase_keys=True,
interpolate=True,
)
print(cfg.var)
Results in:
File "/group/siv_roast_bkup/staff/chinghwa/python-configuration/config/configuration_set.py", line 113, in __getattr__
return self._from_configs("__getattr__", item)
File "/group/siv_roast_bkup/staff/chinghwa/python-configuration/config/configuration_set.py", line 83, in _from_configs
return interpolate_object(args[0], values[0], d, self._interpolate_type)
File "/group/siv_roast_bkup/staff/chinghwa/python-configuration/config/helpers.py", line 192, in interpolate_object
return interpolate_standard(obj, flatten(d), set())
File "/group/siv_roast_bkup/staff/chinghwa/python-configuration/config/helpers.py", line 112, in interpolate_standard
return text.format(**interpolated)
KeyError: 'a'
Can you test PR #37?
conf.py:
my__var = "hello"
dir/conf.py
var = {my.var}
loader:
module_list = ["dir/conf.py","conf.py"]
cfg = config(*module_list, separator="__", interpolate=True, interpolate_type=InterpolateEnumType.DEEP)
cfg["var"]
will only work when interpolate_type is STANDARD
Yeah, I noticed that this morning when I realized I only changed one of the methods. I'll take a look at it this weekend