Skip to content

Commit 79e68bf

Browse files
linting
1 parent 8ed4cd1 commit 79e68bf

File tree

6 files changed

+18
-32
lines changed

6 files changed

+18
-32
lines changed

backend/app/api/events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import logging
33

44
from fastapi import APIRouter, Depends, HTTPException, Query, Request, status
5-
6-
logger = logging.getLogger(__name__)
75
from fastapi.responses import StreamingResponse
86
from sqlalchemy import select
97
from sqlalchemy.ext.asyncio import AsyncSession
@@ -14,6 +12,8 @@
1412
from app.models.node_event import NodeEvent
1513
from app.services.sse import sse_manager
1614

15+
logger = logging.getLogger(__name__)
16+
1717
router = APIRouter(prefix="/api", tags=["events"])
1818

1919

backend/app/api/pathfinder.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
from uuid import UUID
32

43
from fastapi import APIRouter, BackgroundTasks, Depends
54
from sqlalchemy import select
@@ -8,8 +7,6 @@
87

98
from app.auth import get_current_user
109
from app.database import get_db
11-
12-
logger = logging.getLogger(__name__)
1310
from app.models.node import Node
1411
from app.schemas.path import HopInfo, PathRequest, PathResult
1512
from app.services.pathfinder import (
@@ -18,6 +15,8 @@
1815
find_max_min_snr_path,
1916
)
2017

18+
logger = logging.getLogger(__name__)
19+
2120
router = APIRouter(prefix="/api/path", tags=["pathfinder"])
2221

2322

backend/app/models/coverage_cache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import uuid
2-
from datetime import datetime
32

43
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, LargeBinary, String
54
from sqlalchemy.dialects.postgresql import UUID

