From 17b202d8cfcdf7affd2b7628d9942e49b09fcca4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 11 Mar 2024 15:37:03 -1000 Subject: [PATCH] Await discovery_function in the DiscoveryFlowHandler instead of wrapping it in a task (#113115) Await discovery_function in the DiscoveryFlowHandler instead of wrapping This function was always a coro so it can be awaited directly instead of wrapping it in add_job --- homeassistant/helpers/config_entry_flow.py | 3 +-- tests/helpers/test_config_entry_flow.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/helpers/config_entry_flow.py b/homeassistant/helpers/config_entry_flow.py index c4da43a7061..f2247e533a8 100644 --- a/homeassistant/helpers/config_entry_flow.py +++ b/homeassistant/helpers/config_entry_flow.py @@ -69,8 +69,7 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow, Generic[_R]): if not (has_devices := bool(in_progress)): has_devices = await cast( - "asyncio.Future[bool]", - self.hass.async_add_job(self._discovery_function, self.hass), + "asyncio.Future[bool]", self._discovery_function(self.hass) ) if not has_devices: diff --git a/tests/helpers/test_config_entry_flow.py b/tests/helpers/test_config_entry_flow.py index f59b2163591..0735c0a1a80 100644 --- a/tests/helpers/test_config_entry_flow.py +++ b/tests/helpers/test_config_entry_flow.py @@ -404,6 +404,7 @@ async def test_webhook_create_cloudhook( assert len(mock_delete.mock_calls) == 1 assert result["require_restart"] is False + await hass.async_block_till_done() async def test_webhook_create_cloudhook_aborts_not_connected(