Use ruff linter to fix issues and provide consistent formatting

This commit is contained in:
Ian Renton
2026-08-15 08:25:54 +01:00
parent 7391c28cd0
commit af3f82c14d
121 changed files with 1989 additions and 996 deletions
+40 -16
View File
@@ -4,7 +4,15 @@ import simplejson
from pyhamtools.frequency import freq_to_band
from pyhamtools.locator import latlong_to_locator
from core.constants import UNKNOWN_BAND, BANDS, CW_MODES, PHONE_MODES, DATA_MODES, MODE_ALIASES, ALL_MODES
from core.constants import (
ALL_MODES,
BANDS,
CW_MODES,
DATA_MODES,
MODE_ALIASES,
PHONE_MODES,
UNKNOWN_BAND,
)
from core.data_store import DATA_STORE
from data.callsign import Callsign
@@ -63,11 +71,25 @@ def infer_mode_from_frequency(freq):
# a spot at 7074.5 kHz will be indicated as LSB, even though it's clearly in the FT8 range. Future updates
# might include other common digimode centres of activity here, but this achieves the main goal of keeping
# large numbers of clearly-FT* spots off the list of people filtering out digimodes.
if (7074 <= khz < 7077) or (10136 <= khz < 10139) or (14074 <= khz < 14077) or (18100 <= khz < 18103) or (
21074 <= khz < 21077) or (24915 <= khz < 24918) or (28074 <= khz < 28077):
if (
(7074 <= khz < 7077)
or (10136 <= khz < 10139)
or (14074 <= khz < 14077)
or (18100 <= khz < 18103)
or (21074 <= khz < 21077)
or (24915 <= khz < 24918)
or (28074 <= khz < 28077)
):
mode = "FT8"
if (7047.5 <= khz < 7050.5) or (10140 <= khz < 10143) or (14080 <= khz < 14083) or (
18104 <= khz < 18107) or (21140 <= khz < 21143) or (24919 <= khz < 24922) or (28180 <= khz < 28183):
if (
(7047.5 <= khz < 7050.5)
or (10140 <= khz < 10143)
or (14080 <= khz < 14083)
or (18104 <= khz < 18107)
or (21140 <= khz < 21143)
or (24919 <= khz < 24922)
or (28180 <= khz < 28183)
):
mode = "FT4"
return mode
except KeyError:
@@ -100,17 +122,19 @@ def get_callsign_object_from_pyhamtools_callinfo(callsign, callinfo):
if lat and lon:
grid = latlong_to_locator(lat, lon)
return Callsign(call=callsign,
home_call=home_call,
country=country,
dxcc_id=dxcc_id,
continent=continent,
cq_zone=cq_zone,
itu_zone=itu_zone,
latitude=lat,
longitude=lon,
grid=grid,
location_source="DXCC")
return Callsign(
call=callsign,
home_call=home_call,
country=country,
dxcc_id=dxcc_id,
continent=continent,
cq_zone=cq_zone,
itu_zone=itu_zone,
latitude=lat,
longitude=lon,
grid=grid,
location_source="DXCC",
)
except (KeyError, ValueError):
# Unknown callsign, can't look anything up, return a Callsign object with basic data so that gets cached