Adjust type hints in android_ip_webcam switch entity (#76989)

This commit is contained in:
epenet 2022-08-18 22:49:59 +02:00 committed by GitHub
parent 009a573324
commit f323c5e880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,9 @@
"""Support for Android IP Webcam settings."""
from __future__ import annotations
from collections.abc import Callable
from collections.abc import Callable, Coroutine
from dataclasses import dataclass
from typing import Any
from pydroid_ipcam import PyDroidIPCam
@ -21,8 +22,8 @@ from .entity import AndroidIPCamBaseEntity
class AndroidIPWebcamSwitchEntityDescriptionMixin:
"""Mixin for required keys."""
on_func: Callable[[PyDroidIPCam], None]
off_func: Callable[[PyDroidIPCam], None]
on_func: Callable[[PyDroidIPCam], Coroutine[Any, Any, bool]]
off_func: Callable[[PyDroidIPCam], Coroutine[Any, Any, bool]]
@dataclass
@ -159,12 +160,12 @@ class IPWebcamSettingSwitch(AndroidIPCamBaseEntity, SwitchEntity):
"""Return if settings is on or off."""
return bool(self.cam.current_settings.get(self.entity_description.key))
async def async_turn_on(self, **kwargs):
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn device on."""
await self.entity_description.on_func(self.cam)
await self.coordinator.async_request_refresh()
async def async_turn_off(self, **kwargs):
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn device off."""
await self.entity_description.off_func(self.cam)
await self.coordinator.async_request_refresh()