Repository: omry/omegaconf

Issue:
Handle dotlist override with values containing =
See https://github.com/facebookresearch/hydra/issues/266 (Which is actually one bug in Hydra and one in OmegaConf).

Discussion:

Patch:
diff --git a/omegaconf/config.py b/omegaconf/config.py
index 6b53109..3c80734 100644
--- a/omegaconf/config.py
+++ b/omegaconf/config.py
@@ -244,12 +244,15 @@ class Config(object):
 
     def merge_with_dotlist(self, dotlist):
         for arg in dotlist:
-            args = arg.split("=")
-            key = args[0]
-            value = None
-            if len(args) > 1:
-                # load with yaml to get correct automatic typing with the same rules as yaml parsing
-                value = yaml.load(args[1], Loader=get_yaml_loader())
+            idx = arg.find("=")
+            if idx == -1:
+                key = arg
+                value = None
+            else:
+                key = arg[0:idx]
+                value = arg[idx + 1 :]
+                value = yaml.load(value, Loader=get_yaml_loader())
+
             self.update(key, value)
 
     def update(self, key, value=None):


Test patch:
diff --git a/tests/test_update.py b/tests/test_update.py
index 0ade637..12fcacf 100644
--- a/tests/test_update.py
+++ b/tests/test_update.py
@@ -1,5 +1,6 @@
 import sys
 
+import pytest
 from pytest import raises
 
 from omegaconf import MissingMandatoryValue
@@ -154,10 +155,18 @@ def test_update_list_make_dict():
     assert c[1].b.b == "bb"
 
 
-def test_merge_with_dotlist():
-    c = OmegaConf.create([1, 2, 3])
-    c.merge_with_dotlist(["0=bar", "2.a=100"])
-    assert c == ["bar", 2, dict(a=100)]
+@pytest.mark.parametrize(
+    "cfg,overrides,expected",
+    [
+        ([1, 2, 3], ["0=bar", "2.a=100"], ["bar", 2, dict(a=100)]),
+        ({}, ["foo=bar", "bar=100"], {"foo": "bar", "bar": 100}),
+        ({}, ["foo=bar=10"], {"foo": "bar=10"}),
+    ],
+)
+def test_merge_with_dotlist(cfg, overrides, expected):
+    c = OmegaConf.create(cfg)
+    c.merge_with_dotlist(overrides)
+    assert c == expected
 
 
 def test_merge_with_cli():