Skip to content

Commit df50186

Browse files
committed
fix(ty): correct invalid return types
fixes #1503
1 parent 98648b4 commit df50186

20 files changed

Lines changed: 44 additions & 35 deletions

ardupilot_methodic_configurator/data_model_template_overview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ def columns() -> tuple[str, ...]:
5050
)
5151

5252
def attributes(self) -> list[str]:
53-
return self.__dict__.keys() # type: ignore[return-value]
53+
return list(self.__dict__)

ardupilot_methodic_configurator/tempcal_imu.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def IMUs(self) -> list[int]: # noqa: N802
211211
if len(self.accel.keys()) != len(self.gyro.keys()):
212212
logging.critical("accel and gyro data doesn't match")
213213
sys.exit(1)
214-
return self.accel.keys() # type: ignore[return-value]
214+
return list(self.accel)
215215

216216
def add_accel(self, imu: int, temperature: float, time: float, value: Vector3) -> None:
217217
if imu not in self.accel:
@@ -260,26 +260,26 @@ def filter(self, width_s: int) -> None:
260260
def accel_at_temp(self, imu: int, axis: str, temperature: float) -> float:
261261
"""Return the accel value closest to the given temperature."""
262262
if temperature < self.accel[imu]["T"][0]:
263-
return self.accel[imu][axis][0] # type: ignore[no-any-return]
263+
return float(self.accel[imu][axis][0])
264264
for i in range(len(self.accel[imu]["T"]) - 1):
265265
if self.accel[imu]["T"][i] <= temperature <= self.accel[imu]["T"][i + 1]:
266266
v1 = self.accel[imu][axis][i]
267267
v2 = self.accel[imu][axis][i + 1]
268268
p = (temperature - self.accel[imu]["T"][i]) / (self.accel[imu]["T"][i + 1] - self.accel[imu]["T"][i])
269-
return v1 + (v2 - v1) * p # type: ignore[no-any-return]
270-
return self.accel[imu][axis][-1] # type: ignore[no-any-return]
269+
return float(v1 + (v2 - v1) * p)
270+
return float(self.accel[imu][axis][-1])
271271

272272
def gyro_at_temp(self, imu: int, axis: str, temperature: float) -> float:
273273
"""Return the gyro value closest to the given temperature."""
274274
if temperature < self.gyro[imu]["T"][0]:
275-
return self.gyro[imu][axis][0] # type: ignore[no-any-return]
275+
return float(self.gyro[imu][axis][0])
276276
for i in range(len(self.gyro[imu]["T"]) - 1):
277277
if self.gyro[imu]["T"][i] <= temperature <= self.gyro[imu]["T"][i + 1]:
278278
v1 = self.gyro[imu][axis][i]
279279
v2 = self.gyro[imu][axis][i + 1]
280280
p = (temperature - self.gyro[imu]["T"][i]) / (self.gyro[imu]["T"][i + 1] - self.gyro[imu]["T"][i])
281-
return v1 + (v2 - v1) * p # type: ignore[no-any-return]
282-
return self.gyro[imu][axis][-1] # type: ignore[no-any-return]
281+
return float(v1 + (v2 - v1) * p)
282+
return float(self.gyro[imu][axis][-1])
283283

284284

285285
def constrain(value: float, minv: float, maxv: float) -> Union[float, int]:

tests/acceptance_use_fc_params_from_file.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import os
1717
from argparse import ArgumentParser
18+
from collections.abc import Generator
1819
from pathlib import Path
1920
from tempfile import TemporaryDirectory
2021
from unittest.mock import MagicMock, patch
@@ -32,7 +33,7 @@
3233

3334

3435
@pytest.fixture
35-
def temp_vehicle_dir() -> str:
36+
def temp_vehicle_dir() -> Generator[str, None, None]:
3637
"""Fixture providing a temporary directory for vehicle configuration."""
3738
with TemporaryDirectory(prefix="test_vehicle_") as tmpdir:
3839
yield tmpdir

tests/bdd_frontend_tkinter_show.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ class TestTooltipFunctionality: # pylint: disable=too-many-public-methods
659659
"""Test the Tooltip class and related functions."""
660660

