Use async with in Acmeda config flow (#48291)

This commit is contained in:
Franck Nijhof 2021-03-26 04:21:27 +01:00 committed by GitHub
parent b90c620c5e
commit 24dee01599
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,12 +38,13 @@ class AcmedaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
} }
hubs = [] hubs = []
with suppress(asyncio.TimeoutError), async_timeout.timeout(5): with suppress(asyncio.TimeoutError):
async for hub in aiopulse.Hub.discover(): async with async_timeout.timeout(5):
if hub.id not in already_configured: async for hub in aiopulse.Hub.discover():
hubs.append(hub) 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") return self.async_abort(reason="no_devices_found")
if len(hubs) == 1: if len(hubs) == 1: