Autogenerated type safety parameterisation of all methods

This commit is contained in:
Ian Renton
2026-09-20 20:02:19 +01:00
parent 6037e742cc
commit 324dd1414b
132 changed files with 1228 additions and 706 deletions
+8 -5
View File
@@ -1,7 +1,10 @@
from datetime import datetime, time
from typing import cast
from __future__ import annotations
from datetime import date, datetime, time
from typing import Any, cast
import pytz
import requests
from icalendar import Calendar, Event
from data.alert import Alert
@@ -12,10 +15,10 @@ class ICALAlertProvider(HTTPAlertProvider):
"""Generic alert provider for iCal calendars. Defines an abstract method event_to_alert(event) that subclasses must
implement, and use it to convert an iCal event to an Alert object based on whatever format their iCal events use."""
def __init__(self, name, provider_config, url, poll_interval):
def __init__(self, name: str, provider_config: dict[str, Any], url: str, poll_interval: int) -> None:
super().__init__(name, provider_config, url, poll_interval)
def _http_response_to_alerts(self, http_response):
def _http_response_to_alerts(self, http_response: requests.Response) -> list[Alert]:
new_alerts = []
cal = Calendar.from_ical(http_response.content)
@@ -34,7 +37,7 @@ class ICALAlertProvider(HTTPAlertProvider):
"""Convert an ICal event to an Alert object. Subclasses must implement this method."""
@staticmethod
def _to_utc_timestamp(value):
def _to_utc_timestamp(value: datetime | date) -> float:
"""Convert a date or datetime value from an iCal field into a UTC UNIX timestamp."""
# Datetime object so we can treat it as-is, check if it has a non-UTC tz and convert it if necessary