This lesson is part of the Automating Python Code Quality course.
In this lesson, you will learn:
- what yamllint is
- how to check your YAML files for issues using yamllint
- how to install yamllint
- yamllint's main configuration options.
What is YAML Lint?
As the name suggests, YAML lint allows us to check and validate our YAML files for issues, for example indentation issues.
Installing YAML Lint
To install YAML lint, simply perform a:
$ poetry add -D yamllint
Usage
yamllint can be run against a file or directory. If a directory is specified, yamllint will recursively check all of the files. Examples of each are shown below:
$ yamllint .
$ yamllint dir
$ yamllint myfile.yml
Therefore, let’s say we have the following file:
❯ cat 002_linting/004_yamllint_issues.yaml
vlans:
- vlan_id: 100
vlan_name: SALES
vlan_id: 200
vlan_name: HR