Improve ondilo_ico generic typing (#84738)

This commit is contained in:
Marc Mueller 2022-12-29 09:35:06 +01:00 committed by GitHub
parent b8a4399078
commit c4b45fb110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -1,6 +1,7 @@
"""API for Ondilo ICO bound to Home Assistant OAuth."""
from asyncio import run_coroutine_threadsafe
import logging
from typing import Any
from ondilo import Ondilo
@ -35,7 +36,7 @@ class OndiloClient(Ondilo):
return self.session.token
def get_all_pools_data(self) -> dict:
def get_all_pools_data(self) -> list[dict[str, Any]]:
"""Fetch pools and add pool details and last measures to pool data."""
pools = self.get_pools()

View File

@ -3,6 +3,7 @@ from __future__ import annotations
from datetime import timedelta
import logging
from typing import Any
from ondilo import OndiloError
@ -28,6 +29,7 @@ from homeassistant.helpers.update_coordinator import (
UpdateFailed,
)
from .api import OndiloClient
from .const import DOMAIN
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
@ -91,9 +93,9 @@ async def async_setup_entry(
) -> None:
"""Set up the Ondilo ICO sensors."""
api = hass.data[DOMAIN][entry.entry_id]
api: OndiloClient = hass.data[DOMAIN][entry.entry_id]
async def async_update_data():
async def async_update_data() -> list[dict[str, Any]]:
"""Fetch data from API endpoint.
This is the place to pre-process the data to lookup tables
@ -132,12 +134,14 @@ async def async_setup_entry(
async_add_entities(entities)
class OndiloICO(CoordinatorEntity, SensorEntity):
class OndiloICO(
CoordinatorEntity[DataUpdateCoordinator[list[dict[str, Any]]]], SensorEntity
):
"""Representation of a Sensor."""
def __init__(
self,
coordinator: DataUpdateCoordinator,
coordinator: DataUpdateCoordinator[list[dict[str, Any]]],
poolidx: int,
description: SensorEntityDescription,
) -> None: