Improve string formatting v6 (#33698)

This commit is contained in:
springstan authored and GitHub committed 2020-04-07 23:14:28 +02:00
1 parent d7e3b0b755
commit eae21be5b9
43 files changed
+81 -87

No files matched your search

+2 -2
View File
@@ -86,7 +86,7 @@ SET_ZONE_OVERRIDE_SCHEMA = vol.Schema(
vol.Coerce(float), vol.Range(min=4.0, max=35.0)
),
vol.Optional(ATTR_DURATION_UNTIL): vol.All(
cv.time_period, vol.Range(min=timedelta(days=0), max=timedelta(days=1)),
cv.time_period, vol.Range(min=timedelta(days=0), max=timedelta(days=1))
),
}
)
@@ -121,7 +121,7 @@ def convert_dict(dictionary: Dict[str, Any]) -> Dict[str, Any]:
"""Convert a string to snake_case."""
string = re.sub(r"[\-\.\s]", "_", str(key))
return (string[0]).lower() + re.sub(
r"[A-Z]", lambda matched: "_" + matched.group(0).lower(), string[1:]
r"[A-Z]", lambda matched: f"_{matched.group(0).lower()}", string[1:]
)
return {