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
+21 -18
View File
@@ -1,7 +1,10 @@
from __future__ import annotations
import importlib
import logging
import os
import sys
from typing import Any
import yaml
@@ -16,25 +19,25 @@ if not os.path.isfile("config.yml"):
# Load config
with open("config.yml") as f:
config = yaml.safe_load(f)
config: dict[str, Any] = yaml.safe_load(f)
logger.info("Loaded config.")
BASE_URL = config.get("base_url", "http://localhost:8080")
MAX_SPOT_AGE = config.get("max_spot_age_sec", 3600)
MAX_ALERT_AGE = config.get("max_alert_age_sec", 604800)
SERVER_OWNER_CALLSIGN = config.get("server_owner_callsign", "N0CALL")
WEB_SERVER_PORT = config.get("web_server_port", 8080)
TELNET_SERVER_ENABLED = config.get("telnet_server_enabled", False)
TELNET_SERVER_ADDRESS = config.get("telnet_server_address", "localhost")
TELNET_SERVER_PORT = config.get("telnet_server_port", 7373)
ALLOW_SPOTTING = config.get("allow_spotting", True)
ALLOW_UPSTREAM_SPOTTING = config.get("allow_upstream_spotting", True)
WEB_UI_OPTIONS = config.get("web_ui_options", {})
API_ONLY_MODE = config.get("api_only_mode", False)
RECAPTCHA_SECRET_KEY = config.get("recaptcha_secret_key", "")
RECAPTCHA_SITE_KEY = config.get("recaptcha_site_key", "")
LOG_LEVEL = config.get("log_level", "INFO")
LOG_WEB_REQUESTS = config.get("log_web_requests", False)
BASE_URL: str = config.get("base_url", "http://localhost:8080")
MAX_SPOT_AGE: int = config.get("max_spot_age_sec", 3600)
MAX_ALERT_AGE: int = config.get("max_alert_age_sec", 604800)
SERVER_OWNER_CALLSIGN: str = config.get("server_owner_callsign", "N0CALL")
WEB_SERVER_PORT: int = config.get("web_server_port", 8080)
TELNET_SERVER_ENABLED: bool = config.get("telnet_server_enabled", False)
TELNET_SERVER_ADDRESS: str = config.get("telnet_server_address", "localhost")
TELNET_SERVER_PORT: int = config.get("telnet_server_port", 7373)
ALLOW_SPOTTING: bool = config.get("allow_spotting", True)
ALLOW_UPSTREAM_SPOTTING: bool = config.get("allow_upstream_spotting", True)
WEB_UI_OPTIONS: dict[str, Any] = config.get("web_ui_options", {})
API_ONLY_MODE: bool = config.get("api_only_mode", False)
RECAPTCHA_SECRET_KEY: str = config.get("recaptcha_secret_key", "")
RECAPTCHA_SITE_KEY: str = config.get("recaptcha_site_key", "")
LOG_LEVEL: str = config.get("log_level", "INFO")
LOG_WEB_REQUESTS: bool = config.get("log_web_requests", False)
WEB_UI_OPTIONS["qrz_enabled"] = any(p["class"] == "QRZ" and p["enabled"] for p in config["callsign_data_providers"])
WEB_UI_OPTIONS["hamqth_enabled"] = any(
@@ -44,7 +47,7 @@ WEB_UI_OPTIONS["recaptcha_site_key"] = RECAPTCHA_SITE_KEY
WEB_UI_OPTIONS["allow_upstream_spotting"] = ALLOW_SPOTTING and ALLOW_UPSTREAM_SPOTTING
def create_provider_from_config(package, config_providers_entry):
def create_provider_from_config(package: str, config_providers_entry: dict[str, Any]) -> Any:
"""Utility method to get a provider based on the class specified in its config entry. You must also provide the
package to look for it in, as there are several types of provider. e.g. package "providers.spot", where the config
entry is for a POTA spot provider."""