fix: resolve ruff lint errors and add lint CI job

Remove unused imports (deque, sys, Opcode, struct, _REPLAY_ADJUSTABLE_OPCODES)
across 4 active Python files and refactor semicolons to separate statements
in radar_protocol.py. Add ruff lint job to CI workflow targeting only the
active files (excludes legacy GUI_V*.py and v7/).
This commit is contained in:
Jason
2026-04-08 17:28:22 +03:00
parent 9df73fe994
commit 6a117dd324
5 changed files with 45 additions and 12 deletions
+28
View File
@@ -7,6 +7,34 @@ on:
branches: [main, develop] branches: [main, develop]
jobs: jobs:
# ===========================================================================
# Job 0: Ruff Lint (active Python files only)
# Excludes legacy GUI_V*.py files and untracked v7/ directory
# ===========================================================================
lint:
name: Ruff Lint (active files)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install ruff
run: pip install ruff
- name: Run ruff on active files
run: |
ruff check \
9_Firmware/9_3_GUI/radar_protocol.py \
9_Firmware/9_3_GUI/radar_dashboard.py \
9_Firmware/9_3_GUI/smoke_test.py \
9_Firmware/9_3_GUI/test_radar_dashboard.py
# =========================================================================== # ===========================================================================
# Job 1: Python Host Software Tests (58 tests) # Job 1: Python Host Software Tests (58 tests)
# radar_protocol, radar_dashboard, FT2232H connection, replay, opcodes, e2e # radar_protocol, radar_dashboard, FT2232H connection, replay, opcodes, e2e
+1 -2
View File
@@ -21,7 +21,6 @@ Usage:
python radar_dashboard.py --record # Launch with HDF5 recording python radar_dashboard.py --record # Launch with HDF5 recording
""" """
import sys
import os import os
import time import time
import queue import queue
@@ -45,7 +44,7 @@ from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from radar_protocol import ( from radar_protocol import (
RadarProtocol, FT2232HConnection, ReplayConnection, RadarProtocol, FT2232HConnection, ReplayConnection,
DataRecorder, RadarAcquisition, DataRecorder, RadarAcquisition,
RadarFrame, StatusResponse, Opcode, RadarFrame, StatusResponse,
NUM_RANGE_BINS, NUM_DOPPLER_BINS, WATERFALL_DEPTH, NUM_RANGE_BINS, NUM_DOPPLER_BINS, WATERFALL_DEPTH,
) )
+15 -8
View File
@@ -24,7 +24,7 @@ import logging
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Optional, List, Tuple, Dict, Any from typing import Optional, List, Tuple, Dict, Any
from enum import IntEnum from enum import IntEnum
from collections import deque
import numpy as np import numpy as np
@@ -764,13 +764,20 @@ class ReplayConnection:
dq = int(np.clip(dop_q[rbin, dbin], -32768, 32767)) dq = int(np.clip(dop_q[rbin, dbin], -32768, 32767))
d = 1 if det[rbin, dbin] else 0 d = 1 if det[rbin, dbin] else 0
buf[pos] = HEADER_BYTE; pos += 1 buf[pos] = HEADER_BYTE
buf[pos:pos+2] = rq_bytes; pos += 2 pos += 1
buf[pos:pos+2] = ri_bytes; pos += 2 buf[pos:pos+2] = rq_bytes
buf[pos:pos+2] = struct.pack(">h", di); pos += 2 pos += 2
buf[pos:pos+2] = struct.pack(">h", dq); pos += 2 buf[pos:pos+2] = ri_bytes
buf[pos] = d; pos += 1 pos += 2
buf[pos] = FOOTER_BYTE; pos += 1 buf[pos:pos+2] = struct.pack(">h", di)
pos += 2
buf[pos:pos+2] = struct.pack(">h", dq)
pos += 2
buf[pos] = d
pos += 1
buf[pos] = FOOTER_BYTE
pos += 1
return bytes(buf) return bytes(buf)
-1
View File
@@ -27,7 +27,6 @@ Exit codes:
import sys import sys
import os import os
import time import time
import struct
import argparse import argparse
import logging import logging
+1 -1
View File
@@ -21,7 +21,7 @@ from radar_protocol import (
HEADER_BYTE, FOOTER_BYTE, STATUS_HEADER_BYTE, HEADER_BYTE, FOOTER_BYTE, STATUS_HEADER_BYTE,
NUM_RANGE_BINS, NUM_DOPPLER_BINS, NUM_CELLS, NUM_RANGE_BINS, NUM_DOPPLER_BINS, NUM_CELLS,
DATA_PACKET_SIZE, DATA_PACKET_SIZE,
_HARDWARE_ONLY_OPCODES, _REPLAY_ADJUSTABLE_OPCODES, _HARDWARE_ONLY_OPCODES,
) )