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
+11 -7
View File
@@ -1,7 +1,11 @@
from __future__ import annotations
import logging
from datetime import datetime
from typing import Any
import pytz
import requests
from core.constants import HTTP_HEADERS
from core.enums import ActivityName, ActivityRefType, Mode
@@ -21,14 +25,14 @@ class GMA(HTTPSpotProvider):
# GMA spots don't contain the details of the programme they are for, we need a separate lookup for that
REF_INFO_URL_ROOT = "https://www.gma.rocks/api/ref/?"
def __init__(self, provider_config):
def __init__(self, provider_config: dict[str, Any]) -> None:
# Ensure there is an API key in our config, and set up the query URL using it. If no key is provided,
# disable this spot provider.
self._api_key = provider_config.get("api_key", "")
self._api_key: str = provider_config.get("api_key", "")
if self._api_key == "":
provider_config["enabled"] = False
logger.warning("GMA spot provider configured but no api key was provided, this API will not be queried.")
self._url_data_cache = URLDataCache("GMA")
self._url_data_cache: URLDataCache = URLDataCache("GMA")
super().__init__(
"GMA",
@@ -37,8 +41,8 @@ class GMA(HTTPSpotProvider):
self.POLL_INTERVAL_SEC,
)
def _http_response_to_spots(self, http_response):
new_spots = []
def _http_response_to_spots(self, http_response: requests.Response) -> list[Spot]:
new_spots: list[Spot] = []
# Iterate through source data
if "RCD" in http_response.json():
for source_spot in http_response.json()["RCD"]:
@@ -172,10 +176,10 @@ class GMA(HTTPSpotProvider):
return new_spots
def can_submit_spot(self, activity):
def can_submit_spot(self, activity: str) -> bool:
return activity == ActivityName.GMA
def submit_spot(self, spot, credentials):
def submit_spot(self, spot: Spot, credentials: dict[str, str]) -> None:
# TODO: Implement.
# Spotting to GMA is documented: https://www.cqgma.org/api/doc/apigma_spot.pdf We (or the user) need a GMA account, and to send the password in plaintext(!!)
raise NotImplementedError("GMA upstream spot submission is not yet implemented")