Generate: improve duplicate key feedback by providing duplicate text, line and column

This commit is contained in:
Fabian Dill 2022-01-25 04:20:08 +01:00
parent 0800cfccb6
commit 1b3b0f199d
1 changed files with 2 additions and 1 deletions

View File

@ -125,7 +125,8 @@ class UniqueKeyLoader(SafeLoader):
for key_node, value_node in node.value:
key = self.construct_object(key_node, deep=deep)
if key in mapping:
raise KeyError(f"Duplicate key {key!r} found in YAML. Already found keys: {mapping}.")
logging.error(f"YAML duplicates sanity check failed{key_node.start_mark}")
raise KeyError(f"Duplicate key {key} found in YAML. Already found keys: {mapping}.")
mapping.add(key)
return super().construct_mapping(node, deep)