From 24dee01599a8c4e0d503c0cb9880d837e0d18c7d Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Fri, 26 Mar 2021 04:21:27 +0100 Subject: [PATCH] Use async with in Acmeda config flow (#48291) --- homeassistant/components/acmeda/config_flow.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/acmeda/config_flow.py b/homeassistant/components/acmeda/config_flow.py index a849e49ddf4..5cdb804d5dd 100644 --- a/homeassistant/components/acmeda/config_flow.py +++ b/homeassistant/components/acmeda/config_flow.py @@ -38,12 +38,13 @@ class AcmedaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): } hubs = [] - with suppress(asyncio.TimeoutError), async_timeout.timeout(5): - async for hub in aiopulse.Hub.discover(): - if hub.id not in already_configured: - hubs.append(hub) + with suppress(asyncio.TimeoutError): + async with async_timeout.timeout(5): + async for hub in aiopulse.Hub.discover(): + if hub.id not in already_configured: + hubs.append(hub) - if len(hubs) == 0: + if not hubs: return self.async_abort(reason="no_devices_found") if len(hubs) == 1: