diff --git a/.strict-typing b/.strict-typing index 439831790b0..6b2c52f42f6 100644 --- a/.strict-typing +++ b/.strict-typing @@ -261,6 +261,7 @@ homeassistant.components.persistent_notification.* homeassistant.components.pi_hole.* homeassistant.components.ping.* homeassistant.components.plugwise.* +homeassistant.components.poolsense.* homeassistant.components.powerwall.* homeassistant.components.private_ble_device.* homeassistant.components.proximity.* diff --git a/homeassistant/components/poolsense/binary_sensor.py b/homeassistant/components/poolsense/binary_sensor.py index 56e417511bd..052a205a37b 100644 --- a/homeassistant/components/poolsense/binary_sensor.py +++ b/homeassistant/components/poolsense/binary_sensor.py @@ -48,6 +48,6 @@ class PoolSenseBinarySensor(PoolSenseEntity, BinarySensorEntity): """Representation of PoolSense binary sensors.""" @property - def is_on(self): + def is_on(self) -> bool: """Return true if the binary sensor is on.""" return self.coordinator.data[self.entity_description.key] == "red" diff --git a/homeassistant/components/poolsense/config_flow.py b/homeassistant/components/poolsense/config_flow.py index 6a6708b4045..64685d67035 100644 --- a/homeassistant/components/poolsense/config_flow.py +++ b/homeassistant/components/poolsense/config_flow.py @@ -1,11 +1,13 @@ """Config flow for PoolSense integration.""" import logging +from typing import Any from poolsense import PoolSense import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_EMAIL, CONF_PASSWORD +from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import aiohttp_client from .const import DOMAIN @@ -21,7 +23,9 @@ class PoolSenseConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): def __init__(self) -> None: """Initialize PoolSense config flow.""" - async def async_step_user(self, user_input=None): + async def async_step_user( + self, user_input: dict[str, Any] | None = None + ) -> FlowResult: """Handle the initial step.""" errors = {} diff --git a/homeassistant/components/poolsense/coordinator.py b/homeassistant/components/poolsense/coordinator.py index 3a5089b5022..e5e3e6ad1bd 100644 --- a/homeassistant/components/poolsense/coordinator.py +++ b/homeassistant/components/poolsense/coordinator.py @@ -6,8 +6,11 @@ import logging from poolsense import PoolSense from poolsense.exceptions import PoolSenseError +from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_EMAIL, CONF_PASSWORD +from homeassistant.core import HomeAssistant from homeassistant.helpers import aiohttp_client +from homeassistant.helpers.typing import StateType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .const import DOMAIN @@ -15,10 +18,10 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) -class PoolSenseDataUpdateCoordinator(DataUpdateCoordinator): +class PoolSenseDataUpdateCoordinator(DataUpdateCoordinator[dict[str, StateType]]): """Define an object to hold PoolSense data.""" - def __init__(self, hass, entry): + def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None: """Initialize.""" self.poolsense = PoolSense( aiohttp_client.async_get_clientsession(hass), @@ -26,11 +29,10 @@ class PoolSenseDataUpdateCoordinator(DataUpdateCoordinator): entry.data[CONF_PASSWORD], ) self.hass = hass - self.entry = entry super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=timedelta(hours=1)) - async def _async_update_data(self): + async def _async_update_data(self) -> dict[str, StateType]: """Update data via library.""" data = {} async with asyncio.timeout(10): diff --git a/homeassistant/components/poolsense/entity.py b/homeassistant/components/poolsense/entity.py index 2186d815135..0eca39cc48d 100644 --- a/homeassistant/components/poolsense/entity.py +++ b/homeassistant/components/poolsense/entity.py @@ -3,14 +3,20 @@ from homeassistant.helpers.entity import EntityDescription from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import ATTRIBUTION +from .coordinator import PoolSenseDataUpdateCoordinator -class PoolSenseEntity(CoordinatorEntity): +class PoolSenseEntity(CoordinatorEntity[PoolSenseDataUpdateCoordinator]): """Implements a common class elements representing the PoolSense component.""" _attr_attribution = ATTRIBUTION - def __init__(self, coordinator, email, description: EntityDescription) -> None: + def __init__( + self, + coordinator: PoolSenseDataUpdateCoordinator, + email: str, + description: EntityDescription, + ) -> None: """Initialize poolsense sensor.""" super().__init__(coordinator) self.entity_description = description diff --git a/homeassistant/components/poolsense/sensor.py b/homeassistant/components/poolsense/sensor.py index eee7518e6da..ed120562374 100644 --- a/homeassistant/components/poolsense/sensor.py +++ b/homeassistant/components/poolsense/sensor.py @@ -15,6 +15,7 @@ from homeassistant.const import ( ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import StateType from .const import DOMAIN from .entity import PoolSenseEntity @@ -93,6 +94,6 @@ class PoolSenseSensor(PoolSenseEntity, SensorEntity): """Sensor representing poolsense data.""" @property - def native_value(self): + def native_value(self) -> StateType: """State of the sensor.""" return self.coordinator.data[self.entity_description.key] diff --git a/mypy.ini b/mypy.ini index f18e781fd23..c2ecac66946 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2372,6 +2372,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.poolsense.*] +check_untyped_defs = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +warn_return_any = true +warn_unreachable = true + [mypy-homeassistant.components.powerwall.*] check_untyped_defs = true disallow_incomplete_defs = true