Rewrite syntax errors handling and test them

If a syntax errors occurs at the same place than a regular yamllint rule
error, only the yamllint one is issued.
This commit is contained in:
Adrien Vergé
2016-01-12 23:20:33 +01:00
parent bf96bdde01
commit 07c5b4177c
4 changed files with 68 additions and 26 deletions

View File

@@ -16,8 +16,6 @@
import yaml
from yamllint.errors import LintProblem
class Line(object):
def __init__(self, line_no, buffer, start, end):
@@ -85,11 +83,3 @@ def token_or_line_generator(buffer):
else:
yield token
token = next(token_gen, None)
def get_syntax_error(buffer):
try:
yaml.safe_load_all(buffer)
except yaml.error.MarkedYAMLError as e:
return LintProblem(e.problem_mark.line + 1, e.problem_mark.column + 1,
'syntax error: ' + e.problem)