Skip to content

Commit 6651530

Browse files
Enforce more ruff rules (#5922)
* Apply ruff/flake8-implicit-str-concat rule ISC003 ISC003 Explicitly concatenated string should be implicitly concatenated * Enforce ruff/flake8-implicit-str-concat rules (ISC) * Apply ruff/Perflint rule PERF102 PERF102 When using only the values of a dict use the `values()` method * Apply ruff/Perflint rule PERF401 PERF401 Use a list comprehension to create a transformed list * Enforce ruff/Perflint rules (PERF)
1 parent 1c1d01c commit 6651530

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ extend-select = [
152152
"C4", # flake8-comprehensions
153153
"EM", # flake8-errmsg
154154
"ICN", # flake8-import-conventions
155+
"ISC", # flake8-implicit-str-concat
156+
"PERF", # Perflint
155157
"PGH", # pygrep-hooks
156158
"PIE", # flake8-pie
157159
"PL", # pylint

tests/test_class_sh_basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ def test_pass_unique_ptr_disowns(pass_f, rtrn_f, expected):
112112
pass_f(obj)
113113
assert str(exc_info.value) == (
114114
"Missing value for wrapped C++ type"
115-
+ " `pybind11_tests::class_sh_basic::atyp`:"
116-
+ " Python instance was disowned."
115+
" `pybind11_tests::class_sh_basic::atyp`:"
116+
" Python instance was disowned."
117117
)
118118

119119

tests/test_iostream.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,7 @@ def test_redirect_both(capfd):
288288
def test_threading():
289289
with m.ostream_redirect(stdout=True, stderr=False):
290290
# start some threads
291-
threads = []
292-
293-
# start some threads
294-
for _j in range(20):
295-
threads.append(m.TestThread())
291+
threads = [m.TestThread() for _j in range(20)]
296292

297293
# give the threads some time to fail
298294
threads[0].sleep()

tests/test_stl_binders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def test_noncopyable_containers():
258258
assert nvnc[i][j].value == j + 1
259259

260260
# Note: maps do not have .values()
261-
for _, v in nvnc.items():
261+
for v in nvnc.values():
262262
for i, j in enumerate(v, start=1):
263263
assert j.value == i
264264

@@ -269,7 +269,7 @@ def test_noncopyable_containers():
269269
assert nmnc[i][j].value == 10 * j
270270

271271
vsum = 0
272-
for _, v_o in nmnc.items():
272+
for v_o in nmnc.values():
273273
for k_i, v_i in v_o.items():
274274
assert v_i.value == 10 * k_i
275275
vsum += v_i.value
@@ -283,7 +283,7 @@ def test_noncopyable_containers():
283283
assert numnc[i][j].value == 10 * j
284284

285285
vsum = 0
286-
for _, v_o in numnc.items():
286+
for v_o in numnc.values():
287287
for k_i, v_i in v_o.items():
288288
assert v_i.value == 10 * k_i
289289
vsum += v_i.value

0 commit comments

Comments
 (0)