mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Make CoordinatorEntity generic (#49854)
This commit is contained in:
parent
dc46a213a7
commit
f53284b200
@ -6,7 +6,7 @@ from collections.abc import Awaitable
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
from time import monotonic
|
||||
from typing import Any, Callable, Generic, TypeVar
|
||||
from typing import Callable, Generic, TypeVar
|
||||
import urllib.error
|
||||
|
||||
import aiohttp
|
||||
@ -25,8 +25,6 @@ REQUEST_REFRESH_DEFAULT_IMMEDIATE = True
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
# mypy: disallow-any-generics
|
||||
|
||||
|
||||
class UpdateFailed(Exception):
|
||||
"""Raised when an update has failed."""
|
||||
@ -294,10 +292,10 @@ class DataUpdateCoordinator(Generic[T]):
|
||||
self._unsub_refresh = None
|
||||
|
||||
|
||||
class CoordinatorEntity(entity.Entity):
|
||||
class CoordinatorEntity(Generic[T], entity.Entity):
|
||||
"""A class for entities using DataUpdateCoordinator."""
|
||||
|
||||
def __init__(self, coordinator: DataUpdateCoordinator[Any]) -> None:
|
||||
def __init__(self, coordinator: DataUpdateCoordinator[T]) -> None:
|
||||
"""Create the entity with a DataUpdateCoordinator."""
|
||||
self.coordinator = coordinator
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user