mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Enable strict typing for doorbird (#98778)
This commit is contained in:
parent
d0d160f11c
commit
d582e60a6e
@ -104,6 +104,7 @@ homeassistant.components.dhcp.*
|
||||
homeassistant.components.diagnostics.*
|
||||
homeassistant.components.dlna_dmr.*
|
||||
homeassistant.components.dnsip.*
|
||||
homeassistant.components.doorbird.*
|
||||
homeassistant.components.dormakaba_dkey.*
|
||||
homeassistant.components.dsmr.*
|
||||
homeassistant.components.dunehd.*
|
||||
|
@ -157,7 +157,9 @@ async def _update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
|
||||
|
||||
@callback
|
||||
def _async_import_options_from_data_if_missing(hass: HomeAssistant, entry: ConfigEntry):
|
||||
def _async_import_options_from_data_if_missing(
|
||||
hass: HomeAssistant, entry: ConfigEntry
|
||||
) -> None:
|
||||
options = dict(entry.options)
|
||||
modified = False
|
||||
for importable_option in (CONF_EVENTS,):
|
||||
|
@ -87,7 +87,7 @@ class DoorBirdCamera(DoorBirdEntity, Camera):
|
||||
self._last_update = datetime.datetime.min
|
||||
self._attr_unique_id = f"{self._mac_addr}_{camera_id}"
|
||||
|
||||
async def stream_source(self):
|
||||
async def stream_source(self) -> str | None:
|
||||
"""Return the stream source."""
|
||||
return self._stream_url
|
||||
|
||||
|
@ -23,7 +23,9 @@ from .util import get_mac_address_from_door_station_info
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _schema_with_defaults(host=None, name=None):
|
||||
def _schema_with_defaults(
|
||||
host: str | None = None, name: str | None = None
|
||||
) -> vol.Schema:
|
||||
return vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_HOST, default=host): str,
|
||||
@ -39,7 +41,9 @@ def _check_device(device: DoorBird) -> tuple[tuple[bool, int], dict[str, Any]]:
|
||||
return device.ready(), device.info()
|
||||
|
||||
|
||||
async def validate_input(hass: core.HomeAssistant, data):
|
||||
async def validate_input(
|
||||
hass: core.HomeAssistant, data: dict[str, Any]
|
||||
) -> dict[str, str]:
|
||||
"""Validate the user input allows us to connect."""
|
||||
device = DoorBird(data[CONF_HOST], data[CONF_USERNAME], data[CONF_PASSWORD])
|
||||
try:
|
||||
@ -78,13 +82,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
VERSION = 1
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
"""Initialize the DoorBird config flow."""
|
||||
self.discovery_schema = {}
|
||||
self.discovery_schema: vol.Schema | None = None
|
||||
|
||||
async def async_step_user(self, user_input=None):
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors = {}
|
||||
errors: dict[str, str] = {}
|
||||
if user_input is not None:
|
||||
info, errors = await self._async_validate_or_error(user_input)
|
||||
if not errors:
|
||||
@ -128,7 +134,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return await self.async_step_user()
|
||||
|
||||
async def _async_validate_or_error(self, user_input):
|
||||
async def _async_validate_or_error(
|
||||
self, user_input: dict[str, Any]
|
||||
) -> tuple[dict[str, Any], dict[str, Any]]:
|
||||
"""Validate doorbird or error."""
|
||||
errors = {}
|
||||
info = {}
|
||||
@ -159,7 +167,9 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
"""Initialize options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(self, user_input=None):
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle options flow."""
|
||||
if user_input is not None:
|
||||
events = [event.strip() for event in user_input[CONF_EVENTS].split(",")]
|
||||
|
@ -2,7 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import Any, cast
|
||||
|
||||
from doorbirdpy import DoorBird
|
||||
|
||||
@ -131,7 +131,7 @@ class ConfiguredDoorBird:
|
||||
|
||||
for fav_id in favs["http"]:
|
||||
if favs["http"][fav_id]["value"] == url:
|
||||
return fav_id
|
||||
return cast(str, fav_id)
|
||||
|
||||
return None
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Describe logbook events."""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
|
||||
from homeassistant.components.logbook import (
|
||||
LOGBOOK_ENTRY_ENTITY_ID,
|
||||
LOGBOOK_ENTRY_MESSAGE,
|
||||
@ -14,11 +16,16 @@ from .models import DoorBirdData
|
||||
|
||||
|
||||
@callback
|
||||
def async_describe_events(hass: HomeAssistant, async_describe_event):
|
||||
def async_describe_events(
|
||||
hass: HomeAssistant,
|
||||
async_describe_event: Callable[
|
||||
[str, str, Callable[[Event], dict[str, str | None]]], None
|
||||
],
|
||||
) -> None:
|
||||
"""Describe logbook events."""
|
||||
|
||||
@callback
|
||||
def async_describe_logbook_event(event: Event):
|
||||
def async_describe_logbook_event(event: Event) -> dict[str, str | None]:
|
||||
"""Describe a logbook event."""
|
||||
return {
|
||||
LOGBOOK_ENTRY_NAME: "Doorbird",
|
||||
|
10
mypy.ini
10
mypy.ini
@ -802,6 +802,16 @@ disallow_untyped_defs = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.doorbird.*]
|
||||
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.dormakaba_dkey.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user