Ensure that WattTime is strictly typed (#57130)

This commit is contained in:
Aaron Bach 2021-10-07 04:40:10 -06:00 committed by GitHub
parent 24fa2a714a
commit 2ba8e1030c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -122,6 +122,7 @@ homeassistant.components.uptimerobot.*
homeassistant.components.vacuum.*
homeassistant.components.vallox.*
homeassistant.components.water_heater.*
homeassistant.components.watttime.*
homeassistant.components.weather.*
homeassistant.components.websocket_api.*
homeassistant.components.zodiac.*

View File

@ -1,7 +1,7 @@
"""Support for WattTime sensors."""
from __future__ import annotations
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, cast
from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
@ -100,4 +100,4 @@ class RealtimeEmissionsSensor(CoordinatorEntity, SensorEntity):
@property
def native_value(self) -> StateType:
"""Return the value reported by the sensor."""
return self.coordinator.data[self.entity_description.key]
return cast(StateType, self.coordinator.data[self.entity_description.key])

View File

@ -1353,6 +1353,17 @@ no_implicit_optional = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.watttime.*]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.weather.*]
check_untyped_defs = true
disallow_incomplete_defs = true