File tree Expand file tree Collapse file tree
custom_components/asp_parking/gps2asp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,13 +123,12 @@ async def _fetch_page_with_retry(
123123 return response .json ()
124124 except httpx .HTTPStatusError as exc :
125125 last_error = exc
126- status_code = exc .response .status_code
127126 delay = self .BASE_DELAY * (2 ** attempt )
128127 logger .warning (
129128 "SODA API attempt %d/%d failed: HTTP %d (retry in %.1fs)" ,
130129 attempt + 1 ,
131130 self .MAX_RETRIES ,
132- status_code ,
131+ exc . response . status_code ,
133132 delay ,
134133 )
135134 if attempt < self .MAX_RETRIES - 1 :
@@ -158,7 +157,7 @@ async def _fetch_page_with_retry(
158157 )
159158
160159 # First page failed -- raise SODA API error
161- status_code = None
160+ status_code : int | None = None
162161 if isinstance (last_error , httpx .HTTPStatusError ):
163162 status_code = last_error .response .status_code
164163 raise SODAAPIError (status_code = status_code , detail = str (last_error ))
Original file line number Diff line number Diff line change 88from __future__ import annotations
99
1010import dataclasses
11+ from typing import Literal
1112
1213from ..schedule .models import ASPActiveNow , ScheduleFound , ScheduleResult
1314from . import SuspensionInfo
@@ -39,7 +40,7 @@ def apply_suspension(
3940 if not isinstance (schedule , (ScheduleFound , ASPActiveNow )):
4041 return schedule
4142
42- resolution_reason : str
43+ resolution_reason : Literal [ "suspended_holiday" , "suspended_emergency" ]
4344 if info .source == "holiday" :
4445 resolution_reason = "suspended_holiday"
4546 elif info .source in ("emergency" , "ha_nyc311" ):
Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ dev = [
3333[tool .hatch .build .targets .wheel ]
3434packages = [" src/gps2asp" ]
3535
36+ [tool .mypy ]
37+
38+ [[tool .mypy .overrides ]]
39+ module = [" shapely" , " shapely.*" , " rtree" , " rtree.*" ]
40+ ignore_missing_imports = true
41+
3642[tool .pytest .ini_options ]
3743asyncio_mode = " auto"
3844markers = [
Original file line number Diff line number Diff line change @@ -123,13 +123,12 @@ async def _fetch_page_with_retry(
123123 return response .json ()
124124 except httpx .HTTPStatusError as exc :
125125 last_error = exc
126- status_code = exc .response .status_code
127126 delay = self .BASE_DELAY * (2 ** attempt )
128127 logger .warning (
129128 "SODA API attempt %d/%d failed: HTTP %d (retry in %.1fs)" ,
130129 attempt + 1 ,
131130 self .MAX_RETRIES ,
132- status_code ,
131+ exc . response . status_code ,
133132 delay ,
134133 )
135134 if attempt < self .MAX_RETRIES - 1 :
@@ -161,7 +160,7 @@ async def _fetch_page_with_retry(
161160 )
162161
163162 # First page failed -- raise SODA API error
164- status_code = None
163+ status_code : int | None = None
165164 if isinstance (last_error , httpx .HTTPStatusError ):
166165 status_code = last_error .response .status_code
167166 raise SODAAPIError (status_code = status_code , detail = str (last_error ))
Original file line number Diff line number Diff line change 88from __future__ import annotations
99
1010import dataclasses
11+ from typing import Literal
1112
1213from ..schedule .models import ASPActiveNow , ScheduleFound , ScheduleResult
1314from . import SuspensionInfo
@@ -39,7 +40,7 @@ def apply_suspension(
3940 if not isinstance (schedule , (ScheduleFound , ASPActiveNow )):
4041 return schedule
4142
42- resolution_reason : str
43+ resolution_reason : Literal [ "suspended_holiday" , "suspended_emergency" ]
4344 if info .source == "holiday" :
4445 resolution_reason = "suspended_holiday"
4546 elif info .source in ("emergency" , "ha_nyc311" ):
You can’t perform that action at this time.
0 commit comments