Hi,
We do use anchors & aliases <<: * quite extensively in our CircleCI yaml config.
Unfortunately check-yaml (or rather ruamel.yaml) complains about duplicated << keys, which actually aren't duplicated.
Let's take this job definition as an example:
jobs:
setup_env_for_smoke_tests:
<<: *machine_python3
working_directory: ~/directory-tests
<<: *steps_setup_env_for_smoke_tests
When I run pre-commit run --all-files without args: [--unsafe], I'm going to get this error:
raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
in ".circleci/config.yml", line 254, column 5
found duplicate key "<<"
in ".circleci/config.yml", line 256, column 5
To suppress this check see:
http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys
I had a look at recommended doc page https://yaml.readthedocs.io/en/latest/api.html#duplicate-keys and ruamel.yaml has an option to allow allow_duplicate_keys, unfortunately check_yaml.py does not support it.
As a workaround I allowed unsafe constructs, but it doesn't look good:
- id: check-yaml
args: [--unsafe]
In theory we can "merge keys" but it's rather an ugly solution:
Further reading:
Thanks
Hi,
We do use anchors & aliases
<<: *quite extensively in our CircleCI yaml config.Unfortunately
check-yaml(or ratherruamel.yaml) complains about duplicated<<keys, which actually aren't duplicated.Let's take this job definition as an example:
When I run
pre-commit run --all-fileswithoutargs: [--unsafe], I'm going to get this error:I had a look at recommended doc page https://yaml.readthedocs.io/en/latest/api.html#duplicate-keys and
ruamel.yamlhas an option to allowallow_duplicate_keys, unfortunately check_yaml.py does not support it.As a workaround I allowed
unsafeconstructs, but it doesn't look good:In theory we can "merge keys" but it's rather an ugly solution:
Further reading:
ruamel.yamldoes support anchors https://yaml.readthedocs.io/en/latest/detail.html?highlight=anchors#detailsAnchors and AliasesThanks