Add websocket type hints in components (#80533)

This commit is contained in:
epenet 2022-10-19 04:15:23 +02:00 committed by GitHub
parent eca45f9dd0
commit 60640b4436
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 99 additions and 20 deletions

View file

@ -1,5 +1,6 @@
"""Websocket API for automation."""
import json
from typing import Any
import voluptuous as vol
@ -54,7 +55,11 @@ def async_setup(hass: HomeAssistant) -> None:
}
)
@websocket_api.async_response
async def websocket_trace_get(hass, connection, msg):
async def websocket_trace_get(
hass: HomeAssistant,
connection: websocket_api.ActiveConnection,
msg: dict[str, Any],
) -> None:
"""Get a script or automation trace."""
key = f"{msg['domain']}.{msg['item_id']}"
run_id = msg["run_id"]
@ -83,7 +88,11 @@ async def websocket_trace_get(hass, connection, msg):
}
)
@websocket_api.async_response
async def websocket_trace_list(hass, connection, msg):
async def websocket_trace_list(
hass: HomeAssistant,
connection: websocket_api.ActiveConnection,
msg: dict[str, Any],
) -> None:
"""Summarize script and automation traces."""
wanted_domain = msg["domain"]
key = f"{msg['domain']}.{msg['item_id']}" if "item_id" in msg else None
@ -102,7 +111,11 @@ async def websocket_trace_list(hass, connection, msg):
}
)
@websocket_api.async_response
async def websocket_trace_contexts(hass, connection, msg):
async def websocket_trace_contexts(
hass: HomeAssistant,
connection: websocket_api.ActiveConnection,
msg: dict[str, Any],
) -> None:
"""Retrieve contexts we have traces for."""
key = f"{msg['domain']}.{msg['item_id']}" if "item_id" in msg else None