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,12 +209,12 @@ 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}
)
await self.hass.config_entries.async_reload(self.entry.entry_id)
return self.async_abort(reason="reauth_successful")
self.hass.config_entries.async_update_entry(
self.entry, data={**user_input, CONF_HOST: self.host}
)
await self.hass.config_entries.async_reload(self.entry.entry_id)
return self.async_abort(reason="reauth_successful")
return self.async_show_form(
step_id="reauth_confirm",

View File

@ -41,8 +41,8 @@ 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)
return get_client_controller(client)
class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):

View File

@ -329,12 +329,12 @@ 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}
)
await self.hass.config_entries.async_reload(self.entry.entry_id)
return self.async_abort(reason="reauth_successful")
self.hass.config_entries.async_update_entry(
self.entry, data={**self.entry.data, **user_input}
)
await self.hass.config_entries.async_reload(self.entry.entry_id)
return self.async_abort(reason="reauth_successful")
if self.entry.data.get("gen", 1) == 1:
schema = {

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()
await self.coordinator.async_refresh()

View File

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

View File

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

View File

@ -42,13 +42,11 @@ 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."
)
return printer
# 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.")
return printer
coordinator = DataUpdateCoordinator[SyncThru](
hass,

View File

@ -114,11 +114,11 @@ 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},
)
return self.async_create_entry(
title=name_from_bulb_type_and_mac(bulbtype, device.mac_address),
data={CONF_HOST: device.ip_address},
)
current_unique_ids = self._async_current_ids()
current_hosts = {

View File

@ -157,9 +157,9 @@ 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")
async_delete_issue(hass, DOMAIN, "invalid_server_version")
LOGGER.info("Connected to Zwave JS Server")
dev_reg = device_registry.async_get(hass)
ent_reg = entity_registry.async_get(hass)