Skip to content

Commit e117359

Browse files
Fix linter complaints.
1 parent 41d80cf commit e117359

2 files changed

Lines changed: 25 additions & 36 deletions

File tree

sketch_adapter_solidworks/adapter.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -881,13 +881,12 @@ def _find_sketch_point_by_coords(self, element_id: str, point_type: PointType) -
881881
entity_index = self._entity_to_id.get(id(entity))
882882
if entity_index is None:
883883
# Try to find by searching through entities
884-
for idx, geom in enumerate(self._segment_geometry_list):
885-
# Check if this geometry matches the entity
886-
pass
884+
# (placeholder for future implementation)
885+
pass
887886

888887
# Look up the geometry by element_id
889888
geom = None
890-
for idx, g in enumerate(self._segment_geometry_list):
889+
for g in self._segment_geometry_list:
891890
# Match by checking if the entity at this index is our entity
892891
# Since we can't compare COM objects reliably, use the stored coordinates
893892
if g.get('element_id') == element_id:
@@ -897,17 +896,13 @@ def _find_sketch_point_by_coords(self, element_id: str, point_type: PointType) -
897896
# If we don't have stored geometry with element_id, try matching by index
898897
if geom is None:
899898
# Find the entity index in the order we stored it
900-
for prim_id, ent in self._id_to_entity.items():
899+
for prim_id, _ent in self._id_to_entity.items():
901900
if prim_id == element_id:
902901
# Find the index of this primitive
903902
# We need to track which geometry belongs to which primitive
904903
break
905904

906-
# Fallback: just use the primitive ID to find geometry
907-
# The primitive ID should match the order of creation
908-
for idx, g in enumerate(self._segment_geometry_list):
909-
pass # Can't reliably match without element_id
910-
905+
# Can't reliably match without element_id
911906
return None
912907

913908
# Get the target coordinates based on point type
@@ -1289,11 +1284,9 @@ def _move_point(self, ref: PointRef, new_x: float, new_y: float) -> bool:
12891284

12901285
# Find the stored geometry
12911286
geom = None
1292-
geom_idx = None
1293-
for idx, g in enumerate(self._segment_geometry_list):
1287+
for g in self._segment_geometry_list:
12941288
if g.get('element_id') == entity_id:
12951289
geom = g
1296-
geom_idx = idx
12971290
break
12981291

12991292
if geom is None:
@@ -1984,10 +1977,6 @@ def _export_arc(self, segment: Any, construction: bool = False) -> Arc | Circle:
19841977
)
19851978

19861979
# Otherwise try to export as an arc (original logic for arcs)
1987-
start_pt = None
1988-
end_pt = None
1989-
center_pt = None
1990-
19911980
if self._sketch is not None and radius is not None:
19921981
try:
19931982
points = self._get_com_result(self._sketch, "GetSketchPoints2")
@@ -2188,7 +2177,7 @@ def get_solver_status(self) -> tuple[SolverStatus, int]:
21882177
# Count constraints
21892178
constraint_dof = 0
21902179
if relations:
2191-
for rel in relations:
2180+
for _rel in relations:
21922181
constraint_dof += 1 # Simplified - each relation removes 1 DOF
21932182

21942183
# Estimate status

tests/test_solidworks_roundtrip.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,19 +1435,19 @@ def test_slot_profile(self, adapter):
14351435
sketch = SketchDocument(name="SlotProfileTest")
14361436

14371437
# Create a slot: two parallel lines connected by two semicircular arcs
1438-
l1 = sketch.add_primitive(Line(start=Point2D(20, 0), end=Point2D(80, 0)))
1439-
l2 = sketch.add_primitive(Line(start=Point2D(80, 40), end=Point2D(20, 40)))
1438+
sketch.add_primitive(Line(start=Point2D(20, 0), end=Point2D(80, 0)))
1439+
sketch.add_primitive(Line(start=Point2D(80, 40), end=Point2D(20, 40)))
14401440

