yamllint
yamllint copied to clipboard
Bug: key-duplicates does not work when key is an array
Test case:
$ cat test.yaml
---
field1:
key1: val1
key2: val2
key1: val1
$ yamllint test.yaml
test.yaml
5:3 error duplication of key "key1" in mapping (key-duplicates)
$ cat test2.yaml
---
field1:
- key1: val1
- key2: val2
- key1: val1
$ yamllint test2.yaml
$ /bin/python3 -m pip show yamllint
Name: yamllint
Version: 1.23.0
Summary: A linter for YAML files.
Home-page: https://github.com/adrienverge/yamllint
Author: Adrien Vergé
Author-email: None
License: GPLv3
Location: /usr/lib/python3.6/site-packages
Requires: pathspec, pyyaml
Required-by:
Hello,
This is totally expected: your second example would translate as:
{
"field1": [
{
"key1": "val1"
},
{
"key2": "val2"
},
{
"key1": "val1"
}
]
}
which does not cause any ambiguity nor value override, because each one of the mappings is indenpendent.
Damn. No option for it? This is the exact thing I need to catch.
Hello, this is not an issue and intended to work like that. There is no key duplication in the example test2.yaml
.