Conversation: Use [] when we know key exists (#133305)

This commit is contained in:
Paulus Schoutsen 2024-12-15 15:45:50 -05:00 committed by GitHub
parent 0030a970a1
commit e24dc33259
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,7 +24,7 @@ from .agent_manager import (
get_agent_manager, get_agent_manager,
) )
from .const import DATA_COMPONENT, DATA_DEFAULT_ENTITY from .const import DATA_COMPONENT, DATA_DEFAULT_ENTITY
from .default_agent import METADATA_CUSTOM_FILE, METADATA_CUSTOM_SENTENCE, DefaultAgent from .default_agent import METADATA_CUSTOM_FILE, METADATA_CUSTOM_SENTENCE
from .entity import ConversationEntity from .entity import ConversationEntity
from .models import ConversationInput from .models import ConversationInput
@ -162,8 +162,7 @@ async def websocket_list_sentences(
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict
) -> None: ) -> None:
"""List custom registered sentences.""" """List custom registered sentences."""
agent = hass.data.get(DATA_DEFAULT_ENTITY) agent = hass.data[DATA_DEFAULT_ENTITY]
assert isinstance(agent, DefaultAgent)
sentences = [] sentences = []
for trigger_data in agent.trigger_sentences: for trigger_data in agent.trigger_sentences:
@ -185,8 +184,7 @@ async def websocket_hass_agent_debug(
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict
) -> None: ) -> None:
"""Return intents that would be matched by the default agent for a list of sentences.""" """Return intents that would be matched by the default agent for a list of sentences."""
agent = hass.data.get(DATA_DEFAULT_ENTITY) agent = hass.data[DATA_DEFAULT_ENTITY]
assert isinstance(agent, DefaultAgent)
# Return results for each sentence in the same order as the input. # Return results for each sentence in the same order as the input.
result_dicts: list[dict[str, Any] | None] = [] result_dicts: list[dict[str, Any] | None] = []