Improve type hints for webhook implementation in dialogflow (#121592)

pull/121594/head
epenet 2024-07-09 12:04:28 +02:00 committed by GitHub
parent a1fae0e0ce
commit 7aada39b77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -28,7 +28,9 @@ class DialogFlowError(HomeAssistantError):
"""Raised when a DialogFlow error happens."""
async def handle_webhook(hass, webhook_id, request):
async def handle_webhook(
hass: HomeAssistant, webhook_id: str, request: web.Request
) -> web.Response | None:
"""Handle incoming webhook with Dialogflow requests."""
message = await request.json()
@ -36,7 +38,7 @@ async def handle_webhook(hass, webhook_id, request):
try:
response = await async_handle_message(hass, message)
return b"" if response is None else web.json_response(response)
return None if response is None else web.json_response(response)
except DialogFlowError as err:
_LOGGER.warning(str(err))