Add strict typing to glances (#99537)

This commit is contained in:
Rami Mosleh 2023-09-04 10:07:15 +03:00 committed by GitHub
parent 1dc724274e
commit 8d3828ae54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 3 deletions

View file

@ -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])