diff --git a/esphome/config_validation.py b/esphome/config_validation.py index c6ce33dd23..1e54c04fe5 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -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: diff --git a/esphome/core.py b/esphome/core.py index 9b0b8cefa3..0065b750c4 100644 --- a/esphome/core.py +++ b/esphome/core.py @@ -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 diff --git a/esphome/voluptuous_schema.py b/esphome/voluptuous_schema.py index c30447a427..ce13f0ceb0 100644 --- a/esphome/voluptuous_schema.py +++ b/esphome/voluptuous_schema.py @@ -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 = {} diff --git a/esphome/yaml_util.py b/esphome/yaml_util.py index 1758e739db..053fba6274 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 = 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) diff --git a/pylintrc b/pylintrc index c65a9a7cd9..00ffdc9f9a 100644 --- a/pylintrc +++ b/pylintrc @@ -25,3 +25,6 @@ disable= stop-iteration-return, no-self-use, import-outside-toplevel, + # Broken + unsupported-membership-test, + unsubscriptable-object,