Skip to content

Commit 47c87e7

Browse files
committed
fix(pylint): fix pylint issues
1 parent 520a2f8 commit 47c87e7

8 files changed

+29
-60
lines changed

ardupilot_methodic_configurator/data_model_vehicle_components_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def update_json_structure(self) -> None:
242242

243243
# Handle legacy battery monitor protocol migration for protocols that don't need hardware connections
244244
# This is a local import to avoid a circular import dependency
245-
from ardupilot_methodic_configurator.data_model_vehicle_components_validation import ( # pylint: disable=import-outside-toplevel # noqa: PLC0415
245+
from ardupilot_methodic_configurator.data_model_vehicle_components_validation import ( # pylint: disable=import-outside-toplevel, cyclic-import # noqa: PLC0415
246246
BATT_MONITOR_CONNECTION,
247247
OTHER_PORTS,
248248
)

tests/conftest.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,46 +57,46 @@ def root() -> Generator[tk.Tk, None, None]:
5757
"""Create and clean up Tk root window for testing (session-scoped for robustness)."""
5858
# Try to reuse existing root or create new one
5959
try:
60-
root = tk._default_root # type: ignore[attr-defined]
61-
if root is None:
62-
root = tk.Tk()
60+
root_instance = tk._default_root # type: ignore[attr-defined] # pylint: disable=protected-access
61+
if root_instance is None:
62+
root_instance = tk.Tk()
6363
except (AttributeError, tk.TclError):
64-
root = tk.Tk()
64+
root_instance = tk.Tk()
6565

66-
root.withdraw() # Hide the main window during tests
66+
root_instance.withdraw() # Hide the main window during tests
6767

6868
# Patch the iconphoto method to prevent errors with mock PhotoImage
69-
original_iconphoto = root.iconphoto
69+
original_iconphoto = root_instance.iconphoto
7070

71-
def mock_iconphoto(*args, **kwargs) -> None:
71+
def mock_iconphoto(*args, **kwargs) -> None: # pylint: disable=unused-argument
7272
pass
7373

74-
root.iconphoto = mock_iconphoto # type: ignore[method-assign]
74+
root_instance.iconphoto = mock_iconphoto # type: ignore[method-assign]
7575

76-
yield root
76+
yield root_instance
7777

7878
# Restore original method and destroy root
79-
root.iconphoto = original_iconphoto # type: ignore[method-assign]
79+
root_instance.iconphoto = original_iconphoto # type: ignore[method-assign]
8080

8181
# Only destroy if we're the last test
8282
with contextlib.suppress(tk.TclError):
83-
root.quit() # Close the event loop
83+
root_instance.quit() # Close the event loop
8484

8585

8686
@pytest.fixture
8787
def tk_root() -> Generator[tk.Tk, None, None]:
8888
"""Provide a real Tkinter root for integration tests (legacy name for compatibility)."""
89-
root = None
89+
tk_root_instance = None
9090
try:
91-
root = tk.Tk()
92-
root.withdraw()
93-
yield root
91+
tk_root_instance = tk.Tk()
92+
tk_root_instance.withdraw()
93+
yield tk_root_instance
9494
except tk.TclError:
9595
pytest.skip("Tkinter not available in test environment")
9696
finally:
97-
if root is not None:
97+
if tk_root_instance is not None:
9898
with contextlib.suppress(tk.TclError):
99-
root.destroy()
99+
tk_root_instance.destroy()
100100

101101

102102
@pytest.fixture

tests/test_backend_filesystem.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ardupilot_methodic_configurator.annotate_params import Par
2222
from ardupilot_methodic_configurator.backend_filesystem import LocalFilesystem, is_within_tolerance
2323

24-
# pylint: disable=too-many-lines
24+
# pylint: disable=too-many-lines, too-many-arguments, too-many-positional-arguments
2525

2626

2727
class TestLocalFilesystem(unittest.TestCase): # pylint: disable=too-many-public-methods
@@ -1082,7 +1082,7 @@ def test_user_can_skip_copying_vehicle_image_from_template(
10821082
@patch("ardupilot_methodic_configurator.backend_filesystem.os_path.join")
10831083
@patch("ardupilot_methodic_configurator.backend_filesystem.shutil_copy2")
10841084
@patch("ardupilot_methodic_configurator.backend_filesystem.os_path.isdir")
1085-
def test_copy_vehicle_image_defaults_to_false(self, mock_isdir, mock_copy2, mock_join, mock_listdir, mock_exists) -> None:
1085+
def test_copy_vehicle_image_defaults_to_false(self, mock_isdir, mock_copy2, mock_join, mock_listdir, mock_exists) -> None: # pylint: disable=unused-argument
10861086
"""
10871087
Vehicle image copying defaults to disabled.
10881088
@@ -1103,7 +1103,9 @@ def test_copy_vehicle_image_defaults_to_false(self, mock_isdir, mock_copy2, mock
11031103
# Act: Copy template files without specifying copy_vehicle_image
11041104
# (this should cause an error since parameter is required)
11051105
with pytest.raises(TypeError):
1106-
lfs.copy_template_files_to_new_vehicle_dir("template_dir", "new_vehicle_dir", blank_change_reason=False)
1106+
lfs.copy_template_files_to_new_vehicle_dir(
1107+
"template_dir", "new_vehicle_dir", blank_change_reason=False, copy_vehicle_image=False
1108+
)
11071109

11081110
@patch("ardupilot_methodic_configurator.backend_filesystem.os_path.exists")
11091111
@patch("ardupilot_methodic_configurator.backend_filesystem.os_listdir")

tests/test_frontend_tkinter_autoresize_combobox.py

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,15 @@
1010
SPDX-License-Identifier: GPL-3.0-or-later
1111
"""
1212

13-
import contextlib
1413
import tkinter as tk
15-
from collections.abc import Generator
1614
from tkinter import ttk
1715
from unittest.mock import patch
1816

1917
import pytest
2018

2119
from ardupilot_methodic_configurator.frontend_tkinter_autoresize_combobox import AutoResizeCombobox, update_combobox_width
2220

23-
24-
@pytest.fixture(scope="session")
25-
def root() -> Generator[tk.Tk, None, None]:
26-
"""Create and clean up Tk root window for testing."""
27-
# Try to reuse existing root or create new one
28-
try:
29-
root = tk._default_root # type: ignore[attr-defined]
30-
if root is None:
31-
root = tk.Tk()
32-
except (AttributeError, tk.TclError):
33-
root = tk.Tk()
34-
35-
root.withdraw() # Hide the main window during tests
36-
37-
# Patch the iconphoto method to prevent errors with mock PhotoImage
38-
original_iconphoto = root.iconphoto
39-
40-
def mock_iconphoto(*args, **kwargs) -> None:
41-
pass
42-
43-
root.iconphoto = mock_iconphoto # type: ignore[method-assign]
44-
45-
yield root
46-
47-
# Restore original method and destroy root
48-
root.iconphoto = original_iconphoto # type: ignore[method-assign]
49-
50-
# Only destroy if we're the last test
51-
with contextlib.suppress(tk.TclError):
52-
root.quit() # Close the event loop
21+
# pylint: disable=redefined-outer-name
5322

5423

5524
@pytest.fixture

tests/test_frontend_tkinter_component_editor_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class TestComponentEditorWithMinimalMocking:
267267
while mocking only the absolute minimum required to avoid UI rendering.
268268
"""
269269

270-
def test_editor_initialization_process(self, temp_vehicle_dir, root) -> None: # pylint: disable=unused-argument
270+
def test_editor_initialization_process(self, temp_vehicle_dir, root) -> None:
271271
"""
272272
Test the full initialization process with minimal mocking.
273273
@@ -315,7 +315,7 @@ def test_editor_initialization_process(self, temp_vehicle_dir, root) -> None: #
315315
assert isinstance(components, dict)
316316
assert len(components) > 0
317317

318-
def test_editor_with_real_data_model(self, temp_vehicle_dir, root) -> None: # pylint: disable=unused-argument
318+
def test_editor_with_real_data_model(self, temp_vehicle_dir, root) -> None:
319319
"""
320320
Test the editor with a real data model but minimal UI mocking.
321321

tests/test_frontend_tkinter_component_template_manager.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
from ardupilot_methodic_configurator.frontend_tkinter_component_template_manager import ComponentTemplateManager
1919

20-
# pylint: disable=redefined-outer-name
21-
2220

2321
class TestComponentTemplateManager:
2422
"""Test suite for ComponentTemplateManager."""

tests/test_frontend_tkinter_directory_selection_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class WidgetEventTracker:
3535

3636
def __init__(self, widget) -> None:
3737
self.widget = widget
38-
self.events: list[tuple[str, tk.Event[tk.Misc]]] = []
39-
self.bindings: dict[str, Callable[[tk.Event[tk.Misc]], None]] = {}
38+
self.events: list[tuple[str, tk.Event]] = []
39+
self.bindings: dict[str, Callable[[tk.Event], None]] = {}
4040

4141
def bind(self, event_name) -> None:
4242
"""Bind to a widget event."""

tests/test_frontend_tkinter_parameter_editor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from ardupilot_methodic_configurator.annotate_params import Par
2020
from ardupilot_methodic_configurator.frontend_tkinter_parameter_editor import ParameterEditorWindow
2121

22-
# pylint: disable=redefined-outer-name
22+
# pylint: disable=redefined-outer-name, too-many-arguments, too-many-positional-arguments, unused-argument
2323

2424

2525
@pytest.fixture

0 commit comments

Comments
 (0)