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
This commit is contained in:
J. Nick Koston
2024-03-11 15:37:03 -10:00
committed by GitHub
parent ebd17687e0
commit 17b202d8cf
2 changed files with 2 additions and 2 deletions

View File

@@ -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:

View File

@@ -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(