Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dot-based keys don't interpolate #36

Open
chinghwayu opened this issue Aug 5, 2020 · 3 comments · May be fixed by #37
Open

Dot-based keys don't interpolate #36

chinghwayu opened this issue Aug 5, 2020 · 3 comments · May be fixed by #37

Comments

@chinghwayu
Copy link
Contributor

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'
tr11 pushed a commit that referenced this issue Aug 5, 2020
@tr11 tr11 linked a pull request Aug 5, 2020 that will close this issue
@tr11
Copy link
Owner

tr11 commented Aug 5, 2020

Can you test PR #37?

@chinghwayu
Copy link
Contributor Author

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

@tr11
Copy link
Owner

tr11 commented Aug 5, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants