feat: use yamllint to check YAML files, instead of simply parsing and pretty-printing them#676
Open
jenstroeger wants to merge 1 commit intostagingfrom
Open
feat: use yamllint to check YAML files, instead of simply parsing and pretty-printing them#676jenstroeger wants to merge 1 commit intostagingfrom
jenstroeger wants to merge 1 commit intostagingfrom
Conversation
… pretty-printing them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
onis interpreted as a boolean value (docs) and turned intotrue, thus breaking theargssequence.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.