Skip to content

Commit

Permalink
move out from try
Browse files Browse the repository at this point in the history
  • Loading branch information
freekode committed Apr 27, 2024
1 parent 9f7435a commit 3939fdb
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,15 @@ def __init__(

async def _async_update_data(self):
"""Update the data."""
data = {}
weather_report = {}
async with asyncio.timeout(20):
try:
weather_report = await self._owm_client.get_weather(
self._latitude, self._longitude
)
data = self._convert_weather_response(weather_report)
except RequestError as error:
raise UpdateFailed(error) from error
return data
return self._convert_weather_response(weather_report)

def _convert_weather_response(self, weather_report: WeatherReport):
"""Format the weather response correctly."""
Expand Down

0 comments on commit 3939fdb

Please sign in to comment.