From 245f5a1667033634d4069ee48b7d6915489148fd Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Tue, 26 Nov 2019 08:00:33 +0100 Subject: empty string mapping key preservation Would convert to explicit key (? '') --- emitter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'emitter.py') diff --git a/emitter.py b/emitter.py index 73fbe05..41dc3e8 100644 --- a/emitter.py +++ b/emitter.py @@ -769,7 +769,8 @@ class Emitter(object): or (isinstance(self.event, MappingStartEvent) and self.event.flow_style is True) or ( isinstance(self.event, ScalarEvent) - and not self.analysis.empty + # if there is an explicit style for an empty string, it is a simple key + and not (self.analysis.empty and self.style and self.style not in '\'"') and not self.analysis.multiline ) or self.check_empty_sequence() -- cgit v1.2.1