Remove unnecessary try-else (5) (#86164)

This commit is contained in:
Marc Mueller 2023-01-18 14:10:13 +01:00 committed by GitHub
parent d26484d482
commit 6d336ec136
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 29 deletions

View file

@ -51,7 +51,7 @@ class FlickConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
raise CannotConnect() from err
except AuthException as err:
raise InvalidAuth() from err
else:
return token is not None
async def async_step_user(self, user_input=None):

View file

@ -136,7 +136,7 @@ class GitHubDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
# These are unexpected and we log the trace to help with troubleshooting
LOGGER.exception(exception)
raise UpdateFailed(exception) from exception
else:
self._last_response = response
return response.data["data"]["repository"]

View file

@ -191,7 +191,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
raise ConfigEntryAuthFailed from err
except ApiException as err:
raise ConfigEntryNotReady from err
else:
hass.config_entries.async_update_entry(entry, unique_id=primary_calendar.id)
# Only expose the add event service if we have the correct permissions

View file

@ -43,9 +43,8 @@ class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
except Exception: # pylint: disable=broad-except
LOGGER.exception("Unexpected exception")
return self.async_abort(reason="unknown")
else:
self._name = device.name
self._name = device.name
self._host = host
self._set_confirm_only()
self.context["title_placeholders"] = {"name": self._name, "host": host}

View file

@ -69,7 +69,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
raise ConfigEntryNotReady(
"Unknown error connecting to the Matter server"
) from err
else:
async_delete_issue(hass, DOMAIN, "invalid_server_version")
async def on_hass_stop(event: Event) -> None:

View file

@ -36,9 +36,9 @@ def _can_use_icmp_lib_with_privilege() -> None | bool:
" socket"
)
return None
else:
_LOGGER.debug("Using icmplib in privileged=False mode")
return False
else:
_LOGGER.debug("Using icmplib in privileged=True mode")
return True

View file

@ -153,7 +153,7 @@ class ProtectMediaPlayer(ProtectDeviceEntity, MediaPlayerEntity):
await self.device.play_audio(media_id, blocking=False)
except StreamError as err:
raise HomeAssistantError(err) from err
else:
# update state after starting player
self._async_updated_event(self.device)
# wait until player finishes to update state again

View file

@ -84,7 +84,7 @@ class UptimeRobotDataUpdateCoordinator(DataUpdateCoordinator[list[UptimeRobotMon
raise ConfigEntryAuthFailed(exception) from exception
except UptimeRobotException as exception:
raise UpdateFailed(exception) from exception
else:
if response.status != API_ATTR_OK:
raise UpdateFailed(response.error.message)

View file

@ -180,10 +180,8 @@ class VLCTelnetConfigFlow(ConfigFlow, domain=DOMAIN):
except Exception: # pylint: disable=broad-except
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason="unknown")
else:
return self.async_create_entry(
title=info["title"], data=self.hassio_discovery
)
return self.async_create_entry(title=info["title"], data=self.hassio_discovery)
class CannotConnect(exceptions.HomeAssistantError):