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 -8
View File
@@ -1,6 +1,9 @@
from __future__ import annotations
import logging
from datetime import datetime, timedelta, timezone
from threading import Event, Thread
from typing import Any
import pytz
import requests
@@ -25,30 +28,30 @@ class KC2GProp(SolarConditionsProvider):
Designed to run alongside GIROIonosonde even though they produce similar data. KC2G is more reliable and is always
online, but has fewer stations and does not provide LUF data."""
def __init__(self, provider_config):
def __init__(self, provider_config: dict[str, Any]) -> None:
super().__init__("KC2G Propagation Data", provider_config)
self._thread = None
self._stop_event = Event()
self._thread: Thread | None = None
self._stop_event: Event = Event()
def start(self):
def start(self) -> None:
logger.info(f"Set up query of KC2G ionosonde data API every {POLL_INTERVAL} seconds.")
self._thread = Thread(target=self._run, name="KC2GPropProvider", daemon=True)
self._thread.start()
def stop(self):
def stop(self) -> None:
self._stop_event.set()
if self._thread:
self._thread.join(timeout=12)
if self._thread.is_alive():
logger.warning("KC2G ionosonde worker thread did not exit on time and will be killed.")
def _run(self):
def _run(self) -> None:
while True:
self._poll()
if self._stop_event.wait(timeout=POLL_INTERVAL):
break
def _poll(self):
def _poll(self) -> None:
try:
logger.debug("Polling KC2G ionosonde data...")
http_response = requests.get(KC2G_URL, headers=HTTP_HEADERS, timeout=(5, 30))
@@ -61,7 +64,7 @@ class KC2GProp(SolarConditionsProvider):
# Start from existing ionosonde_data so the accumulated time series survives across polls and restarts and
# stations provided only by GIROIonosonde are not discarded
ionosonde_data = dict(self._solar_conditions.ionosonde_data or {})
ionosonde_data: dict[str, Any] = dict(self._solar_conditions.ionosonde_data or {})
updated_count = 0
for reading in http_response.json():