refactor: address code review issues — remove stale import, fix misleading var name, eliminate redundant adjacency build, add warning log on pin-angle failure
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -98,7 +98,10 @@ class ConnectionManager:
|
|||||||
# Stub direction follows the pin's outward angle from the PinLocator
|
# Stub direction follows the pin's outward angle from the PinLocator
|
||||||
try:
|
try:
|
||||||
pin_angle_deg = locator.get_pin_angle(schematic_path, component_ref, pin_name) or 0
|
pin_angle_deg = locator.get_pin_angle(schematic_path, component_ref, pin_name) or 0
|
||||||
except Exception:
|
except Exception as e:
|
||||||
|
logger.warning(
|
||||||
|
f"Could not get pin angle for {component_ref}/{pin_name}, defaulting to 0: {e}"
|
||||||
|
)
|
||||||
pin_angle_deg = 0
|
pin_angle_deg = 0
|
||||||
import math as _math
|
import math as _math
|
||||||
|
|
||||||
|
|||||||
@@ -414,10 +414,10 @@ def list_floating_labels(schematic: Any, schematic_path: str) -> List[Dict[str,
|
|||||||
coords = label.at.value
|
coords = label.at.value
|
||||||
lx_mm = float(coords[0])
|
lx_mm = float(coords[0])
|
||||||
ly_mm = float(coords[1])
|
ly_mm = float(coords[1])
|
||||||
lx_iu = _to_iu(lx_mm, ly_mm)
|
label_iu = _to_iu(lx_mm, ly_mm)
|
||||||
|
|
||||||
# Check if the label anchor itself is a pin position
|
# Check if the label anchor itself is a pin position
|
||||||
if lx_iu in pin_iu_set:
|
if label_iu in pin_iu_set:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Trace the wire-network from this label and check for pins
|
# Trace the wire-network from this label and check for pins
|
||||||
@@ -470,10 +470,9 @@ def get_net_at_point(
|
|||||||
# Check if query point is on a wire endpoint
|
# Check if query point is on a wire endpoint
|
||||||
all_wires = _parse_wires(schematic) if hasattr(schematic, "wire") else []
|
all_wires = _parse_wires(schematic) if hasattr(schematic, "wire") else []
|
||||||
if all_wires:
|
if all_wires:
|
||||||
_, iu_to_wires = _build_adjacency(all_wires)
|
adjacency, iu_to_wires = _build_adjacency(all_wires)
|
||||||
if query_iu in iu_to_wires:
|
if query_iu in iu_to_wires:
|
||||||
# Found a wire endpoint — trace the net to get the name
|
# Found a wire endpoint — trace the net to get the name
|
||||||
adjacency, _ = _build_adjacency(all_wires)
|
|
||||||
visited, net_points = _find_connected_wires(
|
visited, net_points = _find_connected_wires(
|
||||||
x_mm,
|
x_mm,
|
||||||
y_mm,
|
y_mm,
|
||||||
|
|||||||
@@ -1527,7 +1527,6 @@ class KiCADInterface:
|
|||||||
"""
|
"""
|
||||||
logger.info("Adding net label to schematic")
|
logger.info("Adding net label to schematic")
|
||||||
try:
|
try:
|
||||||
import traceback
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from commands.wire_manager import WireManager
|
from commands.wire_manager import WireManager
|
||||||
|
|||||||
Reference in New Issue
Block a user