mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Enable strict typing for Reolink (#131239)
This commit is contained in:
parent
9e4368cfd4
commit
65652c0adb
@ -385,6 +385,7 @@ homeassistant.components.recollect_waste.*
|
||||
homeassistant.components.recorder.*
|
||||
homeassistant.components.remote.*
|
||||
homeassistant.components.renault.*
|
||||
homeassistant.components.reolink.*
|
||||
homeassistant.components.repairs.*
|
||||
homeassistant.components.rest.*
|
||||
homeassistant.components.rest_command.*
|
||||
|
@ -212,7 +212,7 @@ class ReolinkButtonEntity(ReolinkChannelCoordinatorEntity, ButtonEntity):
|
||||
except ReolinkError as err:
|
||||
raise HomeAssistantError(err) from err
|
||||
|
||||
async def async_ptz_move(self, **kwargs) -> None:
|
||||
async def async_ptz_move(self, **kwargs: Any) -> None:
|
||||
"""PTZ move with speed."""
|
||||
speed = kwargs[ATTR_SPEED]
|
||||
try:
|
||||
|
@ -179,7 +179,7 @@ class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
|
||||
"""Return True if entity is available."""
|
||||
return super().available and self._host.api.camera_online(self._channel)
|
||||
|
||||
def register_callback(self, unique_id: str, cmd_id) -> None:
|
||||
def register_callback(self, unique_id: str, cmd_id: int) -> None:
|
||||
"""Register callback for TCP push events."""
|
||||
self._host.api.baichuan.register_callback(
|
||||
unique_id, self._push_callback, cmd_id, self._channel
|
||||
|
@ -262,7 +262,7 @@ class ReolinkHost:
|
||||
else:
|
||||
ir.async_delete_issue(self._hass, DOMAIN, f"firmware_update_{key}")
|
||||
|
||||
async def _async_check_tcp_push(self, *_) -> None:
|
||||
async def _async_check_tcp_push(self, *_: Any) -> None:
|
||||
"""Check the TCP push subscription."""
|
||||
if self._api.baichuan.events_active:
|
||||
ir.async_delete_issue(self._hass, DOMAIN, "webhook_url")
|
||||
@ -323,7 +323,7 @@ class ReolinkHost:
|
||||
|
||||
self._cancel_tcp_push_check = None
|
||||
|
||||
async def _async_check_onvif(self, *_) -> None:
|
||||
async def _async_check_onvif(self, *_: Any) -> None:
|
||||
"""Check the ONVIF subscription."""
|
||||
if self._webhook_reachable:
|
||||
ir.async_delete_issue(self._hass, DOMAIN, "webhook_url")
|
||||
@ -344,7 +344,7 @@ class ReolinkHost:
|
||||
|
||||
self._cancel_onvif_check = None
|
||||
|
||||
async def _async_check_onvif_long_poll(self, *_) -> None:
|
||||
async def _async_check_onvif_long_poll(self, *_: Any) -> None:
|
||||
"""Check if ONVIF long polling is working."""
|
||||
if not self._long_poll_received:
|
||||
_LOGGER.debug(
|
||||
@ -450,7 +450,7 @@ class ReolinkHost:
|
||||
err,
|
||||
)
|
||||
|
||||
async def _async_start_long_polling(self, initial=False) -> None:
|
||||
async def _async_start_long_polling(self, initial: bool = False) -> None:
|
||||
"""Start ONVIF long polling task."""
|
||||
if self._long_poll_task is None:
|
||||
try:
|
||||
@ -495,7 +495,7 @@ class ReolinkHost:
|
||||
err,
|
||||
)
|
||||
|
||||
async def stop(self, event=None) -> None:
|
||||
async def stop(self, *_: Any) -> None:
|
||||
"""Disconnect the API."""
|
||||
if self._cancel_poll is not None:
|
||||
self._cancel_poll()
|
||||
@ -651,7 +651,7 @@ class ReolinkHost:
|
||||
webhook.async_unregister(self._hass, self.webhook_id)
|
||||
self.webhook_id = None
|
||||
|
||||
async def _async_long_polling(self, *_) -> None:
|
||||
async def _async_long_polling(self, *_: Any) -> None:
|
||||
"""Use ONVIF long polling to immediately receive events."""
|
||||
# This task will be cancelled once _async_stop_long_polling is called
|
||||
while True:
|
||||
@ -688,7 +688,7 @@ class ReolinkHost:
|
||||
# Cooldown to prevent CPU over usage on camera freezes
|
||||
await asyncio.sleep(LONG_POLL_COOLDOWN)
|
||||
|
||||
async def _async_poll_all_motion(self, *_) -> None:
|
||||
async def _async_poll_all_motion(self, *_: Any) -> None:
|
||||
"""Poll motion and AI states until the first ONVIF push is received."""
|
||||
if (
|
||||
self._api.baichuan.events_active
|
||||
|
@ -24,6 +24,7 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from .const import DOMAIN
|
||||
from .host import ReolinkHost
|
||||
from .util import ReolinkConfigEntry
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -48,7 +49,9 @@ def res_name(stream: str) -> str:
|
||||
|
||||
def get_host(hass: HomeAssistant, config_entry_id: str) -> ReolinkHost:
|
||||
"""Return the Reolink host from the config entry id."""
|
||||
config_entry = hass.config_entries.async_get_entry(config_entry_id)
|
||||
config_entry: ReolinkConfigEntry | None = hass.config_entries.async_get_entry(
|
||||
config_entry_id
|
||||
)
|
||||
assert config_entry is not None
|
||||
return config_entry.runtime_data.host
|
||||
|
||||
@ -65,7 +68,9 @@ class ReolinkVODMediaSource(MediaSource):
|
||||
|
||||
async def async_resolve_media(self, item: MediaSourceItem) -> PlayMedia:
|
||||
"""Resolve media to a url."""
|
||||
identifier = item.identifier.split("|", 5)
|
||||
identifier = ["UNKNOWN"]
|
||||
if item.identifier is not None:
|
||||
identifier = item.identifier.split("|", 5)
|
||||
if identifier[0] != "FILE":
|
||||
raise Unresolvable(f"Unknown media item '{item.identifier}'.")
|
||||
|
||||
@ -110,7 +115,7 @@ class ReolinkVODMediaSource(MediaSource):
|
||||
item: MediaSourceItem,
|
||||
) -> BrowseMediaSource:
|
||||
"""Return media."""
|
||||
if item.identifier is None:
|
||||
if not item.identifier:
|
||||
return await self._async_generate_root()
|
||||
|
||||
identifier = item.identifier.split("|", 7)
|
||||
|
@ -213,7 +213,7 @@ class ReolinkUpdateBaseEntity(
|
||||
self._reolink_data.device_coordinator.update_interval = None
|
||||
self._reolink_data.device_coordinator.async_set_updated_data(None)
|
||||
|
||||
async def _resume_update_coordinator(self, *args) -> None:
|
||||
async def _resume_update_coordinator(self, *args: Any) -> None:
|
||||
"""Resume updating the states using the data update coordinator (after reboots)."""
|
||||
self._reolink_data.device_coordinator.update_interval = DEVICE_UPDATE_INTERVAL
|
||||
try:
|
||||
@ -221,7 +221,7 @@ class ReolinkUpdateBaseEntity(
|
||||
finally:
|
||||
self._cancel_resume = None
|
||||
|
||||
async def _async_update_progress(self, *args) -> None:
|
||||
async def _async_update_progress(self, *args: Any) -> None:
|
||||
"""Request update."""
|
||||
self.async_write_ha_state()
|
||||
if self._installing:
|
||||
@ -229,7 +229,7 @@ class ReolinkUpdateBaseEntity(
|
||||
self.hass, POLL_PROGRESS, self._async_update_progress
|
||||
)
|
||||
|
||||
async def _async_update_future(self, *args) -> None:
|
||||
async def _async_update_future(self, *args: Any) -> None:
|
||||
"""Request update."""
|
||||
try:
|
||||
await self.async_update()
|
||||
|
10
mypy.ini
10
mypy.ini
@ -3606,6 +3606,16 @@ disallow_untyped_defs = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.reolink.*]
|
||||
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.repairs.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user