Skip to content

Commit fda1fcb

Browse files
RFingAdamclaude
andcommitted
Fix all ruff lint issues (F401, F841, E741, E402) for CI
Remove unused imports and variables in antenna_templates.py and optimization.py, fix ambiguous variable name and mid-file imports in test_optimization.py. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a63ca94 commit fda1fcb

3 files changed

Lines changed: 12 additions & 21 deletions

File tree

src/mcp_cst_studio/tools/antenna_templates.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from mcp_cst_studio.cst_client import CSTClient
1818
from mcp_cst_studio.vba_builder import VBABuilder, VBAScript
19-
from mcp_cst_studio.validators import validate_name, validate_frequency, validate_positive
19+
from mcp_cst_studio.validators import validate_frequency, validate_positive
2020

2121
# ---------------------------------------------------------------------------
2222
# Physical constants
@@ -725,7 +725,7 @@ def _build_patch_antenna(args: dict) -> str:
725725
h, h + 0.035,
726726
))
727727
# Feed line on top of substrate from edge to patch
728-
feed_length = gnd_y / 2 - L / 2
728+
gnd_y / 2 - L / 2
729729
script.add_raw(_build_brick(
730730
"Antenna", "FeedLine", "PEC",
731731
-feed_w / 2, feed_w / 2,
@@ -749,7 +749,7 @@ def _build_patch_antenna(args: dict) -> str:
749749
script.add_block(port_vba)
750750

751751
elif feed_type == "microstrip":
752-
feed_length = gnd_y / 2 - L / 2
752+
gnd_y / 2 - L / 2
753753
script.add_raw(_build_brick(
754754
"Antenna", "FeedLine", "PEC",
755755
-feed_w / 2, feed_w / 2,
@@ -1121,10 +1121,6 @@ def _build_horn_antenna(args: dict) -> str:
11211121

11221122
# Inner vacuum for horn (tapered cavity approximated via loft)
11231123
# Use analytical VBA for loft between waveguide aperture and horn aperture
1124-
loft_vba_lines = [
1125-
"' --- Lofted horn interior (waveguide to aperture) ---",
1126-
"' Create rear profile (waveguide end) at z=0",
1127-
]
11281124

11291125
# Rear profile curve
11301126
rear_curve = (
@@ -1260,7 +1256,7 @@ def _build_yagi_antenna(args: dict) -> str:
12601256

12611257
# Create each element as a cylinder along x-axis at position z
12621258
for name, z_pos, length in elements:
1263-
elem_vba = (
1259+
(
12641260
VBABuilder("Cylinder")
12651261
.call("Reset")
12661262
.set("Name", name)
@@ -1509,7 +1505,6 @@ def _build_vivaldi_antenna(args: dict) -> str:
15091505
R_taper = 0
15101506

15111507
# Feed line (microstrip on opposite side, quarter-wave stub)
1512-
feed_w = 2.0 # approximate 50-ohm line width for eps_r=2.2
15131508

15141509
f_min = freq * 0.5 # Vivaldi is wideband
15151510
f_max = freq * 1.5

src/mcp_cst_studio/tools/optimization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def _generate_recommendations(
570570
f"(gap: {gap:.2f})"
571571
)
572572

573-
band_center = (f_low + f_high) / 2.0
573+
(f_low + f_high) / 2.0
574574

575575
# Resonance-based recommendations
576576
if nearest_resonance:
@@ -955,7 +955,7 @@ async def _optimization_loop(
955955
956956
Only the final best-parameter application uses add_to_history.
957957
"""
958-
n = len(params_spec)
958+
len(params_spec)
959959
param_names = [p["name"] for p in params_spec]
960960
x0 = [p["initial"] for p in params_spec]
961961
bounds = [(p["min"], p["max"]) for p in params_spec]
@@ -1259,7 +1259,7 @@ async def _handle_refine(args: dict, client: CSTClient) -> dict:
12591259

12601260
# Use first band's target for the goal
12611261
first_band = bands[0]
1262-
s11_threshold = vswr_to_s11(first_band.get("vswr_target", 2.5))
1262+
vswr_to_s11(first_band.get("vswr_target", 2.5))
12631263
tree_path = f"1D Results\\S-Parameters\\S{port},{port}"
12641264
vba.set("SetGoalType", "Min")
12651265
vba.set("SetGoalResult", tree_path)

tests/test_optimization.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
from __future__ import annotations
44

5+
import json
56
import math
67
import os
78
import tempfile
89

910
import pytest
1011

12+
from mcp_cst_studio.cst_client import CSTClient
13+
1114
from mcp_cst_studio.tools.optimization import (
1215
_analyze_impedance_band,
1316
_build_impedance_vba,
@@ -269,8 +272,8 @@ def test_set_params_vba(self):
269272
def test_set_params_vba_only_store_parameter(self):
270273
"""VBA should only contain StoreParameter lines."""
271274
vba = _set_params_vba({"x": 1.0, "y": 2.0})
272-
lines = [l for l in vba.split("\n") if l.strip()]
273-
assert all("StoreParameter" in l for l in lines)
275+
lines = [line for line in vba.split("\n") if line.strip()]
276+
assert all("StoreParameter" in line for line in lines)
274277

275278
def test_set_params_and_solve_vba(self):
276279
"""Combined VBA stores params, solves, and exports."""
@@ -563,11 +566,6 @@ async def test_refine_validation_initial_out_of_range(self, offline_client):
563566
assert "initial" in data["message"]
564567

565568

566-
import json
567-
568-
from mcp_cst_studio.cst_client import CSTClient
569-
570-
571569
# ---------------------------------------------------------------------------
572570
# Diagnostics tools
573571
# ---------------------------------------------------------------------------
@@ -669,8 +667,6 @@ class TestDialogHandler:
669667

670668
def test_import(self):
671669
from mcp_cst_studio.dialog_handler import (
672-
DialogWatcher,
673-
dismiss_cst_dialogs,
674670
find_cst_dialogs,
675671
)
676672
# Functions should be importable and callable

0 commit comments

Comments
 (0)