Skip to content

Commit

Permalink
Fix ConfigKeyError in some cases when merging lists containing interp…
Browse files Browse the repository at this point in the history
…olation values
  • Loading branch information
omry committed Feb 3, 2021
1 parent d53960c commit 5a798e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/422.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ConfigKeyError in some cases when merging lists containing interpolation values
4 changes: 2 additions & 2 deletions omegaconf/basecontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,12 @@ def _list_merge(dest: Any, src: Any) -> None:
et = dest._metadata.element_type
if is_structured_config(et):
prototype = OmegaConf.structured(et)
for item in src:
for item in src._iter_ex(resolve=False):
if isinstance(item, DictConfig):
item = OmegaConf.merge(prototype, item)
temp_target.append(item)
else:
for item in src:
for item in src._iter_ex(resolve=False):
temp_target.append(item)

dest.__dict__["_content"] = temp_target.__dict__["_content"]
Expand Down
5 changes: 5 additions & 0 deletions tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@
ListConfig(content=[1, 2, 3]),
id="list_merge_missing_onto",
),
pytest.param(
({"a": 10, "list": []}, {"list": ["${a}"]}),
{"a": 10, "list": [10]},
id="merge_list_with_interpolation",
),
# Interpolations
# value interpolation
pytest.param(
Expand Down

0 comments on commit 5a798e0

Please sign in to comment.