Use async with in Acmeda config flow (#48291)

pull/48350/head
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
1 changed files with 6 additions and 5 deletions

View File

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