Skip to content

Commit f6c8fae

Browse files
committed
chore: update ruff -> 1.14.1 and update rules for python 3.10
1 parent 51161f9 commit f6c8fae

File tree

213 files changed

+1961
-2208
lines changed

Some content is hidden

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

213 files changed

+1961
-2208
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 ]

poetry.lock

Lines changed: 49 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ joblib = "*"
5050

5151
### Optional dependencies ###
5252
# development core
53-
ruff = { version = "0.11.11", optional = true }
53+
ruff = { version = "0.14.1", optional = true }
5454
coverage = { version = "*", optional = true }
5555
dill = { version = "*", optional = true }
5656
ipython = { version = "*", optional = true }
@@ -234,38 +234,38 @@ requires = ["poetry-core>=1.0.0"]
234234
build-backend = "poetry.core.masonry.api"
235235

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

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

271271
[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.

0 commit comments

Comments
 (0)