@@ -529,7 +529,7 @@ If you load them and merge them with ``list_merge_mode=ListMergeMode.EXTEND_UNIQ
529529 >>>
530530 >>> cfg_1 = OmegaConf.load(' source/example2.yaml' )
531531 >>> cfg_2 = OmegaConf.load(' source/example4.yaml' )
532- >>>
532+ >>>
533533 >>> mode = ListMergeMode.EXTEND_UNIQUE
534534 >>> conf = OmegaConf.merge(cfg_1, cfg_2, list_merge_mode = mode)
535535 >>> print (OmegaConf.to_yaml(conf))
@@ -541,6 +541,32 @@ If you load them and merge them with ``list_merge_mode=ListMergeMode.EXTEND_UNIQ
541541 - user3
542542 <BLANKLINE>
543543
544+ Missing values in ``merge() ``
545+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
546+
547+ ``merge() `` treats ``MISSING `` (``"???" ``) on the *source * side as "no value
548+ to apply" rather than as a value to write — a non-missing value on the
549+ target is never overwritten by a missing value coming from a later config.
550+ Merging in the opposite order does fill the missing value:
551+
552+ .. doctest ::
553+
554+ >>> from omegaconf import OmegaConf
555+ >>> base = OmegaConf.create({" port" : 80 })
556+ >>> override = OmegaConf.create({" port" : " ???" })
557+ >>>
558+ >>> # MISSING on the source side does not overwrite an existing value.
559+ >>> print (OmegaConf.merge(base, override))
560+ {'port': 80}
561+ >>>
562+ >>> # The reverse order does fill the missing value.
563+ >>> print (OmegaConf.merge(override, base))
564+ {'port': 80}
565+
566+ This is useful when a later config (e.g. a base schema) declares some keys
567+ as mandatory: those declarations do not clobber concrete values supplied by
568+ an earlier config.
569+
544570Union operator (``| `` and ``|= ``)
545571^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
546572
0 commit comments