Skip to content

Commit 24679c1

Browse files
committed
chore: update ruff -> 1.14.1 and update rules for python 3.10
1 parent dc01be1 commit 24679c1

File tree

216 files changed

+2028
-2207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+2028
-2207
lines changed

.github/workflows/tidy3d-python-client-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ jobs:
166166
persist-credentials: false
167167
- uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1
168168
with:
169-
version: 0.11.11
169+
version: 0.14.1
170170
- name: Run ruff format
171171
run: ruff format --check --diff
172172
- name: Run ruff check

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ default_install_hook_types:
44
- commit-msg
55
repos:
66
- repo: https://github.com/astral-sh/ruff-pre-commit
7-
rev: "v0.11.11"
7+
rev: "v0.14.1"
88
hooks:
99
- id: ruff-check
1010
args: [ --fix ]

pyproject.toml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typing-extensions = "*"
5252

5353
### Optional dependencies ###
5454
# development core
55-
ruff = { version = "0.11.11", optional = true }
55+
ruff = { version = "0.14.1", optional = true }
5656
coverage = { version = "*", optional = true }
5757
dill = { version = "*", optional = true }
5858
ipython = { version = "*", optional = true }
@@ -236,38 +236,38 @@ requires = ["poetry-core>=1.0.0"]
236236
build-backend = "poetry.core.masonry.api"
237237

238238
[tool.ruff]
239-
target-version = "py39"
239+
target-version = "py310"
240240
line-length = 100
241241
extend-exclude = ["docs/faq/", "docs/notebooks/"]
242242

243243
[tool.ruff.lint]
244244
extend-select = [
245-
"E", # pycodestyle errors
246-
"F", # pyflakes
247-
"B", # bugbear
248-
"I", # isort
249-
"UP", # pyupgrade
250-
"W", # pycodestyle
251-
"C4", # flake8-comprehensions
252-
"NPY", # numpy-specific rules
253-
"RUF", # ruff builtins
254-
"ISC", # implicit string concatenation
255-
"PIE", # flake8-pie
256-
"RSE", # unnecessary parantheses on raised exceptions
257-
"TID", # no relative imports from parent modules
258-
"PLE", # pylint errors
259-
"PLC", # pylint conventions
245+
"E", # pycodestyle errors
246+
"F", # pyflakes
247+
"B", # bugbear
248+
"I", # isort
249+
"UP", # pyupgrade
250+
"W", # pycodestyle
251+
"C4", # flake8-comprehensions
252+
"NPY", # numpy-specific rules
253+
"RUF", # ruff builtins
254+
"ISC", # implicit string concatenation
255+
"PIE", # flake8-pie
256+
"RSE", # unnecessary parantheses on raised exceptions
257+
"TID", # no relative imports from parent modules
258+
"PLE", # pylint errors
259+
"PLC", # pylint conventions
260260
]
261261
extend-ignore = [
262-
"RUF001", # ambiguous unicode characters
263-
"RUF002", # ambiguous unicode characters
264-
"RUF003", # ambiguous unicode characters
265-
"RUF012", # type hints for mutable defaults
266-
"RUF015", # next(iter(...)) instead of list(...)[0]
267-
"E501", # line too long
268-
"B905", # `zip()` without an explicit `strict=` parameter
269-
"UP007", # TODO: Remove once Python >= 3.10
270-
"NPY002", # TODO: Revisit RNG handling
262+
"RUF001", # ambiguous unicode characters
263+
"RUF002", # ambiguous unicode characters
264+
"RUF003", # ambiguous unicode characters
265+
"RUF012", # type hints for mutable defaults
266+
"RUF015", # next(iter(...)) instead of list(...)[0]
267+
"E501", # line too long
268+
"B905", # `zip()` without an explicit `strict=` parameter
269+
"NPY002", # TODO: Revisit RNG handling
270+
"PLC0415", # allow imports not at top level
271271
]
272272

273273
[tool.ruff.lint.isort]

tests/_test_local/_test_fit_web.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from math import isclose
44

55
import numpy as np
6-
76
from tidy3d.plugins.fitter import AdvancedFitterParam, StableDispersionFitter
87

98
np.random.seed(4)
@@ -37,7 +36,7 @@ def test_dispersion_lossless():
3736
num_poles = 3
3837
num_tries = 10
3938
tolerance_rms = 1e-3
40-
best_medium, best_rms = fitter.fit(
39+
best_medium, _best_rms = fitter.fit(
4140
num_tries=num_tries, num_poles=num_poles, tolerance_rms=tolerance_rms
4241
)
4342

tests/_test_local/_test_plugins_web.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import numpy as np
4-
54
from tidy3d.plugins.fitter import DispersionFitter, StableDispersionFitter
65

76

tests/_test_local/_test_web.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import os
66
from unittest import TestCase, mock
77

8-
import tidy3d.web as web
98
from tidy3d.web.auth import encode_password, get_credentials
109

10+
import tidy3d.web as web
11+
1112
from ..utils import SIM_FULL as sim_original
1213

1314
CALLBACK_URL = "https://callbackurl"

tests/test_components/autograd/numerical/test_autograd_box_polyslab_numerical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ def test_box_and_polyslab_gradients_match(is_3d, infinite_dim_2d, shift_box_cent
368368
local_gradient=False,
369369
)
370370

371-
box_value, box_grad = value_and_grad(box_objective)([initial_params])
372-
polyslab_value, polyslab_grad = value_and_grad(polyslab_objective)([initial_params])
371+
_box_value, box_grad = value_and_grad(box_objective)([initial_params])
372+
_polyslab_value, polyslab_grad = value_and_grad(polyslab_objective)([initial_params])
373373

374374
box_grad_np = box_grad
375375
polyslab_grad_np = polyslab_grad

tests/test_components/autograd/numerical/test_autograd_conductivity_numerical.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def make_base_sim(
114114
]
115115
)
116116

