diff --git a/.strict-typing b/.strict-typing index 2a6e9b04cbe..4a4151ce606 100644 --- a/.strict-typing +++ b/.strict-typing @@ -136,6 +136,7 @@ homeassistant.components.fully_kiosk.* homeassistant.components.geo_location.* homeassistant.components.geocaching.* homeassistant.components.gios.* +homeassistant.components.glances.* homeassistant.components.goalzero.* homeassistant.components.google.* homeassistant.components.google_sheets.* diff --git a/homeassistant/components/glances/coordinator.py b/homeassistant/components/glances/coordinator.py index 24a2e23a013..8d2bd0daaa3 100644 --- a/homeassistant/components/glances/coordinator.py +++ b/homeassistant/components/glances/coordinator.py @@ -35,6 +35,7 @@ class GlancesDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): async def _async_update_data(self) -> dict[str, Any]: """Get the latest data from the Glances REST API.""" try: - return await self.api.get_ha_sensor_data() + data = await self.api.get_ha_sensor_data() except exceptions.GlancesApiError as err: raise UpdateFailed from err + return data or {} diff --git a/homeassistant/components/glances/sensor.py b/homeassistant/components/glances/sensor.py index cd9c3a9135d..78aa5ffbf0a 100644 --- a/homeassistant/components/glances/sensor.py +++ b/homeassistant/components/glances/sensor.py @@ -2,6 +2,7 @@ from __future__ import annotations from dataclasses import dataclass +from typing import cast from homeassistant.components.sensor import ( SensorDeviceClass, @@ -346,5 +347,7 @@ class GlancesSensor(CoordinatorEntity[GlancesDataUpdateCoordinator], SensorEntit value = self.coordinator.data[self.entity_description.type] if isinstance(value.get(self._sensor_name_prefix), dict): - return value[self._sensor_name_prefix][self.entity_description.key] - return value[self.entity_description.key] + return cast( + StateType, value[self._sensor_name_prefix][self.entity_description.key] + ) + return cast(StateType, value[self.entity_description.key]) diff --git a/mypy.ini b/mypy.ini index 178b82fd359..14eb6bba841 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1122,6 +1122,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.glances.*] +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.goalzero.*] check_untyped_defs = true disallow_incomplete_defs = true