Sort keys in dicts in output yaml for 'config' command (#1049)

Having different output each time due to random key order makes some
tasks harder (such as CI scripts).
This commit is contained in:
Ivan Shvedunov 2020-06-09 06:10:49 +03:00 committed by GitHub
parent d1f4c2ab57
commit 64bd33a94e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -338,7 +338,7 @@ class ESPHomeDumper(yaml.SafeDumper): # pylint: disable=too-many-ancestors
self.represented_objects[self.alias_key] = node
best_style = True
if hasattr(mapping, 'items'):
mapping = list(mapping.items())
mapping = sorted(mapping.items(), key=lambda item: item[0])
for item_key, item_value in mapping:
node_key = self.represent_data(item_key)
node_value = self.represent_data(item_value)