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

Interpolation error with DEEP or DEEP_NO_BACKTRACK #47

Open
chinghwayu opened this issue Sep 29, 2020 · 2 comments
Open

Interpolation error with DEEP or DEEP_NO_BACKTRACK #47

chinghwayu opened this issue Sep 29, 2020 · 2 comments

Comments

@chinghwayu
Copy link
Contributor

chinghwayu commented Sep 29, 2020

conf.py

var1 = "2020"
var2 = "{var1}"
var3 = "{var1}/{var2}"

mytest.py

module_list = ["conf.py"]
cfg = config(*module_list, separator="__", interpolate=True, interpolate_type=InterpolateEnumType.DEEP_NO_BACKTRACK)
print(cfg["var3"])

Sometimes it will work and return

2020/2020

But other times, it will return

  File "/home/chinghwa/.pyenv/versions/py365-dev/lib/python3.6/site-packages/config/configuration_set.py", line 110, in __getitem__
    return self._from_configs("__getitem__", item)
  File "/home/chinghwa/.pyenv/versions/py365-dev/lib/python3.6/site-packages/config/configuration_set.py", line 83, in _from_configs
    return interpolate_object(args[0], values[0], d, self._interpolate_type)
  File "/home/chinghwa/.pyenv/versions/py365-dev/lib/python3.6/site-packages/config/helpers.py", line 197, in interpolate_object
    return interpolate_deep(attr, obj, d, {}, {}, method)
  File "/home/chinghwa/.pyenv/versions/py365-dev/lib/python3.6/site-packages/config/helpers.py", line 147, in interpolate_deep
    raise KeyError(variable)
KeyError: 'var1'
@tr11
Copy link
Owner

tr11 commented Sep 30, 2020

I'll take a look at it this weekend. I'm planning on unifying the way the templating works that will hopefully fix all these issues

@chinghwayu
Copy link
Contributor Author

I'll take a look at it this weekend. I'm planning on unifying the way the templating works that will hopefully fix all these issues

Any chance at looking at this again in the near future? 😀

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

No branches or pull requests

2 participants