Fix ruff lint errors to unblock CI (import sorting, unused imports, style)

This commit is contained in:
James Smith
2026-03-20 13:51:30 +00:00
parent 90d39f12c1
commit 34e1d25069
14 changed files with 35 additions and 34 deletions

View File

@@ -14,7 +14,7 @@ class SigMFConsumer:
def __init__(
self,
metadata: SigMFMetadata,
on_complete: 'callable | None' = None,
on_complete: callable | None = None,
):
"""
Args:

View File

@@ -12,8 +12,6 @@ from __future__ import annotations
import queue
import time
import numpy as np
from utils.logging import get_logger
from utils.waterfall_fft import (
build_binary_frame,

View File

@@ -113,9 +113,9 @@ class ObservationProfile:
return tasks
@classmethod
def from_row(cls, row) -> 'ObservationProfile':
def from_row(cls, row) -> ObservationProfile:
tasks = []
raw_tasks = row['tasks_json'] if 'tasks_json' in row.keys() else None
raw_tasks = row.get('tasks_json', None)
if raw_tasks:
try:
tasks = normalize_tasks(json.loads(raw_tasks))

View File

@@ -22,7 +22,6 @@ from __future__ import annotations
import json
import queue
import threading
import time
import uuid
from datetime import datetime, timedelta, timezone
from pathlib import Path
@@ -283,6 +282,7 @@ class GroundStationScheduler:
) -> list[ScheduledObservation]:
"""Predict passes for each profile and return ScheduledObservation list."""
from skyfield.api import load, wgs84
from utils.satellite_predict import predict_passes as _predict_passes
try:
@@ -525,8 +525,8 @@ class GroundStationScheduler:
def _attach_sigmf_consumer(self, bus, profile, obs_db_id: int | None) -> None:
"""Attach a SigMFConsumer for raw IQ recording."""
from utils.sigmf import SigMFMetadata
from utils.ground_station.consumers.sigmf_writer import SigMFConsumer
from utils.sigmf import SigMFMetadata
meta = SigMFMetadata(
sample_rate=profile.iq_sample_rate,
@@ -681,8 +681,9 @@ class GroundStationScheduler:
def _insert_observation_record(obs: ScheduledObservation, profile) -> int | None:
try:
from utils.database import get_db
from datetime import datetime, timezone
from utils.database import get_db
with get_db() as conn:
cur = conn.execute('''
INSERT INTO ground_station_observations
@@ -719,8 +720,9 @@ def _insert_event_record(obs_db_id: int | None, event_type: str, payload: str) -
if obs_db_id is None:
return
try:
from utils.database import get_db
from datetime import datetime, timezone
from utils.database import get_db
with get_db() as conn:
conn.execute('''
INSERT INTO ground_station_events (observation_id, event_type, payload_json, timestamp)
@@ -768,9 +770,10 @@ def _build_packet_event(payload, source: str) -> dict[str, Any]:
if parsed is None:
try:
from utils.satellite_telemetry import auto_parse
import base64
from utils.satellite_telemetry import auto_parse
for token in text.replace(',', ' ').split():
cleaned = token.strip()
if not cleaned or len(cleaned) < 8:
@@ -794,8 +797,9 @@ def _build_packet_event(payload, source: str) -> dict[str, Any]:
def _insert_recording_record(obs_db_id: int | None, meta_path: Path, data_path: Path, profile) -> None:
try:
from utils.database import get_db
from datetime import datetime, timezone
from utils.database import get_db
size = data_path.stat().st_size if data_path.exists() else 0
with get_db() as conn:
conn.execute('''
@@ -827,9 +831,10 @@ def _insert_output_record(
metadata: dict[str, Any] | None = None,
) -> int | None:
try:
from utils.database import get_db
from datetime import datetime, timezone
from utils.database import get_db
with get_db() as conn:
cur = conn.execute(
'''

View File

@@ -6,8 +6,6 @@ Uses Skyfield's find_events() for accurate AOS/TCA/LOS event detection.
from __future__ import annotations
import datetime
import math
from typing import Any
from utils.logging import get_logger

View File

@@ -12,11 +12,10 @@ views of raw binary data (hex dump, float32, uint16/32, strings).
from __future__ import annotations
import math
import struct
import string
import struct
from datetime import datetime
# ---------------------------------------------------------------------------
# AX.25 parser
# ---------------------------------------------------------------------------

View File

@@ -22,13 +22,12 @@ from typing import Callable
import numpy as np
from utils.logging import get_logger
# DopplerTracker/DopplerInfo now live in the shared utils/doppler module.
# Import them here so existing code that does
# ``from utils.sstv.sstv_decoder import DopplerTracker``
# continues to work unchanged.
from utils.doppler import DopplerInfo, DopplerTracker # noqa: F401
from utils.logging import get_logger
from .constants import ISS_SSTV_FREQ, SAMPLE_RATE
from .dsp import goertzel_mag, normalize_audio