diff --git a/.strict-typing b/.strict-typing index 1d73b05fdea..e93f1589cc8 100644 --- a/.strict-typing +++ b/.strict-typing @@ -341,6 +341,7 @@ homeassistant.components.nut.* homeassistant.components.onboarding.* homeassistant.components.oncue.* homeassistant.components.onewire.* +homeassistant.components.onkyo.* homeassistant.components.open_meteo.* homeassistant.components.openexchangerates.* homeassistant.components.opensky.* diff --git a/homeassistant/components/onkyo/media_player.py b/homeassistant/components/onkyo/media_player.py index df1f25a196b..1718ecb36be 100644 --- a/homeassistant/components/onkyo/media_player.py +++ b/homeassistant/components/onkyo/media_player.py @@ -4,7 +4,7 @@ from __future__ import annotations import asyncio import logging -from typing import Any +from typing import Any, Literal import pyeiscp import voluptuous as vol @@ -23,7 +23,7 @@ from homeassistant.const import ( CONF_NAME, EVENT_HOMEASSISTANT_STOP, ) -from homeassistant.core import HomeAssistant, ServiceCall, callback +from homeassistant.core import Event, HomeAssistant, ServiceCall, callback from homeassistant.helpers import config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -269,7 +269,7 @@ async def async_setup_platform( _LOGGER.debug("Manually creating receiver: %s (%s)", name, host) @callback - async def async_onkyo_interview_callback(conn: pyeiscp.Connection): + async def async_onkyo_interview_callback(conn: pyeiscp.Connection) -> None: """Receiver interviewed, connection not yet active.""" info = ReceiverInfo(conn.host, conn.port, conn.name, conn.identifier) _LOGGER.debug("Receiver interviewed: %s (%s)", info.model_name, info.host) @@ -285,7 +285,7 @@ async def async_setup_platform( _LOGGER.debug("Discovering receivers") @callback - async def async_onkyo_discovery_callback(conn: pyeiscp.Connection): + async def async_onkyo_discovery_callback(conn: pyeiscp.Connection) -> None: """Receiver discovered, connection not yet active.""" info = ReceiverInfo(conn.host, conn.port, conn.name, conn.identifier) _LOGGER.debug("Receiver discovered: %s (%s)", info.model_name, info.host) @@ -298,7 +298,7 @@ async def async_setup_platform( ) @callback - def close_receiver(_event): + def close_receiver(_event: Event) -> None: for receiver in receivers.values(): receiver.conn.close() @@ -495,19 +495,23 @@ class OnkyoMediaPlayer(MediaPlayerEntity): self.async_write_ha_state() @callback - def _parse_source(self, source): + def _parse_source(self, source_raw: str | int | tuple[str]) -> None: # source is either a tuple of values or a single value, # so we convert to a tuple, when it is a single value. - if not isinstance(source, tuple): - source = (source,) + if isinstance(source_raw, str | int): + source = (str(source_raw),) + else: + source = source_raw for value in source: if value in self._source_mapping: self._attr_source = self._source_mapping[value] - break - self._attr_source = "_".join(source) + return + self._attr_source = "_".join(source) @callback - def _parse_audio_information(self, audio_information): + def _parse_audio_information( + self, audio_information: tuple[str] | Literal["N/A"] + ) -> None: # If audio information is not available, N/A is returned, # so only update the audio information, when it is not N/A. if audio_information == "N/A": @@ -523,7 +527,9 @@ class OnkyoMediaPlayer(MediaPlayerEntity): } @callback - def _parse_video_information(self, video_information): + def _parse_video_information( + self, video_information: tuple[str] | Literal["N/A"] + ) -> None: # If video information is not available, N/A is returned, # so only update the video information, when it is not N/A. if video_information == "N/A": @@ -538,11 +544,11 @@ class OnkyoMediaPlayer(MediaPlayerEntity): if len(value) > 0 } - def _query_av_info_delayed(self): + def _query_av_info_delayed(self) -> None: if self._zone == "main" and not self._query_timer: @callback - def _query_av_info(): + def _query_av_info() -> None: if self._supports_audio_info: self._query_receiver("audio-information") if self._supports_video_info: diff --git a/mypy.ini b/mypy.ini index 4ba1f41f4d4..b352d2747be 100644 --- a/mypy.ini +++ b/mypy.ini @@ -3166,6 +3166,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.onkyo.*] +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.open_meteo.*] check_untyped_defs = true disallow_incomplete_defs = true