Don't treat non-importable YAML as syntax error

`yaml.load()` exceptions are not necessarily syntax errors. For
instance, the following YAML source cannot be `load()`ed into a Python
object, but is valid nonetheless:

    ? - Detroit Tigers
      - Chicago cubs
    :
      - 2001-07-23

    ? [ New York Yankees,
        Atlanta Braves ]
    : [ 2001-07-02, 2001-08-12,
        2001-08-14 ]

This commit detects syntax errors from `yaml.parse()` exceptions rather
than `yaml.load_all()`.
This commit is contained in:
Adrien Vergé
2016-01-15 18:08:25 +01:00
parent 1934206cef
commit 97e2210ec9
2 changed files with 15 additions and 1 deletions

View File

@@ -58,7 +58,7 @@ def get_costemic_problems(buffer, conf):
def get_syntax_error(buffer):
try:
list(yaml.safe_load_all(buffer))
list(yaml.parse(buffer))
except yaml.error.MarkedYAMLError as e:
problem = LintProblem(e.problem_mark.line + 1,
e.problem_mark.column + 1,