661661
@pytest.fixture(autouse=True)
662-
def reset_active_tooltip(self) -> None:
662+
def reset_active_tooltip(self) -> Generator[None, None, None]:
663663
"""Ensure tooltip singleton state does not leak across tests."""
664664
Tooltip._active_tooltip = None
665665
yield

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from test_data_model_vehicle_components_common import SAMPLE_DOC_DICT, ComponentDataModelFixtures
3131

3232
from ardupilot_methodic_configurator.backend_filesystem import LocalFilesystem
33+
from ardupilot_methodic_configurator.backend_filesystem_vehicle_components import VehicleComponents
3334
from ardupilot_methodic_configurator.backend_flightcontroller import FlightController
3435
from ardupilot_methodic_configurator.data_model_parameter_editor import ParameterEditor
3536
from ardupilot_methodic_configurator.frontend_tkinter_base_window import BaseWindow
@@ -156,7 +157,7 @@ def _mock_context(config: Optional[MockConfiguration] = None) -> tuple[contextli
156157

157158
# Make all fixtures available across test files
158159
@pytest.fixture
159-
def vehicle_components() -> ComponentDataModelFixtures:
160+
def vehicle_components() -> VehicleComponents:
160161
"""Create a VehicleComponents instance."""
161162
return ComponentDataModelFixtures.create_vehicle_components()
162163

tests/test_backend_flightcontroller_connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
import serial.tools.list_ports_common
2424
from pymavlink import mavutil
2525

26-
if TYPE_CHECKING:
27-
from ardupilot_methodic_configurator.backend_flightcontroller_protocols import MavlinkConnection
28-
2926
from ardupilot_methodic_configurator.backend_flightcontroller_connection import (
3027
DEFAULT_BAUDRATE,
3128
SUPPORTED_BAUDRATES,
@@ -43,6 +40,9 @@
4340
)
4441
from ardupilot_methodic_configurator.data_model_flightcontroller_info import FlightControllerInfo
4542

43+
if TYPE_CHECKING:
44+
from ardupilot_methodic_configurator.backend_flightcontroller_protocols import MavlinkConnection
45+
4646
# pylint: disable=protected-access, too-many-lines
4747

4848

tests/test_data_model_flightcontroller_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def fc_info_with_complete_data(self, fc_info_with_basic_data) -> FlightControlle
7575
return fc_info
7676

7777
@pytest.fixture
78-
def mocked_mavutil_enums(self) -> MagicMock:
78+
def mocked_mavutil_enums(self) -> dict[str, dict[int, MagicMock]]:
7979
"""Fixture providing mocked mavutil enums."""
8080
return {
8181
"MAV_PROTOCOL_CAPABILITY": {

tests/test_extract_missing_translations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import sys
1515
import tempfile
1616
import unittest
17+
from collections.abc import Generator
1718
from unittest.mock import MagicMock, call, patch
1819

1920
import pytest
@@ -316,7 +317,7 @@ def test_main(self, mock_logging, mock_output, mock_extract, mock_args) -> None:
316317

317318
# These are pytest-style standalone functions, outside the class
318319
@pytest.fixture
319-
def temp_dir() -> str:
320+
def temp_dir() -> Generator[str, None, None]:
320321
with tempfile.TemporaryDirectory() as tmpdirname:
321322
yield tmpdirname
322323

tests/test_extract_param_defaults.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
import unittest
14+
from collections.abc import Generator
1415
from unittest.mock import MagicMock, Mock, call, patch
1516

1617
import pytest
@@ -30,7 +31,7 @@
3031

3132

3233
@pytest.fixture
33-
def mock_print() -> Mock:
34+
def mock_print() -> Generator[Mock, None, None]:
3435
with patch("builtins.print") as mock:
3536
yield mock
3637

tests/test_frontend_tkinter_component_editor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
import tkinter as tk
14+
from collections.abc import Generator
1415
from tkinter import ttk
1516
from unittest.mock import MagicMock, patch
1617

@@ -34,7 +35,7 @@
3435

3536

3637
@pytest.fixture
37-
def editor_with_mocked_root() -> ComponentEditorWindow:
38+
def editor_with_mocked_root() -> Generator[ComponentEditorWindow, None, None]:
3839
"""Create a mock ComponentEditorWindow for testing."""
3940
# Create the class without initialization
4041
with patch.object(ComponentEditorWindow, "__init__", return_value=None):

0 commit comments

Comments
 (0)