mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-21 06:47:42 +00:00
Autogenerated type safety parameterisation of all methods
This commit is contained in:
+10
-6
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
@@ -11,6 +13,8 @@ from core.activity_utils import get_icon_for_activity
|
||||
from core.call_lookup_helper import get_call_info
|
||||
from core.enums import Continent
|
||||
from core.utils import get_flag_for_dxcc
|
||||
from data.activity_ref import ActivityRef
|
||||
from data.lookup_credentials import LookupCredentials
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -25,9 +29,9 @@ class Alert:
|
||||
# DX (alerting) operator info
|
||||
|
||||
# Callsigns of the operators that has been alerted
|
||||
dx_calls: list | None = None
|
||||
dx_calls: list[str] | None = None
|
||||
# Names of the operators that has been alerted
|
||||
dx_names: list | None = None
|
||||
dx_names: list[str | None] | None = None
|
||||
# Country of the DX operator
|
||||
dx_country: str | None = None
|
||||
# Country flag of the DX operator
|
||||
@@ -64,7 +68,7 @@ class Alert:
|
||||
sig: str | None = None
|
||||
# Activity references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO. Still named
|
||||
# "sig_refs" for API backwards compatibility.
|
||||
sig_refs: list = field(default_factory=list)
|
||||
sig_refs: list[ActivityRef] = field(default_factory=list)
|
||||
|
||||
# Timing info
|
||||
|
||||
@@ -87,7 +91,7 @@ class Alert:
|
||||
# Icon to use when displaying this alert in the web UI. Chosen from the Font Awesome set.
|
||||
icon: str | None = None
|
||||
|
||||
def infer_missing(self, credentials=None):
|
||||
def infer_missing(self, credentials: LookupCredentials | None = None) -> None:
|
||||
"""Infer missing parameters where possible"""
|
||||
|
||||
try:
|
||||
@@ -160,12 +164,12 @@ class Alert:
|
||||
except Exception:
|
||||
logger.exception("Exception while inferring missing data from spot")
|
||||
|
||||
def to_json(self):
|
||||
def to_json(self) -> str:
|
||||
"""JSON serialise"""
|
||||
|
||||
return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True)
|
||||
|
||||
def expired(self):
|
||||
def expired(self) -> bool:
|
||||
"""Decide if this alert has expired (in which case it should not be added to the system in the first place, and not
|
||||
returned by the web server if later requested, and removed by the cleanup functions). "Expired" is defined as
|
||||
either having an end_time in the past, or if it only has a start_time, then that start time was more than 3 hours
|
||||
|
||||
Reference in New Issue
Block a user