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

This commit is contained in:
Otto Winter 2020-07-25 14:21:56 +02:00 committed by GitHub
parent 32efa5d83e
commit 55388724af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 18 deletions

View File

@ -186,6 +186,7 @@ def ensure_list(*validators):
None and empty dictionaries are converted to empty lists.
"""
user = All(*validators)
list_schema = Schema([user])
def validator(value):
check_not_templatable(value)
@ -193,19 +194,7 @@ def ensure_list(*validators):
return []
if not isinstance(value, list):
return [user(value)]
ret = []
errs = []
for i, val in enumerate(value):
try:
with prepend_path([i]):
ret.append(user(val))
except MultipleInvalid as err:
errs.extend(err.errors)
except Invalid as err:
errs.append(err)
if errs:
raise MultipleInvalid(errs)
return ret
return list_schema(value)
return validator
@ -811,6 +800,7 @@ def mqtt_qos(value):
def requires_component(comp):
"""Validate that this option can only be specified when the component `comp` is loaded."""
# pylint: disable=unsupported-membership-test
def validator(value):
# pylint: disable=unsupported-membership-test
if comp not in CORE.raw_config:

View File

@ -553,7 +553,6 @@ class EsphomeCore:
if self.config is None:
raise ValueError("Config has not been loaded yet")
# pylint: disable=unsupported-membership-test,unsubscriptable-object
if 'wifi' in self.config:
return self.config[CONF_WIFI][CONF_USE_ADDRESS]
@ -567,7 +566,6 @@ class EsphomeCore:
if self.config is None:
raise ValueError("Config has not been loaded yet")
# pylint: disable=unsubscriptable-object
if CONF_COMMENT in self.config[CONF_ESPHOME]:
return self.config[CONF_ESPHOME][CONF_COMMENT]
@ -584,7 +582,6 @@ class EsphomeCore:
if self.config is None:
raise ValueError("Config has not been loaded yet")
# pylint: disable=unsubscriptable-object
return self.config[CONF_ESPHOME][CONF_ARDUINO_VERSION]
@property

View File

@ -52,7 +52,8 @@ class _Schema(vol.Schema):
all_required_keys = {key for key in schema if isinstance(key, vol.Required)}
# Keys that may have defaults
all_default_keys = {key for key in schema if isinstance(key, vol.Optional)}
# This is a list because sets do not guarantee insertion order
all_default_keys = [key for key in schema if isinstance(key, vol.Optional)]
# Recursively compile schema
_compiled_schema = {}

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 = sorted(mapping.items(), key=lambda item: item[0])
mapping = list(mapping.items())
for item_key, item_value in mapping:
node_key = self.represent_data(item_key)
node_value = self.represent_data(item_value)

View File

@ -25,3 +25,6 @@ disable=
stop-iteration-return,
no-self-use,
import-outside-toplevel,
# Broken
unsupported-membership-test,
unsubscriptable-object,