Skip to content

Commit

Permalink
Conversation: Use [] when we know key exists (#133305)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Dec 15, 2024
1 parent 0030a97 commit e24dc33
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions homeassistant/components/conversation/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
get_agent_manager,
)
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 .models import ConversationInput

Expand Down Expand Up @@ -162,8 +162,7 @@ async def websocket_list_sentences(
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict
) -> None:
"""List custom registered sentences."""
agent = hass.data.get(DATA_DEFAULT_ENTITY)
assert isinstance(agent, DefaultAgent)
agent = hass.data[DATA_DEFAULT_ENTITY]

sentences = []
for trigger_data in agent.trigger_sentences:
Expand All @@ -185,8 +184,7 @@ async def websocket_hass_agent_debug(
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict
) -> None:
"""Return intents that would be matched by the default agent for a list of sentences."""
agent = hass.data.get(DATA_DEFAULT_ENTITY)
assert isinstance(agent, DefaultAgent)
agent = hass.data[DATA_DEFAULT_ENTITY]

# Return results for each sentence in the same order as the input.
result_dicts: list[dict[str, Any] | None] = []
Expand Down

0 comments on commit e24dc33

Please sign in to comment.