From 64bd33a94eb723ea882d4afa36360780fea3cfb8 Mon Sep 17 00:00:00 2001 From: Ivan Shvedunov Date: Tue, 9 Jun 2020 06:10:49 +0300 Subject: [PATCH] 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). --- esphome/yaml_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/yaml_util.py b/esphome/yaml_util.py index 053fba6274..1758e739db 100644 --- a/esphome/yaml_util.py +++ b/esphome/yaml_util.py @@ -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)