diff --git a/.strict-typing b/.strict-typing index 041da10ab80..9f91b5ab699 100644 --- a/.strict-typing +++ b/.strict-typing @@ -439,6 +439,7 @@ homeassistant.components.waqi.* homeassistant.components.water_heater.* homeassistant.components.watttime.* homeassistant.components.weather.* +homeassistant.components.webhook.* homeassistant.components.webostv.* homeassistant.components.websocket_api.* homeassistant.components.wemo.* diff --git a/homeassistant/components/webhook/__init__.py b/homeassistant/components/webhook/__init__.py index 16f3e5c7ef2..00b27fdb647 100644 --- a/homeassistant/components/webhook/__init__.py +++ b/homeassistant/components/webhook/__init__.py @@ -174,7 +174,7 @@ async def async_handle_webhook( ) try: - response = await webhook["handler"](hass, webhook_id, request) + response: Response | None = await webhook["handler"](hass, webhook_id, request) if response is None: response = Response(status=HTTPStatus.OK) return response diff --git a/homeassistant/components/webhook/trigger.py b/homeassistant/components/webhook/trigger.py index 78728793f5d..e0f3412a562 100644 --- a/homeassistant/components/webhook/trigger.py +++ b/homeassistant/components/webhook/trigger.py @@ -3,8 +3,9 @@ from __future__ import annotations from dataclasses import dataclass import logging +from typing import Any -from aiohttp import hdrs +from aiohttp import hdrs, web import voluptuous as vol from homeassistant.const import CONF_PLATFORM, CONF_WEBHOOK_ID @@ -57,9 +58,11 @@ class TriggerInstance: job: HassJob -async def _handle_webhook(hass, webhook_id, request): +async def _handle_webhook( + hass: HomeAssistant, webhook_id: str, request: web.Request +) -> None: """Handle incoming webhook.""" - base_result = {"platform": "webhook", "webhook_id": webhook_id} + base_result: dict[str, Any] = {"platform": "webhook", "webhook_id": webhook_id} if "json" in request.headers.get(hdrs.CONTENT_TYPE, ""): base_result["json"] = await request.json() @@ -133,7 +136,7 @@ async def async_attach_trigger( triggers[webhook_id].append(trigger_instance) @callback - def unregister(): + def unregister() -> None: """Unregister webhook.""" if issue_id: async_delete_issue(hass, DOMAIN, issue_id) diff --git a/mypy.ini b/mypy.ini index 7693912a6c8..c72aba4e62f 100644 --- a/mypy.ini +++ b/mypy.ini @@ -4153,6 +4153,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.webhook.*] +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.webostv.*] check_untyped_defs = true disallow_incomplete_defs = true