Fix some IDE warnings, mostly around type safety on the Python side

This commit is contained in:
Ian Renton
2026-06-19 21:33:46 +01:00
parent 05ac652cee
commit edb2641f76
42 changed files with 319 additions and 187 deletions

View File

@@ -28,7 +28,8 @@ class GIROIonosonde(SolarConditionsProvider):
self._thread = None
self._stop_event = Event()
def _load_stations(self):
@staticmethod
def _load_stations():
stations = []
with open(STATIONS_INDEX, newline='') as f:
for row in csv.reader(f):

View File

@@ -32,6 +32,9 @@ class HamQSL(HTTPSolarConditionsProvider):
# Some error checking functions in case the data is janky.
def text(tag, default=None):
if sd is None:
logging.warning("HamQSL solar conditions API returned unexpected XML structure")
return default
el = sd.find(tag)
return el.text.strip() if el is not None and el.text else default
@@ -104,7 +107,7 @@ class HamQSL(HTTPSolarConditionsProvider):
"geomag_noise": text("signalnoise"),
"hf_conditions": hf_conditions,
"vhf_conditions": {
"vhf_aurora_northern_hemi": vhf_map.get(("vhf-aurora", "northern_hemi")).title().replace("Lat Aur", "Latitude"),
"vhf_aurora_northern_hemi": (vhf_map.get(("vhf-aurora", "northern_hemi")) or "").title().replace("Lat Aur", "Latitude") or None,
"es_2m_europe": vhf_map.get(("E-Skip", "europe")),
"es_4m_europe": vhf_map.get(("E-Skip", "europe_4m")),
"es_6m_europe": vhf_map.get(("E-Skip", "europe_6m")),

View File

@@ -3,8 +3,8 @@ from core.constants import BANDS
HF_BANDS = [b for b in BANDS if b.is_ham_hf]
def _latest(d):
return d[max(d.keys())] if d else None
def _latest(d) -> float | None:
return float(d[max(d.keys())]) if d else None
def compute_band_states(fof2_dict, muf_dict, luf_dict):

View File

@@ -10,6 +10,7 @@ class SolarConditionsProvider:
def __init__(self, provider_config):
"""Constructor"""
self._solar_conditions_cache = None
self.name = provider_config["name"]
self.enabled = provider_config["enabled"]
self.last_update_time = datetime.min.replace(tzinfo=pytz.UTC)