mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Enable strict typing for HEOS (#136797)
This commit is contained in:
parent
a2b5a96bc9
commit
a135b4bb43
@ -228,6 +228,7 @@ homeassistant.components.guardian.*
|
||||
homeassistant.components.habitica.*
|
||||
homeassistant.components.hardkernel.*
|
||||
homeassistant.components.hardware.*
|
||||
homeassistant.components.heos.*
|
||||
homeassistant.components.here_travel_time.*
|
||||
homeassistant.components.history.*
|
||||
homeassistant.components.history_stats.*
|
||||
|
@ -40,7 +40,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: HeosConfigEntry) -> bool
|
||||
):
|
||||
for domain, player_id in device.identifiers:
|
||||
if domain == DOMAIN and not isinstance(player_id, str):
|
||||
device_registry.async_update_device(
|
||||
device_registry.async_update_device( # type: ignore[unreachable]
|
||||
device.id, new_identifiers={(DOMAIN, str(player_id))}
|
||||
)
|
||||
break
|
||||
|
@ -8,6 +8,7 @@ entities to update. Entities subscribe to entity-specific updates within the ent
|
||||
from collections.abc import Callable, Sequence
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pyheos import (
|
||||
Credentials,
|
||||
@ -23,7 +24,7 @@ from pyheos import (
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform
|
||||
from homeassistant.core import HassJob, HomeAssistant, callback
|
||||
from homeassistant.core import CALLBACK_TYPE, HassJob, HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.helpers.event import async_call_later
|
||||
@ -106,7 +107,9 @@ class HeosCoordinator(DataUpdateCoordinator[None]):
|
||||
await self.heos.disconnect()
|
||||
await super().async_shutdown()
|
||||
|
||||
def async_add_listener(self, update_callback, context=None) -> Callable[[], None]:
|
||||
def async_add_listener(
|
||||
self, update_callback: CALLBACK_TYPE, context: Any = None
|
||||
) -> Callable[[], None]:
|
||||
"""Add a listener for the coordinator."""
|
||||
remove_listener = super().async_add_listener(update_callback, context)
|
||||
# Update entities so group_member entity_ids fully populate.
|
||||
|
@ -135,7 +135,7 @@ class HeosMediaPlayer(CoordinatorEntity[HeosCoordinator], MediaPlayerEntity):
|
||||
|
||||
def __init__(self, coordinator: HeosCoordinator, player: HeosPlayer) -> None:
|
||||
"""Initialize."""
|
||||
self._media_position_updated_at = None
|
||||
self._media_position_updated_at: datetime | None = None
|
||||
self._player: HeosPlayer = player
|
||||
self._attr_unique_id = str(player.player_id)
|
||||
model_parts = player.model.split(maxsplit=1)
|
||||
@ -151,7 +151,7 @@ class HeosMediaPlayer(CoordinatorEntity[HeosCoordinator], MediaPlayerEntity):
|
||||
)
|
||||
super().__init__(coordinator, context=player.player_id)
|
||||
|
||||
async def _player_update(self, event):
|
||||
async def _player_update(self, event: str) -> None:
|
||||
"""Handle player attribute updated."""
|
||||
if event == heos_const.EVENT_PLAYER_NOW_PLAYING_PROGRESS:
|
||||
self._media_position_updated_at = utcnow()
|
||||
|
@ -64,4 +64,4 @@ rules:
|
||||
inject-websession:
|
||||
status: done
|
||||
comment: The integration does not use websession
|
||||
strict-typing: todo
|
||||
strict-typing: done
|
||||
|
@ -28,7 +28,7 @@ HEOS_SIGN_IN_SCHEMA = vol.Schema(
|
||||
HEOS_SIGN_OUT_SCHEMA = vol.Schema({})
|
||||
|
||||
|
||||
def register(hass: HomeAssistant):
|
||||
def register(hass: HomeAssistant) -> None:
|
||||
"""Register HEOS services."""
|
||||
hass.services.async_register(
|
||||
DOMAIN,
|
||||
|
10
mypy.ini
generated
10
mypy.ini
generated
@ -2036,6 +2036,16 @@ disallow_untyped_defs = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.heos.*]
|
||||
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.here_travel_time.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user