mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Remove unnecessary try-else (4) (#86161)
This commit is contained in:
parent
a44e44b7d0
commit
d26484d482
@ -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",
|
||||
|
@ -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):
|
||||
|
@ -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 = {
|
||||
|
@ -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()
|
||||
|
@ -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:
|
||||
|
@ -172,5 +172,5 @@ class SyncthingClient:
|
||||
await self._client.system.ping()
|
||||
except aiosyncthing.exceptions.SyncthingError:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
return True
|
||||
|
@ -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,
|
||||
|
@ -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 = {
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user