style: sort Python imports with isort

Add isort configuration (profile=black, line_length=100) to pyproject.toml,
add isort pre-commit hook, and auto-sort imports across all Python source files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Eugene Mikhantyev
2026-03-29 13:02:24 +01:00
parent 75cead0860
commit c44bd9205d
50 changed files with 226 additions and 179 deletions

View File

@@ -15,12 +15,11 @@ from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from commands.freerouting import (
FreeroutingCommands,
_find_java,
_find_docker,
_docker_available,
_find_docker,
_find_java,
_java_version_ok,
)

View File

@@ -6,11 +6,11 @@ Integration tests parse real .kicad_sch files via sexpdata.
"""
import os
import sys
import shutil
import sys
import tempfile
from pathlib import Path
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch
import pytest
import sexpdata
@@ -20,23 +20,23 @@ from sexpdata import Symbol
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from commands.schematic_analysis import (
_parse_wires,
_parse_labels,
_parse_symbols,
_load_sexp,
_extract_lib_symbols,
_parse_lib_symbol_graphics,
_transform_local_point,
_line_segment_intersects_aabb,
_point_in_rect,
_distance,
_aabb_overlap,
_check_wire_overlap,
_compute_symbol_bbox_direct,
_distance,
_extract_lib_symbols,
_line_segment_intersects_aabb,
_load_sexp,
_parse_labels,
_parse_lib_symbol_graphics,
_parse_symbols,
_parse_wires,
_point_in_rect,
_transform_local_point,
compute_symbol_bbox,
find_overlapping_elements,
get_elements_in_region,
find_wires_crossing_symbols,
get_elements_in_region,
)
# ---------------------------------------------------------------------------

View File

@@ -3,8 +3,8 @@ Tests for get_schematic_component and edit_schematic_component fieldPositions su
"""
import re
import sys
import shutil
import sys
import tempfile
from pathlib import Path

View File

@@ -268,7 +268,8 @@ def _make_handler_under_test(handler_name: str):
This works because every _handle_* method starts with a params dict check
before doing any file I/O or heavy imports.
"""
import importlib.util, types
import importlib.util
import types
# We monkey-patch sys.modules to avoid pcbnew/skip side effects
stubs = {}
@@ -301,8 +302,8 @@ class TestHandlerParamValidation:
def _make_iface_stub(self):
"""Return a stub that exposes only the handler methods under test."""
import types
import importlib
import types
# Build a minimal namespace that satisfies the imports inside each handler
stub_mod = types.ModuleType("_handler_stubs")

View File

@@ -119,7 +119,8 @@ class TestHandlerDispatch:
@pytest.fixture(autouse=True)
def load_handler_map(self):
# Import only the dispatch table without initialising KiCAD connections
import importlib, types
import importlib
import types
# Patch heavy imports before loading kicad_interface
for mod in ["pcbnew", "skip"]:
@@ -334,6 +335,7 @@ class TestPinSnapping:
# Re-import so the patched skip.Schematic is used
import importlib
import kicad_interface
importlib.reload(kicad_interface)