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
+9 -7
View File
@@ -1,6 +1,8 @@
from __future__ import annotations
import logging
from datetime import datetime
from typing import ClassVar
from typing import Any, ClassVar
import requests
from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout
@@ -27,17 +29,17 @@ class SOTA(HTTPSpotProvider):
SUBMIT_URL = "https://api-db2.sota.org.uk/api/spots"
VALID_MODES: ClassVar[list[str]] = ["AM", "CW", "Data", "DV", "FM", "SSB"]
def __init__(self, provider_config):
def __init__(self, provider_config: dict[str, Any]) -> None:
super().__init__("SOTA", provider_config, self.EPOCH_URL, self.POLL_INTERVAL_SEC)
self._api_epoch = ""
self._api_epoch: str = ""
def _http_response_to_spots(self, http_response):
def _http_response_to_spots(self, http_response: requests.Response) -> list[Spot]:
# OK, source data is actually just the epoch at this point. We'll then go on to fetch real data if we know this
# has changed.
epoch_changed = http_response.text != self._api_epoch
self._api_epoch = http_response.text
new_spots = []
new_spots: list[Spot] = []
# OK, if the epoch actually changed, now we make the real request for data.
if epoch_changed:
try:
@@ -83,10 +85,10 @@ class SOTA(HTTPSpotProvider):
logger.warning("Timeout when accessing SOTA spots API.")
return new_spots
def can_submit_spot(self, activity):
def can_submit_spot(self, activity: str) -> bool:
return activity == ActivityName.SOTA
def submit_spot(self, spot, credentials):
def submit_spot(self, spot: Spot, credentials: dict[str, str]) -> None:
# TODO test this method works
access_token = credentials.get("access_token", "")
id_token = credentials.get("id_token", "")