Remove unnecessary try-else (1) (#86158)

This commit is contained in:
Marc Mueller 2023-01-18 14:24:52 +01:00 committed by GitHub
parent 6d336ec136
commit 1cc8feabb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 32 deletions

View file

@ -152,5 +152,5 @@ class AirzoneZoneEntity(AirzoneEntity):
raise HomeAssistantError(
f"Failed to set zone {self.name}: {error}"
) from error
else:
self.coordinator.async_set_updated_data(self.coordinator.airzone.data())
self.coordinator.async_set_updated_data(self.coordinator.airzone.data())

View file

@ -76,17 +76,16 @@ class BroadlinkUpdateManager(ABC):
)
raise UpdateFailed(err) from err
else:
if self.available is False:
_LOGGER.warning(
"Connected to %s (%s at %s)",
self.device.name,
self.device.api.model,
self.device.api.host[0],
)
self.available = True
self.last_update = dt.utcnow()
return data
if self.available is False:
_LOGGER.warning(
"Connected to %s (%s at %s)",
self.device.name,
self.device.api.model,
self.device.api.host[0],
)
self.available = True
self.last_update = dt.utcnow()
return data
@abstractmethod
async def async_fetch_data(self):

View file

@ -747,8 +747,8 @@ class CameraImageView(CameraView):
)
except (HomeAssistantError, ValueError) as ex:
raise web.HTTPInternalServerError() from ex
else:
return web.Response(body=image.content, content_type=image.content_type)
return web.Response(body=image.content, content_type=image.content_type)
class CameraMjpegStream(CameraView):

View file

@ -131,12 +131,11 @@ def get_data(hass: HomeAssistant, config: Mapping[str, Any]) -> CO2SignalRespons
_LOGGER.exception("Unexpected exception")
raise UnknownError from err
else:
if "error" in data:
raise UnknownError(data["error"])
if "error" in data:
raise UnknownError(data["error"])
if data.get("status") != "ok":
_LOGGER.exception("Unexpected response: %s", data)
raise UnknownError
if data.get("status") != "ok":
_LOGGER.exception("Unexpected response: %s", data)
raise UnknownError
return cast(CO2SignalResponse, data)

View file

@ -285,15 +285,15 @@ class EmonCmsData:
except requests.exceptions.RequestException as exception:
_LOGGER.error(exception)
return
if req.status_code == HTTPStatus.OK:
self.data = req.json()
else:
if req.status_code == HTTPStatus.OK:
self.data = req.json()
else:
_LOGGER.error(
(
"Please verify if the specified configuration value "
"'%s' is correct! (HTTP Status_code = %d)"
),
CONF_URL,
req.status_code,
)
_LOGGER.error(
(
"Please verify if the specified configuration value "
"'%s' is correct! (HTTP Status_code = %d)"
),
CONF_URL,
req.status_code,
)