diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index 1e07a3f97..b0177e0c9 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -221,8 +221,7 @@ def format_table(self, table: SettingTable) -> str: if isinstance(v, str): assignments.append((k, v)) elif isinstance(v, Sequence): - for inner_v in v: - assignments.append((k, str(inner_v))) + assignments.extend((k, str(inner_v)) for inner_v in v) else: assignments.append((k, str(v))) diff --git a/pyproject.toml b/pyproject.toml index e3efab7ca..b3523e2be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -201,6 +201,7 @@ extend-select = [ "YTT", # flake8-2020 "EXE", # flake8-executable "PYI", # flake8-pyi + "PERF101", "PERF102", "PERF401", "PERF402", "PERF403", # A selection of perflint codes ] ignore = [ "PLR", # Design related pylint codes diff --git a/test/utils.py b/test/utils.py index 02659fb6e..d999e1b40 100644 --- a/test/utils.py +++ b/test/utils.py @@ -8,7 +8,7 @@ import platform as pm import subprocess import sys -from collections.abc import Mapping, Sequence +from collections.abc import Generator, Mapping, Sequence from pathlib import Path from tempfile import TemporaryDirectory from typing import Any, Final @@ -165,7 +165,7 @@ def expected_wheels( single_arch: bool = False, ) -> list[str]: """ - Returns a list of expected wheels from a run of cibuildwheel. + Returns the expected wheels from a run of cibuildwheel. """ if machine_arch is None: machine_arch = pm.machine() @@ -186,22 +186,21 @@ def expected_wheels( elif platform == "windows" and machine_arch == "AMD64": architectures.append("x86") - wheels: list[str] = [] - for architecture in architectures: - wheels.extend( - _expected_wheels( - package_name, - package_version, - architecture, - manylinux_versions, - musllinux_versions, - macosx_deployment_target, - python_abi_tags, - include_universal2, - single_python, - ) + return [ + wheel + for architecture in architectures + for wheel in _expected_wheels( + package_name, + package_version, + architecture, + manylinux_versions, + musllinux_versions, + macosx_deployment_target, + python_abi_tags, + include_universal2, + single_python, ) - return wheels + ] def _expected_wheels( @@ -214,7 +213,7 @@ def _expected_wheels( python_abi_tags: list[str] | None, include_universal2: bool, single_python: bool, -) -> list[str]: +) -> Generator[str, None, None]: """ Returns a list of expected wheels from a run of cibuildwheel. """ @@ -264,13 +263,12 @@ def _expected_wheels( ) ] - wheels = [] - if platform == "pyodide": assert len(python_abi_tags) == 1 python_abi_tag = python_abi_tags[0] platform_tag = "pyodide_2024_0_wasm32" - return [f"{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl"] + yield f"{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl" + return for python_abi_tag in python_abi_tags: platform_tags = [] @@ -321,9 +319,7 @@ def _expected_wheels( raise Exception(msg) for platform_tag in platform_tags: - wheels.append(f"{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl") - - return wheels + yield f"{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl" def get_macos_version() -> tuple[int, int]: