Skip to content

Commit 74a7d8a

Browse files
chore: add a selection of PERF rules (#2313)
1 parent 93314a8 commit 74a7d8a

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

cibuildwheel/options.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ def format_table(self, table: SettingTable) -> str:
221221
if isinstance(v, str):
222222
assignments.append((k, v))
223223
elif isinstance(v, Sequence):
224-
for inner_v in v:
225-
assignments.append((k, str(inner_v)))
224+
assignments.extend((k, str(inner_v)) for inner_v in v)
226225
else:
227226
assignments.append((k, str(v)))
228227

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ extend-select = [
201201
"YTT", # flake8-2020
202202
"EXE", # flake8-executable
203203
"PYI", # flake8-pyi
204+
"PERF101", "PERF102", "PERF401", "PERF402", "PERF403", # A selection of perflint codes
204205
]
205206
ignore = [
206207
"PLR", # Design related pylint codes

test/utils.py

+20-24
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import platform as pm
99
import subprocess
1010
import sys
11-
from collections.abc import Mapping, Sequence
11+
from collections.abc import Generator, Mapping, Sequence
1212
from pathlib import Path
1313
from tempfile import TemporaryDirectory
1414
from typing import Any, Final
@@ -165,7 +165,7 @@ def expected_wheels(
165165
single_arch: bool = False,
166166
) -> list[str]:
167167
"""
168-
Returns a list of expected wheels from a run of cibuildwheel.
168+
Returns the expected wheels from a run of cibuildwheel.
169169
"""
170170
if machine_arch is None:
171171
machine_arch = pm.machine()
@@ -186,22 +186,21 @@ def expected_wheels(
186186
elif platform == "windows" and machine_arch == "AMD64":
187187
architectures.append("x86")
188188

189-
wheels: list[str] = []
190-
for architecture in architectures:
191-
wheels.extend(
192-
_expected_wheels(
193-
package_name,
194-
package_version,
195-
architecture,
196-
manylinux_versions,
197-
musllinux_versions,
198-
macosx_deployment_target,
199-
python_abi_tags,
200-
include_universal2,
201-
single_python,
202-
)
189+
return [
190+
wheel
191+
for architecture in architectures
192+
for wheel in _expected_wheels(
193+
package_name,
194+
package_version,
195+
architecture,
196+
manylinux_versions,
197+
musllinux_versions,
198+
macosx_deployment_target,
199+
python_abi_tags,
200+
include_universal2,
201+
single_python,
203202
)
204-
return wheels
203+
]
205204

206205

207206
def _expected_wheels(
@@ -214,7 +213,7 @@ def _expected_wheels(
214213
python_abi_tags: list[str] | None,
215214
include_universal2: bool,
216215
single_python: bool,
217-
) -> list[str]:
216+
) -> Generator[str, None, None]:
218217
"""
219218
Returns a list of expected wheels from a run of cibuildwheel.
220219
"""
@@ -264,13 +263,12 @@ def _expected_wheels(
264263
)
265264
]
266265

267-
wheels = []
268-
269266
if platform == "pyodide":
270267
assert len(python_abi_tags) == 1
271268
python_abi_tag = python_abi_tags[0]
272269
platform_tag = "pyodide_2024_0_wasm32"
273-
return [f"{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl"]
270+
yield f"{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl"
271+
return
274272

275273
for python_abi_tag in python_abi_tags:
276274
platform_tags = []
@@ -321,9 +319,7 @@ def _expected_wheels(
321319
raise Exception(msg)
322320

323321
for platform_tag in platform_tags:
324-
wheels.append(f"{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl")
325-
326-
return wheels
322+
yield f"{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl"
327323

328324

329325
def get_macos_version() -> tuple[int, int]:

0 commit comments

Comments
 (0)