fix(lint): resolve all ruff E402/I001/F821 errors

- Move pytestmark after all imports in 35 test files (E402: not-at-top)
- Add TYPE_CHECKING guard for FlightProcessor in composition.py (F821)
- Sort import blocks in src/ and tests/ (I001 auto-fix via ruff --fix)
- ruff check src/ tests/ now exits 0 with no errors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Yuzviak
2026-05-11 19:13:42 +03:00
parent 1273ec8eaf
commit bf5b0e3ae2
50 changed files with 114 additions and 116 deletions
+8 -9
View File
@@ -1,14 +1,5 @@
"""Shared test fixtures for GPS-denied-onboard test suite."""
from unittest.mock import AsyncMock, MagicMock
import numpy as np
import pytest
from gps_denied.core.coordinates import CoordinateTransformer
from gps_denied.core.models import ModelManager
from gps_denied.schemas import CameraParameters, GPSPoint
# ---------------------------------------------------------------
# Phase 2 / TEST-03: AC traceability plugin
#
@@ -23,6 +14,14 @@ import json
import re
from collections import defaultdict
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock
import numpy as np
import pytest
from gps_denied.core.coordinates import CoordinateTransformer
from gps_denied.core.models import ModelManager
from gps_denied.schemas import CameraParameters, GPSPoint
_AC_ID_RE = re.compile(r"^AC-(?:\d+\.\d+[a-z]?|NEW-\d+)$")
+2 -2
View File
@@ -3,10 +3,10 @@
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.testing.coord import ecef_to_wgs84, euler_to_quaternion
pytestmark = [pytest.mark.unit]
# --- ECEF → WGS84 ---
def test_ecef_origin_is_on_equator_prime_meridian():
+2 -2
View File
@@ -2,8 +2,6 @@
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.testing.datasets.base import (
DatasetAdapter,
DatasetCapabilities,
@@ -14,6 +12,8 @@ from gps_denied.testing.datasets.base import (
PlatformClass,
)
pytestmark = [pytest.mark.unit]
def test_capabilities_defaults():
cap = DatasetCapabilities(
+2 -2
View File
@@ -5,8 +5,6 @@ from pathlib import Path
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.testing.download import (
DATASET_REGISTRY,
DatasetSpec,
@@ -14,6 +12,8 @@ from gps_denied.testing.download import (
verify_sha256,
)
pytestmark = [pytest.mark.unit]
def test_registry_has_euroc_machine_hall():
assert "euroc_machine_hall" in DATASET_REGISTRY
+2 -2
View File
@@ -13,12 +13,12 @@ from pathlib import Path
import pytest
pytestmark = [pytest.mark.e2e]
from gps_denied.testing.datasets.euroc import EuRoCAdapter
from gps_denied.testing.harness import E2EHarness
from gps_denied.testing.metrics import absolute_trajectory_error
pytestmark = [pytest.mark.e2e]
# CI-tier keeps the prefix short so a full run stays under a couple of minutes.
EUROC_MH01_MAX_FRAMES = 100
+2 -2
View File
@@ -4,14 +4,14 @@ from pathlib import Path
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.testing.datasets.base import (
DatasetNotAvailableError,
PlatformClass,
)
from gps_denied.testing.datasets.euroc import EuRoCAdapter
pytestmark = [pytest.mark.unit]
@pytest.fixture
def fake_euroc_root(tmp_path: Path) -> Path:
+2 -2
View File
@@ -17,12 +17,12 @@ from pathlib import Path
import pytest
pytestmark = [pytest.mark.e2e]
from gps_denied.testing.datasets.euroc import EuRoCAdapter
from gps_denied.testing.harness import E2EHarness
from gps_denied.testing.metrics import absolute_trajectory_error
pytestmark = [pytest.mark.e2e]
MAX_FRAMES = 100
VO_SCALE_M = 0.005 # 5 mm/frame — measured GT median on MH_01
+2 -2
View File
@@ -20,12 +20,12 @@ import cv2
import numpy as np
import pytest
pytestmark = [pytest.mark.e2e]
from gps_denied.core.vo import ORBVisualOdometry
from gps_denied.schemas import CameraParameters
from gps_denied.testing.datasets.euroc import EuRoCAdapter
pytestmark = [pytest.mark.e2e]
# Match CI-tier frame cap used in test_euroc.py
EUROC_MH01_MAX_FRAMES = 100
+2 -2
View File
@@ -7,11 +7,11 @@ Correctness of VO on synthetic is out of scope — that's unit-test territory.
import pytest
pytestmark = [pytest.mark.integration]
from gps_denied.testing.datasets.synthetic import SyntheticAdapter
from gps_denied.testing.harness import E2EHarness, HarnessResult
pytestmark = [pytest.mark.integration]
@pytest.mark.asyncio
async def test_harness_processes_every_frame():
+2 -2
View File
@@ -4,11 +4,11 @@ from pathlib import Path
import pytest
pytestmark = [pytest.mark.e2e]
from gps_denied.testing.datasets.mars_lvig import MARSLVIGAdapter
from gps_denied.testing.harness import E2EHarness
pytestmark = [pytest.mark.e2e]
# Stress tier does not gate on RMSE — featureless sequences legitimately cause
# tracking loss. The gate is whether the pipeline RUNS TO COMPLETION without
# crashing, and what fraction of frames produced any estimate at all.
+2 -2
View File
@@ -4,14 +4,14 @@ from pathlib import Path
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.testing.datasets.base import (
DatasetNotAvailableError,
PlatformClass,
)
from gps_denied.testing.datasets.mars_lvig import MARSLVIGAdapter
pytestmark = [pytest.mark.unit]
@pytest.fixture
def fake_mars_seq(tmp_path: Path) -> Path:
+2 -2
View File
@@ -3,14 +3,14 @@
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.testing.metrics import (
absolute_trajectory_error,
relative_pose_error,
trajectory_rmse,
)
pytestmark = [pytest.mark.unit]
def test_rmse_identical_trajectories_is_zero():
est = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]])
+1 -1
View File
@@ -4,9 +4,9 @@ import numpy as np
import pytest
from gps_denied.testing.datasets.base import PlatformClass
from gps_denied.testing.datasets.synthetic import SyntheticAdapter
pytestmark = [pytest.mark.unit]
from gps_denied.testing.datasets.synthetic import SyntheticAdapter
def test_synthetic_has_raw_imu():
+2 -2
View File
@@ -8,12 +8,12 @@ from pathlib import Path
import pytest
pytestmark = [pytest.mark.e2e]
from gps_denied.testing.datasets.vpair import VPAIRAdapter
from gps_denied.testing.harness import E2EHarness
from gps_denied.testing.metrics import absolute_trajectory_error
pytestmark = [pytest.mark.e2e]
VPAIR_SAMPLE_RMSE_CEILING_M = 20.0 # initial target, calibrate after first runs
+2 -2
View File
@@ -10,14 +10,14 @@ from pathlib import Path
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.testing.datasets.base import (
DatasetNotAvailableError,
PlatformClass,
)
from gps_denied.testing.datasets.vpair import VPAIRAdapter
pytestmark = [pytest.mark.unit]
# ECEF for a point at roughly lat=50.737°, lon=7.095°, alt=350m (Bonn/Eifel region).
# Chosen to hit the real VPAIR geographic area so the adapter's conversion
# produces plausible numbers the tests can assert on.
+2 -2
View File
@@ -13,8 +13,6 @@ from unittest.mock import AsyncMock, MagicMock
import numpy as np
import pytest
pytestmark = [pytest.mark.integration]
from gps_denied.core.chunk_manager import RouteChunkManager
from gps_denied.core.gpr import GlobalPlaceRecognition
from gps_denied.core.graph import FactorGraphOptimizer
@@ -25,6 +23,8 @@ from gps_denied.core.recovery import FailureRecoveryCoordinator
from gps_denied.core.vo import SequentialVisualOdometry
from gps_denied.schemas.graph import FactorGraphConfig
pytestmark = [pytest.mark.integration]
# ---------------------------------------------------------------
# Fixtures
+2 -2
View File
@@ -22,8 +22,6 @@ import time
import numpy as np
import pytest
pytestmark = [pytest.mark.integration]
from gps_denied.core.benchmark import (
AccuracyBenchmark,
BenchmarkResult,
@@ -33,6 +31,8 @@ from gps_denied.core.benchmark import (
from gps_denied.schemas import GPSPoint
from gps_denied.schemas.eskf import ESKFConfig
pytestmark = [pytest.mark.integration]
ORIGIN = GPSPoint(lat=49.0, lon=32.0)
+2 -3
View File
@@ -3,9 +3,6 @@
import json
import pytest
pytestmark = [pytest.mark.integration]
from httpx import ASGITransport, AsyncClient
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
@@ -13,6 +10,8 @@ from gps_denied.app import app
from gps_denied.db.engine import get_session
from gps_denied.db.models import Base
pytestmark = [pytest.mark.integration]
@pytest.fixture
async def override_get_session():
+2 -2
View File
@@ -3,14 +3,14 @@
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.chunk_manager import RouteChunkManager
from gps_denied.core.graph import FactorGraphOptimizer
from gps_denied.schemas.chunk import ChunkStatus
from gps_denied.schemas.graph import FactorGraphConfig
from gps_denied.schemas.metric import Sim3Transform
pytestmark = [pytest.mark.unit]
@pytest.fixture
def chunk_manager():
+2 -2
View File
@@ -3,8 +3,6 @@
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.coordinates import (
CoordinateTransformer,
OriginNotSetError,
@@ -14,6 +12,8 @@ from gps_denied.core.coordinates import (
)
from gps_denied.schemas import CameraParameters, GPSPoint
pytestmark = [pytest.mark.unit]
@pytest.fixture
def transformer():
+2 -3
View File
@@ -1,15 +1,14 @@
"""Tests for the database layer — CRUD, cascade, transactions."""
import pytest
pytestmark = [pytest.mark.integration]
from sqlalchemy import event
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from gps_denied.db.models import Base
from gps_denied.db.repository import FlightRepository
pytestmark = [pytest.mark.integration]
@pytest.fixture
async def session():
+2 -2
View File
@@ -3,13 +3,13 @@
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.coordinates import CoordinateTransformer
from gps_denied.core.eskf import ESKF
from gps_denied.schemas import GPSPoint
from gps_denied.schemas.eskf import ConfidenceTier, ESKFConfig, IMUMeasurement
pytestmark = [pytest.mark.unit]
@pytest.fixture
def eskf():
+2 -2
View File
@@ -3,12 +3,12 @@
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.gpr import GlobalPlaceRecognition
from gps_denied.core.models import ModelManager
from gps_denied.schemas.gpr import TileCandidate
pytestmark = [pytest.mark.unit]
@pytest.fixture
def gpr():
+2 -2
View File
@@ -17,12 +17,12 @@ import time
import numpy as np
import pytest
pytestmark = [pytest.mark.blackbox, pytest.mark.ac("AC-4.3")]
from gps_denied.core.mavlink import _confidence_to_fix_type, _eskf_to_gps_input
from gps_denied.schemas import GPSPoint
from gps_denied.schemas.eskf import ConfidenceTier, ESKFState
pytestmark = [pytest.mark.blackbox, pytest.mark.ac("AC-4.3")]
_ORIGIN = GPSPoint(lat=49.0, lon=32.0)
+2 -2
View File
@@ -3,14 +3,14 @@
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.graph import FactorGraphOptimizer
from gps_denied.schemas import GPSPoint
from gps_denied.schemas.graph import FactorGraphConfig
from gps_denied.schemas.metric import Sim3Transform
from gps_denied.schemas.vo import RelativePose
pytestmark = [pytest.mark.unit]
@pytest.fixture
def optimizer():
+2 -3
View File
@@ -1,13 +1,12 @@
"""Tests for the health endpoint."""
import pytest
pytestmark = [pytest.mark.integration]
from httpx import ASGITransport, AsyncClient
from gps_denied.app import app
pytestmark = [pytest.mark.integration]
@pytest.mark.asyncio
async def test_health_returns_ok():
+2 -2
View File
@@ -14,8 +14,6 @@ import time
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.mavlink import (
MAVLinkBridge,
MockMAVConnection,
@@ -27,6 +25,8 @@ from gps_denied.schemas import GPSPoint
from gps_denied.schemas.eskf import ConfidenceTier, ESKFState
from gps_denied.schemas.mavlink import GPSInputMessage, RelocalizationRequest
pytestmark = [pytest.mark.unit]
# ---------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------
+2 -2
View File
@@ -3,14 +3,14 @@
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.metric import MetricRefinement
from gps_denied.core.models import ModelManager
from gps_denied.schemas import GPSPoint
from gps_denied.schemas.metric import AlignmentResult, ChunkAlignmentResult
from gps_denied.schemas.satellite import TileBounds
pytestmark = [pytest.mark.unit]
@pytest.fixture
def metric():
+2 -2
View File
@@ -5,11 +5,11 @@ import cv2
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.pipeline import ImageInputPipeline, QueueFullError
from gps_denied.schemas.image import ImageBatch
pytestmark = [pytest.mark.unit]
@pytest.fixture
def pipeline(tmp_path):
+2 -2
View File
@@ -5,8 +5,6 @@ from unittest.mock import AsyncMock, MagicMock
import numpy as np
import pytest
pytestmark = [pytest.mark.integration]
from gps_denied.core.chunk_manager import RouteChunkManager
from gps_denied.core.gpr import GlobalPlaceRecognition
from gps_denied.core.graph import FactorGraphOptimizer
@@ -17,6 +15,8 @@ from gps_denied.core.recovery import FailureRecoveryCoordinator
from gps_denied.core.vo import SequentialVisualOdometry
from gps_denied.schemas.graph import FactorGraphConfig
pytestmark = [pytest.mark.integration]
@pytest.fixture
def processor():
+2 -2
View File
@@ -14,14 +14,14 @@ from unittest.mock import AsyncMock, MagicMock
import numpy as np
import pytest
pytestmark = [pytest.mark.integration]
from gps_denied.core.coordinates import CoordinateTransformer
from gps_denied.core.processor import FlightProcessor, TrackingState
from gps_denied.core.rotation import ImageRotationManager
from gps_denied.schemas import CameraParameters, GPSPoint
from gps_denied.schemas.vo import RelativePose
pytestmark = [pytest.mark.integration]
# ---------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------
+2 -2
View File
@@ -3,8 +3,6 @@
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.chunk_manager import RouteChunkManager
from gps_denied.core.gpr import GlobalPlaceRecognition
from gps_denied.core.graph import FactorGraphOptimizer
@@ -13,6 +11,8 @@ from gps_denied.core.models import ModelManager
from gps_denied.core.recovery import FailureRecoveryCoordinator
from gps_denied.schemas.graph import FactorGraphConfig
pytestmark = [pytest.mark.unit]
@pytest.fixture
def recovery():
+2 -2
View File
@@ -5,13 +5,13 @@ from datetime import datetime, timezone
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.rotation import IImageMatcher, ImageRotationManager
from gps_denied.schemas import GPSPoint
from gps_denied.schemas.rotation import RotationResult
from gps_denied.schemas.satellite import TileBounds
pytestmark = [pytest.mark.unit]
@pytest.fixture
def rotation_manager():
+2 -2
View File
@@ -3,12 +3,12 @@
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.satellite import SatelliteDataManager
from gps_denied.schemas import GPSPoint
from gps_denied.utils import mercator
pytestmark = [pytest.mark.unit]
# ---------------------------------------------------------------
# Mercator utils
# ---------------------------------------------------------------
+2 -3
View File
@@ -3,9 +3,6 @@
from datetime import datetime, timezone
import pytest
pytestmark = [pytest.mark.unit]
from pydantic import ValidationError
from gps_denied.config import get_settings
@@ -20,6 +17,8 @@ from gps_denied.schemas.flight import (
Waypoint,
)
pytestmark = [pytest.mark.unit]
# ── GPSPoint ──────────────────────────────────────────────────────────────
@pytest.mark.ac("AC-6.3")
+2 -2
View File
@@ -3,8 +3,6 @@
import numpy as np
import pytest
pytestmark = [pytest.mark.unit]
from gps_denied.core.models import ModelManager
from gps_denied.core.vo import (
CuVSLAMVisualOdometry,
@@ -16,6 +14,8 @@ from gps_denied.core.vo import (
from gps_denied.schemas import CameraParameters
from gps_denied.schemas.vo import Features, Matches
pytestmark = [pytest.mark.unit]
@pytest.fixture
def vo():