Development

yamllint provides both a script and a Python module. The latter can be used to write your own linting tools.

Basic example of running the linter from Python:

import yamllint

yaml_config = yamllint.config.YamlLintConfig("extends: default")
for p in yamllint.linter.run(open("example.yaml", "r"), yaml_config):
    print(p.desc, p.line, p.rule)
class yamllint.linter.LintProblem(line, column, desc='<no description>', rule=None)

Represents a linting problem found by yamllint.

column

Column on which the problem was found (starting at 1)

desc

Human-readable description of the problem

line

Line on which the problem was found (starting at 1)

rule

Identifier of the rule that detected the problem

yamllint.linter.run(input, conf, filepath=None)

Lints a YAML source.

Returns a generator of LintProblem objects.

Parameters:
  • input – buffer, string or stream to read from

  • conf – yamllint configuration object