Enable strict typing for androidtv (#106820)

This commit is contained in:
Marc Mueller 2024-01-01 20:15:01 +01:00 committed by GitHub
parent 06a5e25853
commit 4e0c0cf2ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 5 deletions

View file

@ -64,6 +64,7 @@ homeassistant.components.amcrest.*
homeassistant.components.ampio.* homeassistant.components.ampio.*
homeassistant.components.analytics.* homeassistant.components.analytics.*
homeassistant.components.android_ip_webcam.* homeassistant.components.android_ip_webcam.*
homeassistant.components.androidtv.*
homeassistant.components.androidtv_remote.* homeassistant.components.androidtv_remote.*
homeassistant.components.anel_pwrctrl.* homeassistant.components.anel_pwrctrl.*
homeassistant.components.anova.* homeassistant.components.anova.*

View file

@ -28,7 +28,7 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
Platform, Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import Event, HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_send
@ -166,7 +166,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if not aftv: if not aftv:
raise ConfigEntryNotReady(error_message) raise ConfigEntryNotReady(error_message)
async def async_close_connection(event): async def async_close_connection(event: Event) -> None:
"""Close Android Debug Bridge connection on HA Stop.""" """Close Android Debug Bridge connection on HA Stop."""
await aftv.adb_close() await aftv.adb_close()

View file

@ -385,4 +385,4 @@ def _validate_state_det_rules(state_det_rules: Any) -> list[Any] | None:
except ValueError as exc: except ValueError as exc:
_LOGGER.warning("Invalid state detection rules: %s", exc) _LOGGER.warning("Invalid state detection rules: %s", exc)
return None return None
return json_rules return json_rules # type: ignore[no-any-return]

View file

@ -313,7 +313,7 @@ class ADBDevice(MediaPlayerEntity):
@adb_decorator() @adb_decorator()
async def _adb_screencap(self) -> bytes | None: async def _adb_screencap(self) -> bytes | None:
"""Take a screen capture from the device.""" """Take a screen capture from the device."""
return await self.aftv.adb_screencap() return await self.aftv.adb_screencap() # type: ignore[no-any-return]
async def _async_get_screencap(self, prev_app_id: str | None = None) -> None: async def _async_get_screencap(self, prev_app_id: str | None = None) -> None:
"""Take a screen capture from the device when enabled.""" """Take a screen capture from the device when enabled."""
@ -331,7 +331,7 @@ class ADBDevice(MediaPlayerEntity):
await self._adb_get_screencap(no_throttle=force) await self._adb_get_screencap(no_throttle=force)
@Throttle(MIN_TIME_BETWEEN_SCREENCAPS) @Throttle(MIN_TIME_BETWEEN_SCREENCAPS)
async def _adb_get_screencap(self, **kwargs) -> None: async def _adb_get_screencap(self, **kwargs: Any) -> None:
"""Take a screen capture from the device every 60 seconds.""" """Take a screen capture from the device every 60 seconds."""
if media_data := await self._adb_screencap(): if media_data := await self._adb_screencap():
self._media_image = media_data, "image/png" self._media_image = media_data, "image/png"

View file

@ -400,6 +400,16 @@ disallow_untyped_defs = true
warn_return_any = true warn_return_any = true
warn_unreachable = true warn_unreachable = true
[mypy-homeassistant.components.androidtv.*]
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.androidtv_remote.*] [mypy-homeassistant.components.androidtv_remote.*]
check_untyped_defs = true check_untyped_defs = true
disallow_incomplete_defs = true disallow_incomplete_defs = true