117-
src_size = sim_size_um[0:2] + (0,)
117+
src_size = (*sim_size_um[0:2], 0)
118118

119119
wl_min_src_um = 0.9 * adj_wvl_um
120120
wl_max_src_um = 1.1 * adj_wvl_um
@@ -409,10 +409,10 @@ def test_finite_difference_conductivity_data(
409409
sim_geometry = get_sim_geometry(mesh_wvl_um)
410410

411411
box_for_override = td.Box(
412-
center=(0, 0, 0), size=sim_geometry.size[0:2] + (thickness_um + mesh_wvl_um,)
412+
center=(0, 0, 0), size=(*sim_geometry.size[0:2], thickness_um + mesh_wvl_um)
413413
)
414414

415-
eval_fns, eval_fn_names = make_eval_fns(monitor_size_wvl)
415+
eval_fns, _eval_fn_names = make_eval_fns(monitor_size_wvl)
416416

417417
sim_path_dir = tmp_path / f"test{test_number}"
418418
sim_path_dir.mkdir()
@@ -443,7 +443,7 @@ def test_finite_difference_conductivity_data(
443443
)
444444
conductivity_init = overall_conductivity_scaling * np.ones((dim, dim, Nz))
445445

446-
obj, adj_grad = obj_val_and_grad([conductivity_init])
446+
_obj, adj_grad = obj_val_and_grad([conductivity_init])
447447

448448
# empirical step size for finite difference set as 1/10 the size of the conductivity seed value
449449
fd_step = 0.1 * overall_conductivity_scaling

tests/test_components/autograd/numerical/test_autograd_mode_polyslab_numerical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def make_base_sim(
7272
]
7373
)
7474

75-
src_size = sim_size_um[0:2] + (0,)
75+
src_size = (*sim_size_um[0:2], 0)
7676

7777
wl_min_src_um = 0.9 * adj_wvl_um
7878
wl_max_src_um = 1.1 * adj_wvl_um
@@ -425,7 +425,7 @@ def eval_fn(sim_data):
425425
vertex_centers_x = 1.1 * mesh_wvl_um * np.cos(angles)
426426
vertex_centers_y = 0.8 * mesh_wvl_um * np.sin(angles)
427427

428-
obj, adj_grad = obj_val_and_grad([list(vertex_centers_x) + list(vertex_centers_y)])
428+
_obj, adj_grad = obj_val_and_grad([list(vertex_centers_x) + list(vertex_centers_y)])
429429

430430
for fd_idx in range(NUM_FINITE_DIFFERENCE):
431431
# Create random perturbation of vertices to check against the computed adjoint gradient.

tests/test_components/autograd/numerical/test_autograd_numerical.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def make_base_sim(
7272
]
7373
)
7474

75-
src_size = sim_size_um[0:2] + (0,)
75+
src_size = (*sim_size_um[0:2], 0)
7676

7777
wl_min_src_um = 0.9 * adj_wvl_um
7878
wl_max_src_um = 1.1 * adj_wvl_um
@@ -269,10 +269,10 @@ def test_finite_difference_field_data(field_data_test_parameters, rng, tmp_path,
269269
sim_geometry = get_sim_geometry(mesh_wvl_um)
270270

271271
box_for_override = td.Box(
272-
center=(0, 0, 0), size=sim_geometry.size[0:2] + (thickness_um + mesh_wvl_um,)
272+
center=(0, 0, 0), size=(*sim_geometry.size[0:2], thickness_um + mesh_wvl_um)
273273
)
274274

275-
eval_fns, eval_fn_names = make_eval_fns(monitor_size_wvl)
275+
eval_fns, _eval_fn_names = make_eval_fns(monitor_size_wvl)
276276

277277
sim_path_dir = tmp_path / f"test{test_number}"
278278
sim_path_dir.mkdir()
@@ -298,7 +298,7 @@ def test_finite_difference_field_data(field_data_test_parameters, rng, tmp_path,
298298

299299
perm_init = FINITE_DIFF_PERM_SEED * np.ones((dim, dim, Nz))
300300

301-
obj, adj_grad = obj_val_and_grad([perm_init])
301+
_obj, adj_grad = obj_val_and_grad([perm_init])
302302

303303
# empirical step size from running other finite difference tests for field
304304
# cases with permittivity

0 commit comments

Comments
 (0)