Skip to content

Commit

Permalink
add another merge test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasha10 authored and omry committed Jan 27, 2021
1 parent 9ad3ca8 commit a480938
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion omegaconf/basecontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def expand(node: Container) -> None:
is_structured_config(dest._metadata.element_type)
and not missing_src_value
):
if OmegaConf.is_none(dest, key):
if OmegaConf.is_none(dest, key) or OmegaConf.is_missing(dest, key):
dest[key] = DictConfig(
content=dest._metadata.element_type, parent=dest
)
Expand Down
2 changes: 1 addition & 1 deletion omegaconf/omegaconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def to_container(
)

@staticmethod
def is_missing(cfg: Any, key: Union[int, str]) -> bool:
def is_missing(cfg: Any, key: DictKeyType) -> bool:
assert isinstance(cfg, Container)
try:
node = cfg._get_node(key)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@
id="inter:node_over_node_interpolation",
),
# Structured configs
(
(DictConfig({}, element_type=User), {"user007": {"age": 99}}),
{"user007": {"name": "???", "age": 99}},
),
(
(
DictConfig({"user007": "???"}, element_type=User),
{"user007": {"age": 99}},
),
{"user007": {"name": "???", "age": 99}},
),
(
(
DictConfig({"user007": User("bond", 7)}, element_type=User),
Expand Down

0 comments on commit a480938

Please sign in to comment.