mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Speed up async_render_with_possible_json_value (#118080)
This commit is contained in:
parent
3416162fdb
commit
5cb3bc19c0
@ -7,7 +7,7 @@ import asyncio
|
||||
import base64
|
||||
import collections.abc
|
||||
from collections.abc import Callable, Generator, Iterable
|
||||
from contextlib import AbstractContextManager, suppress
|
||||
from contextlib import AbstractContextManager
|
||||
from contextvars import ContextVar
|
||||
from datetime import date, datetime, time, timedelta
|
||||
from functools import cache, lru_cache, partial, wraps
|
||||
@ -759,8 +759,10 @@ class Template:
|
||||
variables = dict(variables or {})
|
||||
variables["value"] = value
|
||||
|
||||
with suppress(*JSON_DECODE_EXCEPTIONS):
|
||||
try: # noqa: SIM105 - suppress is much slower
|
||||
variables["value_json"] = json_loads(value)
|
||||
except JSON_DECODE_EXCEPTIONS:
|
||||
pass
|
||||
|
||||
try:
|
||||
render_result = _render_with_context(
|
||||
|
Loading…
x
Reference in New Issue
Block a user