feat: use yamllint to check YAML files, instead of simply parsing and pretty-printing them #676
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are differences between YAML 1.1 and YAML 1.2, and out there in the wild different tools use different YAML parsers for either version of YAML files.
Currently, we use
python-package-template/.pre-commit-config.yaml
Line 120 in 40e438b
python-package-template/.pre-commit-config.yaml
Lines 148 to 149 in 40e438b
However — and that’s where trouble starts, and that’s what happened in a dependent repo — by pretty-printing the YAML files using a YAML 1.2 parser we turn a
sequence into
which is valid YAML 1.2 but creates problems with YAML 1.1 parsers: there, the scalar
on
is interpreted as a boolean value (docs) and turned intotrue
, thus breaking theargs
sequence.Adding this YAML linter actually prevents that breakage because the linter notes a violation of its truthy rule.
I’d like to tinker a little more here: for example, handling of multiple documents
---
in a single file seems inconsistent between ruamel and yamllint, and it would be helpful to disable line-length checking (docs) without using other options. Also, see issue adrienverge/yamllint#632.