chore: add a selection of PERF rules (#2313)
This commit is contained in:
@@ -221,8 +221,7 @@ class ShlexTableFormat(OptionFormat):
|
|||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
assignments.append((k, v))
|
assignments.append((k, v))
|
||||||
elif isinstance(v, Sequence):
|
elif isinstance(v, Sequence):
|
||||||
for inner_v in v:
|
assignments.extend((k, str(inner_v)) for inner_v in v)
|
||||||
assignments.append((k, str(inner_v)))
|
|
||||||
else:
|
else:
|
||||||
assignments.append((k, str(v)))
|
assignments.append((k, str(v)))
|
||||||
|
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ extend-select = [
|
|||||||
"YTT", # flake8-2020
|
"YTT", # flake8-2020
|
||||||
"EXE", # flake8-executable
|
"EXE", # flake8-executable
|
||||||
"PYI", # flake8-pyi
|
"PYI", # flake8-pyi
|
||||||
|
"PERF101", "PERF102", "PERF401", "PERF402", "PERF403", # A selection of perflint codes
|
||||||
]
|
]
|
||||||
ignore = [
|
ignore = [
|
||||||
"PLR", # Design related pylint codes
|
"PLR", # Design related pylint codes
|
||||||
|
|||||||
+20
-24
@@ -8,7 +8,7 @@ import os
|
|||||||
import platform as pm
|
import platform as pm
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from collections.abc import Mapping, Sequence
|
from collections.abc import Generator, Mapping, Sequence
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
from typing import Any, Final
|
from typing import Any, Final
|
||||||
@@ -165,7 +165,7 @@ def expected_wheels(
|
|||||||
single_arch: bool = False,
|
single_arch: bool = False,
|
||||||
) -> list[str]:
|
) -> 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:
|
if machine_arch is None:
|
||||||
machine_arch = pm.machine()
|
machine_arch = pm.machine()
|
||||||
@@ -186,22 +186,21 @@ def expected_wheels(
|
|||||||
elif platform == "windows" and machine_arch == "AMD64":
|
elif platform == "windows" and machine_arch == "AMD64":
|
||||||
architectures.append("x86")
|
architectures.append("x86")
|
||||||
|
|
||||||
wheels: list[str] = []
|
return [
|
||||||
for architecture in architectures:
|
wheel
|
||||||
wheels.extend(
|
for architecture in architectures
|
||||||
_expected_wheels(
|
for wheel in _expected_wheels(
|
||||||
package_name,
|
package_name,
|
||||||
package_version,
|
package_version,
|
||||||
architecture,
|
architecture,
|
||||||
manylinux_versions,
|
manylinux_versions,
|
||||||
musllinux_versions,
|
musllinux_versions,
|
||||||
macosx_deployment_target,
|
macosx_deployment_target,
|
||||||
python_abi_tags,
|
python_abi_tags,
|
||||||
include_universal2,
|
include_universal2,
|
||||||
single_python,
|
single_python,
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return wheels
|
]
|
||||||
|
|
||||||
|
|
||||||
def _expected_wheels(
|
def _expected_wheels(
|
||||||
@@ -214,7 +213,7 @@ def _expected_wheels(
|
|||||||
python_abi_tags: list[str] | None,
|
python_abi_tags: list[str] | None,
|
||||||
include_universal2: bool,
|
include_universal2: bool,
|
||||||
single_python: bool,
|
single_python: bool,
|
||||||
) -> list[str]:
|
) -> Generator[str, None, None]:
|
||||||
"""
|
"""
|
||||||
Returns a list of expected wheels from a run of cibuildwheel.
|
Returns a list of expected wheels from a run of cibuildwheel.
|
||||||
"""
|
"""
|
||||||
@@ -264,13 +263,12 @@ def _expected_wheels(
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
wheels = []
|
|
||||||
|
|
||||||
if platform == "pyodide":
|
if platform == "pyodide":
|
||||||
assert len(python_abi_tags) == 1
|
assert len(python_abi_tags) == 1
|
||||||
python_abi_tag = python_abi_tags[0]
|
python_abi_tag = python_abi_tags[0]
|
||||||
platform_tag = "pyodide_2024_0_wasm32"
|
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:
|
for python_abi_tag in python_abi_tags:
|
||||||
platform_tags = []
|
platform_tags = []
|
||||||
@@ -321,9 +319,7 @@ def _expected_wheels(
|
|||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
|
|
||||||
for platform_tag in platform_tags:
|
for platform_tag in platform_tags:
|
||||||
wheels.append(f"{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl")
|
yield f"{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl"
|
||||||
|
|
||||||
return wheels
|
|
||||||
|
|
||||||
|
|
||||||
def get_macos_version() -> tuple[int, int]:
|
def get_macos_version() -> tuple[int, int]:
|
||||||
|
|||||||
Reference in New Issue
Block a user