diff --git a/tests/test_spec_examples.py b/tests/test_spec_examples.py index 6ec4d39..abc51a7 100644 --- a/tests/test_spec_examples.py +++ b/tests/test_spec_examples.py @@ -110,6 +110,7 @@ conf_overrides = { 'example-8.9': ('empty-lines: {max-end: 1}\n'), 'example-8.14': ('colons: {max-spaces-before: 1}\n'), 'example-8.16': ('indentation: {spaces: 1}\n'), + 'example-8.17': ('indentation: disable\n'), } files = os.listdir('tests/yaml-1.2-spec-examples') @@ -125,9 +126,7 @@ def _gen_test(buffer, conf): # The following tests are blacklisted because they contain rarely-used formats # that yamllint does not handle yet. tmp_blacklist = ( - 'example-2.25', 'example-7.16', - 'example-8.17', 'example-8.20', 'example-8.22', 'example-10.1', diff --git a/tests/test_syntax_errors.py b/tests/test_syntax_errors.py index 6a94261..bd4ddd2 100644 --- a/tests/test_syntax_errors.py +++ b/tests/test_syntax_errors.py @@ -75,3 +75,20 @@ class YamlLintTestCase(RuleTestCase): ' Atlanta Braves]\n' ': [2001-07-02, 2001-08-12,\n' ' 2001-08-14]\n', None) + + def test_sets(self): + self.check('---\n' + '? key one\n' + '? key two\n' + '? [non, scalar, key]\n' + '? key with value\n' + ': value\n' + '...\n', None) + self.check('---\n' + '? - multi\n' + ' - line\n' + ' - keys\n' + '? in:\n' + ' a:\n' + ' set\n' + '...\n', None) diff --git a/yamllint/rules/indentation.py b/yamllint/rules/indentation.py index 7d03ab4..60b880c 100644 --- a/yamllint/rules/indentation.py +++ b/yamllint/rules/indentation.py @@ -413,3 +413,12 @@ def check(conf, token, prev, next, context): indent = context['stack'][-1].indent + conf['spaces'] context['stack'].append(Parent(VAL, indent)) + + if (context['stack'][-1].type == KEY and + isinstance(next, (yaml.BlockEndToken, + yaml.FlowMappingEndToken, + yaml.FlowSequenceEndToken, + yaml.KeyToken))): + # A key without a value: it's part of a set. Let's drop this key + # and leave room for the next one. + context['stack'].pop()