From d82e29168895af0fa15c6280b76ed1712bee9b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Alet?= Date: Fri, 15 Apr 2022 08:12:02 +1100 Subject: [PATCH] Don't break on empty stack --- yamllint/rules/key_duplicates.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yamllint/rules/key_duplicates.py b/yamllint/rules/key_duplicates.py index bd38b14..af294c9 100644 --- a/yamllint/rules/key_duplicates.py +++ b/yamllint/rules/key_duplicates.py @@ -84,7 +84,8 @@ def check(conf, token, prev, next, nextnext, context): elif isinstance(token, (yaml.BlockEndToken, yaml.FlowMappingEndToken, yaml.FlowSequenceEndToken)): - context['stack'].pop() + if len(context['stack']) > 0: + context['stack'].pop() elif (isinstance(token, yaml.KeyToken) and isinstance(next, yaml.ScalarToken)): # This check is done because KeyTokens can be found inside flow