diff --git a/.strict-typing b/.strict-typing index b0fd74bce54fa0f3527fcf806b0305ed08917dd4..1196f199c78b1f37ce28a33c6396c3373a4244ab 100644 --- a/.strict-typing +++ b/.strict-typing @@ -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.* diff --git a/homeassistant/components/reolink/button.py b/homeassistant/components/reolink/button.py index 8863ef9f9a9e7e8e039cf66fd18885b6abafdedc..cd1e1b05fae0ec468296fd7cba833a122e51d198 100644 --- a/homeassistant/components/reolink/button.py +++ b/homeassistant/components/reolink/button.py @@ -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: diff --git a/homeassistant/components/reolink/entity.py b/homeassistant/components/reolink/entity.py index 6101eee8a4c6f6e263d59113b09cf85df257bc73..dc2366e8f569dc2356dbdfef5b345df813f9b775 100644 --- a/homeassistant/components/reolink/entity.py +++ b/homeassistant/components/reolink/entity.py @@ -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 diff --git a/homeassistant/components/reolink/host.py b/homeassistant/components/reolink/host.py index 68a44bf0aae2df1a8ff7d56687e9f0c1227b1df2..d2b2bba627612a8e646cb2f09466a17111cf9040 100644 --- a/homeassistant/components/reolink/host.py +++ b/homeassistant/components/reolink/host.py @@ -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 diff --git a/homeassistant/components/reolink/media_source.py b/homeassistant/components/reolink/media_source.py index 9280df0f5bd40f126a85aa2a4f73b7a5dcd26af0..0c23bed7e2f65a216ec91ffc52c57354f3703be2 100644 --- a/homeassistant/components/reolink/media_source.py +++ b/homeassistant/components/reolink/media_source.py @@ -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) diff --git a/homeassistant/components/reolink/update.py b/homeassistant/components/reolink/update.py index 73d2e53673d6d660c01beca147f66083e34087b5..aa607e2b29e3cbbab77a578c06acbc316ace6e9e 100644 --- a/homeassistant/components/reolink/update.py +++ b/homeassistant/components/reolink/update.py @@ -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() diff --git a/mypy.ini b/mypy.ini index 4d33f16d968e1186de29805858039b4996b2ea0b..04c07d82afaf7b17ed65bc9bdf8752bb11de7f12 100644 --- a/mypy.ini +++ b/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