Extract instance ID helper from updater (#35043)

This commit is contained in:
Paulus Schoutsen 2020-05-04 11:23:12 -07:00 committed by GitHub
parent b3e637ca7a
commit e54e9279e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 72 additions and 37 deletions

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)