Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a68c3aa69e | ||
|
|
7f2c071545 |
@@ -3,7 +3,7 @@ name = "yamllint"
|
|||||||
description = "A linter for YAML files."
|
description = "A linter for YAML files."
|
||||||
readme = {file = "README.rst", content-type = "text/x-rst"}
|
readme = {file = "README.rst", content-type = "text/x-rst"}
|
||||||
requires-python = ">=3.7"
|
requires-python = ">=3.7"
|
||||||
license = {text = "GPL-3.0-only"}
|
license = {text = "GPL-3.0-or-later"}
|
||||||
authors = [{name = "Adrien Vergé"}]
|
authors = [{name = "Adrien Vergé"}]
|
||||||
keywords = ["yaml", "lint", "linter", "syntax", "checker"]
|
keywords = ["yaml", "lint", "linter", "syntax", "checker"]
|
||||||
classifiers = [
|
classifiers = [
|
||||||
|
|||||||
@@ -71,3 +71,22 @@ class DocumentEndTestCase(RuleTestCase):
|
|||||||
'---\n'
|
'---\n'
|
||||||
'third: document\n'
|
'third: document\n'
|
||||||
'...\n', conf, problem=(6, 1))
|
'...\n', conf, problem=(6, 1))
|
||||||
|
|
||||||
|
def test_directives(self):
|
||||||
|
conf = 'document-end: {present: true}'
|
||||||
|
self.check('%YAML 1.2\n'
|
||||||
|
'---\n'
|
||||||
|
'document: end\n'
|
||||||
|
'...\n', conf)
|
||||||
|
self.check('%YAML 1.2\n'
|
||||||
|
'%TAG ! tag:clarkevans.com,2002:\n'
|
||||||
|
'---\n'
|
||||||
|
'document: end\n'
|
||||||
|
'...\n', conf)
|
||||||
|
self.check('---\n'
|
||||||
|
'first: document\n'
|
||||||
|
'...\n'
|
||||||
|
'%YAML 1.2\n'
|
||||||
|
'---\n'
|
||||||
|
'second: document\n'
|
||||||
|
'...\n', conf)
|
||||||
|
|||||||
@@ -99,11 +99,13 @@ def check(conf, token, prev, next, nextnext, context):
|
|||||||
prev_is_end_or_stream_start = isinstance(
|
prev_is_end_or_stream_start = isinstance(
|
||||||
prev, (yaml.DocumentEndToken, yaml.StreamStartToken)
|
prev, (yaml.DocumentEndToken, yaml.StreamStartToken)
|
||||||
)
|
)
|
||||||
|
prev_is_directive = isinstance(prev, yaml.DirectiveToken)
|
||||||
|
|
||||||
if is_stream_end and not prev_is_end_or_stream_start:
|
if is_stream_end and not prev_is_end_or_stream_start:
|
||||||
yield LintProblem(token.start_mark.line, 1,
|
yield LintProblem(token.start_mark.line, 1,
|
||||||
'missing document end "..."')
|
'missing document end "..."')
|
||||||
elif is_start and not prev_is_end_or_stream_start:
|
elif is_start and not (prev_is_end_or_stream_start
|
||||||
|
or prev_is_directive):
|
||||||
yield LintProblem(token.start_mark.line + 1, 1,
|
yield LintProblem(token.start_mark.line + 1, 1,
|
||||||
'missing document end "..."')
|
'missing document end "..."')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user