Rules: indentation: Handle sets

Sets are like mappings, that do not contain values. Example:

    set:
      ? key one
      ? key two
      ? [non, scalar, key]
This commit is contained in:
Adrien Vergé
2016-02-01 17:52:46 +01:00
parent 431a379c81
commit 68618be4cc
3 changed files with 27 additions and 2 deletions

View File

@@ -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()