Skip to content

Commit 7702242

Browse files
committed
refactor: remove bare excepts
1 parent 9dedd3e commit 7702242

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

python_weather/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
from aiohttp import ClientSession, ClientTimeout, TCPConnector
25+
from aiohttp import ClientSession, ClientTimeout, ClientResponseError, TCPConnector
2626
from urllib.parse import quote_plus
2727
from typing import Optional
2828
from asyncio import sleep
@@ -128,7 +128,7 @@ async def get(
128128
resp.raise_for_status()
129129

130130
return Forecast(await resp.json(), unit, locale)
131-
except:
131+
except ClientResponseError:
132132
if attempts == self.__max_retries:
133133
raise RequestError(status) from None
134134

python_weather/forecast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def __init__(self, json: dict, unit: _Unit, locale: Locale):
281281
match = LATLON_REGEX.match(req['query'])
282282

283283
self.coordinates = (float(match[1]), float(match[2]))
284-
except:
284+
except (KeyError, IndexError, StopIteration):
285285
self.coordinates = (float(nearest['latitude']), float(nearest['longitude']))
286286

287287
self.daily_forecasts = [

ruff.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@ indent-width = 2
44
docstring-code-format = true
55
docstring-code-line-length = 88
66
line-ending = "lf"
7-
quote-style = "single"
8-
9-
[lint]
10-
ignore = ["E722"]
7+
quote-style = "single"

0 commit comments

Comments
 (0)