mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
Add strict typing to Skybell (#79800)
This commit is contained in:
@ -232,6 +232,7 @@ homeassistant.components.sensor.*
|
||||
homeassistant.components.senz.*
|
||||
homeassistant.components.shelly.*
|
||||
homeassistant.components.simplisafe.*
|
||||
homeassistant.components.skybell.*
|
||||
homeassistant.components.slack.*
|
||||
homeassistant.components.sleepiq.*
|
||||
homeassistant.components.smhi.*
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
from datetime import datetime
|
||||
|
||||
from aioskybell import SkybellDevice
|
||||
from aioskybell.helpers import const as CONST
|
||||
@ -17,15 +17,23 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
from .entity import DOMAIN, SkybellEntity
|
||||
|
||||
|
||||
@dataclass
|
||||
class SkybellSensorEntityDescription(SensorEntityDescription):
|
||||
"""Class to describe a Skybell sensor."""
|
||||
class SkybellSensorEntityDescriptionMixIn:
|
||||
"""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, ...] = (
|
||||
@ -110,6 +118,6 @@ class SkybellSensor(SkybellEntity, SensorEntity):
|
||||
entity_description: SkybellSensorEntityDescription
|
||||
|
||||
@property
|
||||
def native_value(self) -> int:
|
||||
def native_value(self) -> StateType | datetime:
|
||||
"""Return the state of the sensor."""
|
||||
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_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.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
Reference in New Issue
Block a user