14411441
# Right semicircle
1442-
arc1 = sketch.add_primitive(Arc(
1442+
sketch.add_primitive(Arc(
14431443
center=Point2D(80, 20),
14441444
start_point=Point2D(80, 0),
14451445
end_point=Point2D(80, 40),
14461446
ccw=False
14471447
))
14481448

14491449
# Left semicircle
1450-
arc2 = sketch.add_primitive(Arc(
1450+
sketch.add_primitive(Arc(
14511451
center=Point2D(20, 20),
14521452
start_point=Point2D(20, 40),
14531453
end_point=Point2D(20, 0),
@@ -1470,14 +1470,14 @@ def test_smooth_corner_profile(self, adapter):
14701470
sketch = SketchDocument(name="SmoothCornerTest")
14711471

14721472
# Create an L-shape with a fillet
1473-
l1 = sketch.add_primitive(Line(start=Point2D(0, 0), end=Point2D(0, 50)))
1474-
arc = sketch.add_primitive(Arc(
1473+
sketch.add_primitive(Line(start=Point2D(0, 0), end=Point2D(0, 50)))
1474+
sketch.add_primitive(Arc(
14751475
center=Point2D(10, 50),
14761476
start_point=Point2D(0, 50),
14771477
end_point=Point2D(10, 60),
14781478
ccw=True
14791479
))
1480-
l2 = sketch.add_primitive(Line(start=Point2D(10, 60), end=Point2D(60, 60)))
1480+
sketch.add_primitive(Line(start=Point2D(10, 60), end=Point2D(60, 60)))
14811481

14821482
adapter.create_sketch(sketch.name)
14831483
adapter.load_sketch(sketch)
@@ -1621,8 +1621,8 @@ def test_fully_constrained_rectangle(self, adapter):
16211621
assert len(lines) == 4
16221622

16231623
# Check horizontal lines are horizontal
1624-
horizontal_count = sum(1 for l in lines if abs(l.start.y - l.end.y) < 0.5)
1625-
vertical_count = sum(1 for l in lines if abs(l.start.x - l.end.x) < 0.5)
1624+
horizontal_count = sum(1 for ln in lines if abs(ln.start.y - ln.end.y) < 0.5)
1625+
vertical_count = sum(1 for ln in lines if abs(ln.start.x - ln.end.x) < 0.5)
16261626

16271627
assert horizontal_count == 2, f"Should have 2 horizontal lines, got {horizontal_count}"
16281628
assert vertical_count == 2, f"Should have 2 vertical lines, got {vertical_count}"
@@ -1691,11 +1691,11 @@ def test_arc_tangent_to_two_lines(self, adapter):
16911691
"""Test arc tangent to two lines (fillet-like)."""
16921692
sketch = SketchDocument(name="ArcTangent2LinesTest")
16931693

1694-
l1 = sketch.add_primitive(Line(start=Point2D(0, 0), end=Point2D(50, 0)))
1695-
l2 = sketch.add_primitive(Line(start=Point2D(50, 50), end=Point2D(50, 0)))
1694+
sketch.add_primitive(Line(start=Point2D(0, 0), end=Point2D(50, 0)))
1695+
sketch.add_primitive(Line(start=Point2D(50, 50), end=Point2D(50, 0)))
16961696

16971697
# Arc connecting the two lines
1698-
arc = sketch.add_primitive(Arc(
1698+
sketch.add_primitive(Arc(
16991699
center=Point2D(50, 0),
17001700
start_point=Point2D(50, 0),
17011701
end_point=Point2D(50, 0),
@@ -1886,7 +1886,7 @@ def test_symmetric_line_endpoints(self, adapter):
18861886
exported = adapter.export_sketch()
18871887

18881888
lines = [p for p in exported.primitives.values() if isinstance(p, Line)]
1889-
non_construction = [l for l in lines if not l.construction]
1889+
non_construction = [ln for ln in lines if not ln.construction]
18901890
assert len(non_construction) >= 2, "Should have at least 2 non-construction lines"
18911891

18921892
def test_symmetric_circles(self, adapter):
@@ -2004,29 +2004,29 @@ def test_symmetric_rectangle_halves(self, adapter):
20042004
))
20052005

20062006
# Create left half of rectangle
2007-
left_top = sketch.add_primitive(Line(
2007+
sketch.add_primitive(Line(
20082008
start=Point2D(0, 80),
20092009
end=Point2D(50, 80)
20102010
))
20112011
left_side = sketch.add_primitive(Line(
20122012
start=Point2D(0, 20),
20132013
end=Point2D(0, 80)
20142014
))
2015-
left_bottom = sketch.add_primitive(Line(
2015+
sketch.add_primitive(Line(
20162016
start=Point2D(0, 20),
20172017
end=Point2D(50, 20)
20182018
))
20192019

20202020
# Create right half of rectangle
2021-
right_top = sketch.add_primitive(Line(
2021+
sketch.add_primitive(Line(
20222022
start=Point2D(50, 80),
20232023
end=Point2D(100, 80)
20242024
))
20252025
right_side = sketch.add_primitive(Line(
20262026
start=Point2D(100, 20),
20272027
end=Point2D(100, 80)
20282028
))
2029-
right_bottom = sketch.add_primitive(Line(
2029+
sketch.add_primitive(Line(
20302030
start=Point2D(50, 20),
20312031
end=Point2D(100, 20)
20322032
))
@@ -2039,5 +2039,5 @@ def test_symmetric_rectangle_halves(self, adapter):
20392039
exported = adapter.export_sketch()
20402040

20412041
lines = [p for p in exported.primitives.values() if isinstance(p, Line)]
2042-
non_construction = [l for l in lines if not l.construction]
2042+
non_construction = [ln for ln in lines if not ln.construction]
20432043
assert len(non_construction) >= 6, "Should have at least 6 non-construction lines"

0 commit comments

Comments
 (0)