Tweak template digit detection (#43621)
parent
c4108d4ef1
commit
793fdb5317
|
@ -50,7 +50,7 @@ _ENVIRONMENT = "template.environment"
|
||||||
|
|
||||||
_RE_JINJA_DELIMITERS = re.compile(r"\{%|\{\{|\{#")
|
_RE_JINJA_DELIMITERS = re.compile(r"\{%|\{\{|\{#")
|
||||||
# Match "simple" ints and floats. -1.0, 1, +5, 5.0
|
# Match "simple" ints and floats. -1.0, 1, +5, 5.0
|
||||||
_IS_NUMERIC = re.compile(r"^[+-]?\d*(?:\.\d*)?$")
|
_IS_NUMERIC = re.compile(r"^[+-]?(?!0\d)\d*(?:\.\d*)?$")
|
||||||
|
|
||||||
_RESERVED_NAMES = {"contextfunction", "evalcontextfunction", "environmentfunction"}
|
_RESERVED_NAMES = {"contextfunction", "evalcontextfunction", "environmentfunction"}
|
||||||
|
|
||||||
|
|
|
@ -2421,11 +2421,17 @@ async def test_parse_result(hass):
|
||||||
("1e+100", "1e+100"),
|
("1e+100", "1e+100"),
|
||||||
("0xface", "0xface"),
|
("0xface", "0xface"),
|
||||||
("123", 123),
|
("123", 123),
|
||||||
|
("10", 10),
|
||||||
("123.0", 123.0),
|
("123.0", 123.0),
|
||||||
(".5", 0.5),
|
(".5", 0.5),
|
||||||
|
("0.5", 0.5),
|
||||||
("-1", -1),
|
("-1", -1),
|
||||||
("-1.0", -1.0),
|
("-1.0", -1.0),
|
||||||
("+1", 1),
|
("+1", 1),
|
||||||
("5.", 5.0),
|
("5.", 5.0),
|
||||||
|
("123_123_123", "123_123_123"),
|
||||||
|
# ("+48100200300", "+48100200300"), # phone number
|
||||||
|
("010", "010"),
|
||||||
|
("0011101.00100001010001", "0011101.00100001010001"),
|
||||||
):
|
):
|
||||||
assert template.Template(tpl, hass).async_render() == result
|
assert template.Template(tpl, hass).async_render() == result
|
||||||
|
|
Loading…
Reference in New Issue