mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add strict typing to Skybell (#79800)
This commit is contained in:
parent
e1d3ba6ff1
commit
9850709b37
@ -232,6 +232,7 @@ homeassistant.components.sensor.*
|
|||||||
homeassistant.components.senz.*
|
homeassistant.components.senz.*
|
||||||
homeassistant.components.shelly.*
|
homeassistant.components.shelly.*
|
||||||
homeassistant.components.simplisafe.*
|
homeassistant.components.simplisafe.*
|
||||||
|
homeassistant.components.skybell.*
|
||||||
homeassistant.components.slack.*
|
homeassistant.components.slack.*
|
||||||
homeassistant.components.sleepiq.*
|
homeassistant.components.sleepiq.*
|
||||||
homeassistant.components.smhi.*
|
homeassistant.components.smhi.*
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any
|
from datetime import datetime
|
||||||
|
|
||||||
from aioskybell import SkybellDevice
|
from aioskybell import SkybellDevice
|
||||||
from aioskybell.helpers import const as CONST
|
from aioskybell.helpers import const as CONST
|
||||||
@ -17,15 +17,23 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from .entity import DOMAIN, SkybellEntity
|
from .entity import DOMAIN, SkybellEntity
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class SkybellSensorEntityDescription(SensorEntityDescription):
|
class SkybellSensorEntityDescriptionMixIn:
|
||||||
"""Class to describe a Skybell sensor."""
|
"""Mixin for Skybell sensor."""
|
||||||
|
|
||||||
value_fn: Callable[[SkybellDevice], Any] = lambda val: val
|
value_fn: Callable[[SkybellDevice], StateType | datetime]
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class SkybellSensorEntityDescription(
|
||||||
|
SensorEntityDescription, SkybellSensorEntityDescriptionMixIn
|
||||||
|
):
|
||||||
|
"""Class to describe a Skybell sensor."""
|
||||||
|
|
||||||
|
|
||||||
SENSOR_TYPES: tuple[SkybellSensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[SkybellSensorEntityDescription, ...] = (
|
||||||
@ -110,6 +118,6 @@ class SkybellSensor(SkybellEntity, SensorEntity):
|
|||||||
entity_description: SkybellSensorEntityDescription
|
entity_description: SkybellSensorEntityDescription
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> int:
|
def native_value(self) -> StateType | datetime:
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self.entity_description.value_fn(self._device)
|
return self.entity_description.value_fn(self._device)
|
||||||
|
10
mypy.ini
10
mypy.ini
@ -2072,6 +2072,16 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.skybell.*]
|
||||||
|
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.slack.*]
|
[mypy-homeassistant.components.slack.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user