mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
Add Onkyo to strict typing (#124617)
This commit is contained in:
@ -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.*
|
||||
|
@ -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:
|
||||
|
10
mypy.ini
10
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
|
||||
|
Reference in New Issue
Block a user