From 733309e501dc3e1e0c157679738929b36f964ffd Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 7 Dec 2025 16:06:19 +0100 Subject: [PATCH 1/5] Apply ruff/flake8-implicit-str-concat rule ISC003 ISC003 Explicitly concatenated string should be implicitly concatenated --- tests/test_class_sh_basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_class_sh_basic.py b/tests/test_class_sh_basic.py index 18f0b0646e..aaea87b8f3 100644 --- a/tests/test_class_sh_basic.py +++ b/tests/test_class_sh_basic.py @@ -112,8 +112,8 @@ def test_pass_unique_ptr_disowns(pass_f, rtrn_f, expected): pass_f(obj) assert str(exc_info.value) == ( "Missing value for wrapped C++ type" - + " `pybind11_tests::class_sh_basic::atyp`:" - + " Python instance was disowned." + " `pybind11_tests::class_sh_basic::atyp`:" + " Python instance was disowned." ) From 8bee9d3184a466bbf4b59eae70dc3bef503d6a71 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 7 Dec 2025 16:06:52 +0100 Subject: [PATCH 2/5] Enforce ruff/flake8-implicit-str-concat rules (ISC) --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a4b43d3b04..fec355b1d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -152,6 +152,7 @@ extend-select = [ "C4", # flake8-comprehensions "EM", # flake8-errmsg "ICN", # flake8-import-conventions + "ISC", # flake8-implicit-str-concat "PGH", # pygrep-hooks "PIE", # flake8-pie "PL", # pylint From b80b1e303045079df11866b2b7c833ecdca8662f Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 7 Dec 2025 15:58:32 +0100 Subject: [PATCH 3/5] Apply ruff/Perflint rule PERF102 PERF102 When using only the values of a dict use the `values()` method --- tests/test_stl_binders.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_stl_binders.py b/tests/test_stl_binders.py index 9856ba462b..518f2df2b6 100644 --- a/tests/test_stl_binders.py +++ b/tests/test_stl_binders.py @@ -258,7 +258,7 @@ def test_noncopyable_containers(): assert nvnc[i][j].value == j + 1 # Note: maps do not have .values() - for _, v in nvnc.items(): + for v in nvnc.values(): for i, j in enumerate(v, start=1): assert j.value == i @@ -269,7 +269,7 @@ def test_noncopyable_containers(): assert nmnc[i][j].value == 10 * j vsum = 0 - for _, v_o in nmnc.items(): + for v_o in nmnc.values(): for k_i, v_i in v_o.items(): assert v_i.value == 10 * k_i vsum += v_i.value @@ -283,7 +283,7 @@ def test_noncopyable_containers(): assert numnc[i][j].value == 10 * j vsum = 0 - for _, v_o in numnc.items(): + for v_o in numnc.values(): for k_i, v_i in v_o.items(): assert v_i.value == 10 * k_i vsum += v_i.value From c944fc36e3c639715bc4348f9c77058a2a092b55 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 7 Dec 2025 16:00:04 +0100 Subject: [PATCH 4/5] Apply ruff/Perflint rule PERF401 PERF401 Use a list comprehension to create a transformed list --- tests/test_iostream.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/test_iostream.py b/tests/test_iostream.py index 00b24ab706..791b9e0483 100644 --- a/tests/test_iostream.py +++ b/tests/test_iostream.py @@ -288,11 +288,7 @@ def test_redirect_both(capfd): def test_threading(): with m.ostream_redirect(stdout=True, stderr=False): # start some threads - threads = [] - - # start some threads - for _j in range(20): - threads.append(m.TestThread()) + threads = [m.TestThread() for _j in range(20)] # give the threads some time to fail threads[0].sleep() From 8728e3a21b28e98fac390ad87107db987dea534a Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 7 Dec 2025 16:01:01 +0100 Subject: [PATCH 5/5] Enforce ruff/Perflint rules (PERF) --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index fec355b1d7..eadd0e628f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -153,6 +153,7 @@ extend-select = [ "EM", # flake8-errmsg "ICN", # flake8-import-conventions "ISC", # flake8-implicit-str-concat + "PERF", # Perflint "PGH", # pygrep-hooks "PIE", # flake8-pie "PL", # pylint