Ruamel.yaml comsiders two merge keys as a duplicate key
ruamel.yaml is a YAML 1.2 parser/emitter for Python
Brought to you by:
anthon
>>> ruamel.yaml.safe_load("""
... .foo: &foo
... hello: world
...
... .bar: &bar
... baz: qux
...
... all:
... <<: *foo
... <<: *bar
... """)
Traceback (most recent call last):
[...]
raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
in "<unicode string>", line 9, column 3:
<<: *foo
^ (line: 9)
found duplicate key "<<"
in "<unicode string>", line 10, column 3:
<<: *bar
^ (line: 10)
To suppress this check see:
http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys
Expected output would be:
{'.foo': {'hello': 'world'},
'.bar': {'baz': 'qux'},
'all': {'hello': 'world', 'baz': 'qux'}}
or at least to not barf.
I've just found the syntax
<<: [*foo, *bar]as a workaround. If that's actually the only way - as spec - to define multiple merge, please feel free to close. Thank you!Diff: