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

class yamllint.linter.LintProblem(line, column, desc='<no description>', rule=None)

Represents a linting problem found by yamllint.

column = None

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

desc = None

Human-readable description of the problem

line = None

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

rule = None

Identifier of the rule that detected the problem, conf, filepath=None)

Lints a YAML source.

Returns a generator of LintProblem objects.

  • input – buffer, string or stream to read from
  • conf – yamllint configuration object