backend/app/services/splat.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,6 @@ def _calculate_required_terrain_tiles(
301301
# .sdf file boundaries
302302
lat_start = lat_tile
303303
lon_start = lon_tile
304-
lat_end = lat_start + 1
305-
lon_end = lon_start + 1
306-
307304
# Generate .sdf file names
308305
sdf_filename = Splat._hgt_filename_to_sdf_filename(tile_name, high_resolution = False)
309306
sdf_hd_filename = Splat._hgt_filename_to_sdf_filename(tile_name, high_resolution = True)

backend/tests/test_coverage.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,12 @@
99
"""
1010
from __future__ import annotations
1111

12-
import io
13-
import math
14-
import struct
1512
import textwrap
16-
from unittest.mock import MagicMock, patch
13+
from unittest.mock import patch
1714

1815
import numpy as np
1916
import pytest
20-
import rasterio
2117
from rasterio.io import MemoryFile
22-
from rasterio.transform import from_bounds
2318

2419
from app.models.coverage_request import CoveragePredictionRequest
2520
from app.services.clutter import (
@@ -227,39 +222,39 @@ def test_climate_enumeration(self):
227222
}
228223
for name, expected_int in climates.items():
229224
content = self._make_lrp(radio_climate=name)
230-
lines = [l.split(";")[0].strip() for l in content.strip().split("\n")]
225+
lines = [ln.split(";")[0].strip() for ln in content.strip().split("\n")]
231226
assert lines[4] == str(expected_int), f"{name} should map to {expected_int}"
232227

233228
def test_polarization_enumeration(self):
234229
h_content = self._make_lrp(polarization="horizontal")
235230
v_content = self._make_lrp(polarization="vertical")
236-
h_line = [l.split(";")[0].strip() for l in h_content.split("\n")][5]
237-
v_line = [l.split(";")[0].strip() for l in v_content.split("\n")][5]
231+
h_line = [ln.split(";")[0].strip() for ln in h_content.split("\n")][5]
232+
v_line = [ln.split(";")[0].strip() for ln in v_content.split("\n")][5]
238233
assert h_line == "0"
239234
assert v_line == "1"
240235

241236
def test_situation_fraction_normalized(self):
242237
content = self._make_lrp(situation_fraction=50.0)
243-
lines = [l.split(";")[0].strip() for l in content.strip().split("\n")]
238+
lines = [ln.split(";")[0].strip() for ln in content.strip().split("\n")]
244239
assert float(lines[6]) == pytest.approx(0.50)
245240

246241
def test_time_fraction_normalized(self):
247242
content = self._make_lrp(time_fraction=90.0)
248-
lines = [l.split(";")[0].strip() for l in content.strip().split("\n")]
243+
lines = [ln.split(";")[0].strip() for ln in content.strip().split("\n")]
249244
assert float(lines[7]) == pytest.approx(0.90)
250245

251246
def test_erp_calculation(self):
252247
# ERP = 10^((tx_power + tx_gain - system_loss - 30) / 10) Watts
253248
# The LRP file formats ERP with %.2f, so we allow rounding tolerance.
254249
content = self._make_lrp(tx_power=17.0, tx_gain=2.0, system_loss=2.0)
255-
lines = [l.split(";")[0].strip() for l in content.strip().split("\n")]
250+
lines = [ln.split(";")[0].strip() for ln in content.strip().split("\n")]
256251
expected_erp = 10 ** ((17.0 + 2.0 - 2.0 - 30) / 10)
257252
assert float(lines[8]) == pytest.approx(expected_erp, abs=0.01)
258253

259254
def test_erp_with_zero_gain_loss(self):
260255
# 20 dBm, 0 dB gain, 0 dB loss → 10^((20-30)/10) = 0.1 W
261256
content = self._make_lrp(tx_power=20.0, tx_gain=0.0, system_loss=0.0)
262-
lines = [l.split(";")[0].strip() for l in content.strip().split("\n")]
257+
lines = [ln.split(";")[0].strip() for ln in content.strip().split("\n")]
263258
assert float(lines[8]) == pytest.approx(0.1, rel=1e-3)
264259

265260
def test_frequency_in_content(self):
@@ -278,31 +273,31 @@ def test_returns_bytes(self):
278273

279274
def test_has_32_levels(self):
280275
content = Splat._create_splat_dcf("plasma", -130.0, -80.0).decode()
281-
data_lines = [l for l in content.split("\n") if l.strip() and not l.startswith(";")]
276+
data_lines = [ln for ln in content.split("\n") if ln.strip() and not ln.startswith(";")]
282277
assert len(data_lines) == 32
283278

284279
def test_levels_from_max_to_min(self):
285280
content = Splat._create_splat_dcf("plasma", -130.0, -80.0).decode()
286-
data_lines = [l for l in content.split("\n") if l.strip() and not l.startswith(";")]
281+
data_lines = [ln for ln in content.split("\n") if ln.strip() and not ln.startswith(";")]
287282
first_dbm = int(data_lines[0].split(":")[0].strip())
288283
last_dbm = int(data_lines[-1].split(":")[0].strip())
289284
assert first_dbm > last_dbm # max at top, min at bottom
290285

291286
def test_max_dbm_is_first_level(self):
292287
content = Splat._create_splat_dcf("plasma", -130.0, -80.0).decode()
293-
data_lines = [l for l in content.split("\n") if l.strip() and not l.startswith(";")]
288+
data_lines = [ln for ln in content.split("\n") if ln.strip() and not ln.startswith(";")]
294289
first_dbm = int(data_lines[0].split(":")[0].strip())
295290
assert first_dbm == -80
296291

297292
def test_min_dbm_is_last_level(self):
298293
content = Splat._create_splat_dcf("plasma", -130.0, -80.0).decode()
299-
data_lines = [l for l in content.split("\n") if l.strip() and not l.startswith(";")]
294+
data_lines = [ln for ln in content.split("\n") if ln.strip() and not ln.startswith(";")]
300295
last_dbm = int(data_lines[-1].split(":")[0].strip())
301296
assert last_dbm == -130
302297

303298
def test_rgb_values_in_range(self):
304299
content = Splat._create_splat_dcf("plasma", -130.0, -80.0).decode()
305-
data_lines = [l for l in content.split("\n") if l.strip() and not l.startswith(";")]
300+
data_lines = [ln for ln in content.split("\n") if ln.strip() and not ln.startswith(";")]
306301
for line in data_lines:
307302
rgb_part = line.split(":")[1]
308303
r, g, b = [int(x) for x in rgb_part.split(",")]

backend/tests/test_pathfinder.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,15 @@
1111
from __future__ import annotations
1212

1313
import math
14-
import struct
15-
from typing import List, Optional
16-
from unittest.mock import patch
14+
from typing import Optional
1715

1816
import numpy as np
1917
import pytest
20-
import rasterio
2118
from rasterio.io import MemoryFile
2219
from rasterio.transform import from_bounds
2320

2421
from app.services.pathfinder import (
2522
COVERAGE_DYNAMIC_RANGE_DB,
26-
LORA_PRESETS,
2723
GraphNode,
2824
_FRIIS_ONLY_PENALTY_DB,
2925
_LORA_MIN_SNR_DB,

0 commit comments

Comments
 (0)