From c7609ba5e7b7c5cc2216138bbc504e7a23998511 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Mon, 22 Apr 2019 22:14:30 +0200 Subject: [PATCH] Lint --- esphome/automation.py | 2 +- esphome/yaml_util.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/esphome/automation.py b/esphome/automation.py index 0f1f3a0c3f..16bdf0daf9 100644 --- a/esphome/automation.py +++ b/esphome/automation.py @@ -80,7 +80,7 @@ def validate_automation(extra_schema=None, extra_validators=None, single=False): except cv.Invalid as err2: if u'Unable to find action' in str(err): raise err2 - raise cv.MultipleInvalid([err, err2]) + raise cv.MultipleInvalid([err, err2]) elif isinstance(value, dict): if CONF_THEN in value: return [schema(value)] diff --git a/esphome/yaml_util.py b/esphome/yaml_util.py index 91df60ecbc..30e8bb82de 100644 --- a/esphome/yaml_util.py +++ b/esphome/yaml_util.py @@ -3,6 +3,7 @@ from __future__ import print_function import fnmatch import functools import logging +import math import os import uuid @@ -411,13 +412,10 @@ class ESPHomeDumper(yaml.SafeDumper): # pylint: disable=too-many-ancestors def represent_float(self, value): if is_secret(value): return self.represent_secret(value) - # pylint: disable=comparison-with-itself - if value != value or (value == 0.0 and value == 1.0): + if math.isnan(value): value = u'.nan' - elif value == self.inf_value: - value = u'.inf' - elif value == -self.inf_value: - value = u'-.inf' + elif math.isinf(value): + value = u'.inf' if value > 0 else u'-.inf' else: value = text_type(repr(value)).lower() # Note that in some cases `repr(data)` represents a float number