mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 22:37:44 +00:00
Autogenerated type safety parameterisation of all methods
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
from datetime import datetime
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
import diskcache
|
||||
import pytz
|
||||
|
||||
from core.data_store import DATA_STORE
|
||||
from data.callsign import Callsign
|
||||
from data.lookup_credentials import LookupCredentials
|
||||
|
||||
|
||||
class CallsignDataProvider:
|
||||
"""Generic callsign reference data provider class. Subclasses of this set up the various mechanisms via which
|
||||
Spothole can look up data for callsigns."""
|
||||
|
||||
def __init__(self, name, provider_config, storage):
|
||||
def __init__(self, name: str, provider_config: dict[str, Any], storage: diskcache.Cache) -> None:
|
||||
"""Constructor. As well as name and config, provide the storage object from DATA_STORE that will be used to
|
||||
store the result of lookups to speed up future access."""
|
||||
|
||||
@@ -21,18 +27,18 @@ class CallsignDataProvider:
|
||||
self.lookup_count = 0
|
||||
self._storage = storage
|
||||
|
||||
def start(self):
|
||||
def start(self) -> None:
|
||||
"""Start the provider. This should return immediately after spawning threads to access remote resources, if
|
||||
needed."""
|
||||
|
||||
raise NotImplementedError("Subclasses must implement this method")
|
||||
|
||||
def stop(self):
|
||||
def stop(self) -> None:
|
||||
"""Stop any threads and prepare for application shutdown"""
|
||||
|
||||
raise NotImplementedError("Subclasses must implement this method")
|
||||
|
||||
def lookup(self, callsign, lookup_credentials):
|
||||
def lookup(self, callsign: str, lookup_credentials: LookupCredentials | None) -> Callsign | None:
|
||||
"""Looks up data for the provided callsign. Takes a LookupCredentials object, which provides any credentials
|
||||
that have been provided by the user for this session (QRZ.com/HamQTH) to allow us to look up using those
|
||||
services on the user's behalf. (Clublog is looked up using an API key owned by the server and provided in its
|
||||
@@ -57,7 +63,7 @@ class CallsignDataProvider:
|
||||
else:
|
||||
return None
|
||||
|
||||
def _perform_new_lookup(self, callsign, lookup_credentials):
|
||||
def _perform_new_lookup(self, callsign: str, lookup_credentials: LookupCredentials | None) -> Callsign | None:
|
||||
"""Makes a new request to the data source for callsign data."""
|
||||
|
||||
raise NotImplementedError("Subclasses must implement this method")
|
||||
|
||||
Reference in New Issue
Block a user