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:
@@ -1,6 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from typing import ClassVar
|
||||
from typing import Any, ClassVar
|
||||
|
||||
import requests
|
||||
|
||||
@@ -36,11 +38,11 @@ class Tiles(HTTPSpotProvider):
|
||||
"Other",
|
||||
]
|
||||
|
||||
def __init__(self, provider_config):
|
||||
def __init__(self, provider_config: dict[str, Any]) -> None:
|
||||
super().__init__("Tiles", provider_config, self.SPOTS_URL, self.POLL_INTERVAL_SEC)
|
||||
|
||||
def _http_response_to_spots(self, http_response):
|
||||
new_spots = []
|
||||
def _http_response_to_spots(self, http_response: requests.Response) -> list[Spot]:
|
||||
new_spots: list[Spot] = []
|
||||
# Iterate through source data
|
||||
for source_spot in http_response.json()["spots"]:
|
||||
# Convert to our spot format
|
||||
@@ -84,10 +86,10 @@ class Tiles(HTTPSpotProvider):
|
||||
new_spots.append(spot)
|
||||
return new_spots
|
||||
|
||||
def can_submit_spot(self, activity):
|
||||
def can_submit_spot(self, activity: str) -> bool:
|
||||
return activity == ActivityName.TILES
|
||||
|
||||
def submit_spot(self, spot, credentials):
|
||||
def submit_spot(self, spot: Spot, credentials: dict[str, str]) -> None:
|
||||
# Tiles on the air currently only supports *self* spots
|
||||
if spot.dx_call == spot.de_call:
|
||||
# Figure out a valid mode. Borrowed this from PoLo :)
|
||||
@@ -127,7 +129,7 @@ class Tiles(HTTPSpotProvider):
|
||||
|
||||
# Utility function to keep the first decimal point in a given string but remove any others. Used to parse Tiles'
|
||||
# strange frequency format where we can sometimes have e.g. "14.123.5".
|
||||
def strip_extra_decimal_points(s):
|
||||
def strip_extra_decimal_points(s: str) -> str:
|
||||
parts = s.split(".", 1)
|
||||
if len(parts) == 1:
|
||||
return s
|
||||
|
||||
Reference in New Issue
Block a user