Remove unnecessary try-else (4) (#86161)

This commit is contained in:
Marc Mueller 2023-01-18 13:17:08 +01:00 committed by GitHub
parent a44e44b7d0
commit d26484d482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 35 deletions

View File

@ -209,7 +209,7 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
await async_check_credentials(self.hass, self.host, user_input)
except (ApiError, AuthFailed, ClientConnectorError, asyncio.TimeoutError):
return self.async_abort(reason="reauth_unsuccessful")
else:
self.hass.config_entries.async_update_entry(
self.entry, data={**user_input, CONF_HOST: self.host}
)

View File

@ -41,7 +41,7 @@ async def async_get_controller(
await client.load_local(ip_address, password, port=port, use_ssl=ssl)
except RainMachineError:
return None
else:
return get_client_controller(client)

View File

@ -329,7 +329,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
await validate_input(self.hass, host, info, user_input)
except (DeviceConnectionError, InvalidAuthError, FirmwareUnsupported):
return self.async_abort(reason="reauth_unsuccessful")
else:
self.hass.config_entries.async_update_entry(
self.entry, data={**self.entry.data, **user_input}
)

View File

@ -178,5 +178,5 @@ class SwitchBeeClimateEntity(SwitchBeeDeviceEntity[SwitchBeeThermostat], Climate
raise HomeAssistantError(
f"Failed to set {self.name} state {state}, error: {str(exp)}"
) from exp
else:
await self.coordinator.async_refresh()

View File

@ -83,7 +83,7 @@ class SwitchBeeCoordinator(DataUpdateCoordinator[Mapping[int, SwitchBeeBaseDevic
raise UpdateFailed(
f"Error communicating with API: {exp}"
) from SwitchBeeError
else:
_LOGGER.debug("Loaded devices")
# Get the state of the devices

View File

@ -172,5 +172,5 @@ class SyncthingClient:
await self._client.system.ping()
except aiosyncthing.exceptions.SyncthingError:
return False
else:
return True

View File

@ -42,12 +42,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
exc_info=api_error,
)
raise api_error
else:
# if the printer is offline, we raise an UpdateFailed
if printer.is_unknown_state():
raise UpdateFailed(
f"Configured printer at {printer.url} does not respond."
)
raise UpdateFailed(f"Configured printer at {printer.url} does not respond.")
return printer
coordinator = DataUpdateCoordinator[SyncThru](

View File

@ -114,7 +114,7 @@ class WizConfigFlow(ConfigFlow, domain=DOMAIN):
bulbtype = await bulb.get_bulbtype()
except WIZ_CONNECT_EXCEPTIONS:
return self.async_abort(reason="cannot_connect")
else:
return self.async_create_entry(
title=name_from_bulb_type_and_mac(bulbtype, device.mac_address),
data={CONF_HOST: device.ip_address},

View File

@ -157,7 +157,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
raise ConfigEntryNotReady(f"Invalid server version: {err}") from err
except (asyncio.TimeoutError, BaseZwaveJSServerError) as err:
raise ConfigEntryNotReady(f"Failed to connect: {err}") from err
else:
async_delete_issue(hass, DOMAIN, "invalid_server_version")
LOGGER.info("Connected to Zwave JS Server")