import yaml
foo = """
foo: &foo "foo"
bar:
x: *foo
y: &foo "bar"
z: *foo
"""
bar = yaml.load(foo)
print(bar)
according to the yaml specification here http://yaml.org/spec/1.2/spec.html#anchor//
When composing a representation graph from serialized events, an alias node refers to the most recent node in the serialization having the specified anchor. Therefore, anchors need not be unique within a serialization. In addition, an anchor need not have an alias node referring to it. It is therefore possible to provide an anchor for all nodes in serialization.
this was fixed in older version of ruaml.yaml apparently as well before reintroducing the bug
not sure why this was closed, as it is indeed a bug
I too have encountered this problem while processing some gitlab ci yaml files. The files have duplicate anchors but are perfectly valid. When I modified a temporary local copy of the yaml files to remove the duplicates issue, the files processed fine.
Hmm, is there any workarounds?
Hmm, is there any workarounds?
Not that I know of, but there is a pending PR: #394
Most helpful comment
not sure why this was closed, as it is indeed a bug