diff --git a/omegaconf/dictconfig.py b/omegaconf/dictconfig.py index 8e25ce9c2..10a3b7f34 100644 --- a/omegaconf/dictconfig.py +++ b/omegaconf/dictconfig.py @@ -594,6 +594,8 @@ def __eq__(self, other: Any) -> bool: return DictConfig._dict_conf_eq(self, other) if isinstance(other, DictConfig): return DictConfig._dict_conf_eq(self, other) + if self._is_missing(): + return _is_missing_literal(other) return NotImplemented def __ne__(self, other: Any) -> bool: diff --git a/omegaconf/listconfig.py b/omegaconf/listconfig.py index bb2c8a886..08a7d4e38 100644 --- a/omegaconf/listconfig.py +++ b/omegaconf/listconfig.py @@ -16,6 +16,7 @@ from ._utils import ( ValueKind, + _is_missing_literal, _is_none, _is_optional, format_and_raise, @@ -481,6 +482,8 @@ def __eq__(self, other: Any) -> bool: return ListConfig._list_eq(self, other) if other is None or isinstance(other, ListConfig): return ListConfig._list_eq(self, other) + if self._is_missing(): + return _is_missing_literal(other) return NotImplemented def __ne__(self, other: Any) -> bool: diff --git a/tests/test_config_eq.py b/tests/test_config_eq.py index 003506be6..dae24de0b 100644 --- a/tests/test_config_eq.py +++ b/tests/test_config_eq.py @@ -99,6 +99,20 @@ def eq(a: Any, b: Any) -> None: eq(c2, i2) +@mark.parametrize( + "cfg,other", + [ + param(DictConfig("???"), "???", id="missing_dictconfig"), + param(ListConfig("???"), "???", id="missing_listconfig"), + ], +) +def test_missing_container_string_eq(cfg: Any, other: Any) -> None: + assert cfg == other + assert other == cfg + assert not (cfg != other) + assert not (other != cfg) + + @mark.parametrize( "input1, input2", [