Add strict typing to glances (#99537)
This commit is contained in:
parent
1dc724274e
commit
8d3828ae54
4 changed files with 18 additions and 3 deletions
|
@ -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])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue