Extract instance ID helper from updater (#35043)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2020-05-04 11:23:12 -07:00
1 parent b3e637ca7a
commit e54e9279e3
8 files changed
+72 -37

No files matched your search

+2
View File
@@ -4,6 +4,7 @@ import functools
from typing import Awaitable, Callable, TypeVar, cast
from homeassistant.core import HomeAssistant
from homeassistant.loader import bind_hass
T = TypeVar("T")
@@ -19,6 +20,7 @@ def singleton(data_key: str) -> Callable[[FUNC], FUNC]:
def wrapper(func: FUNC) -> FUNC:
"""Wrap a function with caching logic."""
@bind_hass
@functools.wraps(func)
async def wrapped(hass: HomeAssistant) -> T:
obj_or_evt = hass.data.get(data_key)