diff --git a/news/269.bugfix b/news/269.bugfix new file mode 100644 index 000000000..6f49937f0 --- /dev/null +++ b/news/269.bugfix @@ -0,0 +1 @@ +Merging into a MISSING Structured config node expands the node first to ensure the result is legal diff --git a/news/271.bugfix b/news/271.bugfix new file mode 100644 index 000000000..a84869169 --- /dev/null +++ b/news/271.bugfix @@ -0,0 +1 @@ +Fix merging into a config with a read only node if merge is not mutating that node diff --git a/omegaconf/basecontainer.py b/omegaconf/basecontainer.py index 7f2a833a6..6815b4853 100644 --- a/omegaconf/basecontainer.py +++ b/omegaconf/basecontainer.py @@ -12,14 +12,14 @@ _convert_to_omegaconf_container, _get_value, _is_interpolation, + _resolve_optional, + get_ref_type, get_value_kind, get_yaml_loader, + is_dict_annotation, is_primitive_container, is_primitive_dict, is_structured_config, - get_ref_type, - is_dict_annotation, - _resolve_optional, ) from .base import Container, ContainerMetadata, Node from .errors import MissingMandatoryValue, ReadonlyConfigError, ValidationError @@ -232,8 +232,6 @@ def pretty(self, resolve: bool = False, sort_keys: bool = False) -> str: @staticmethod def _map_merge(dest: "BaseContainer", src: "BaseContainer") -> None: """merge src into dest and return a new copy, does not modified input""" - from omegaconf import OmegaConf - from .dictconfig import DictConfig from .listconfig import ListConfig from .nodes import ValueNode diff --git a/tests/test_merge.py b/tests/test_merge.py index 523658644..f7ecda7d0 100644 --- a/tests/test_merge.py +++ b/tests/test_merge.py @@ -1,5 +1,6 @@ -from typing import Any, Tuple from dataclasses import dataclass +from typing import Any, Tuple + import pytest from omegaconf import ( @@ -217,22 +218,6 @@ def test_merge(inputs: Any, expected: Any) -> None: OmegaConf.merge(*configs) -""" -from omegaconf import OmegaConf, MISSING -from dataclasses import dataclass - -@dataclass -class A: - a : int = 10 - -@dataclass -class B: - x : A = MISSING - -OmegaConf.merge(B, {"x": {}}) -""" - - def test_merge_error_retains_type() -> None: cfg = OmegaConf.structured(ConcretePlugin) with pytest.raises(ValidationError):