diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e477219..c4cb1dc9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.14 + rev: v0.15.0 hooks: - id: ruff-check args: ["--fix", "--show-fixes"] diff --git a/bin/update_pythons.py b/bin/update_pythons.py index 277f2397..c55ba6f5 100755 --- a/bin/update_pythons.py +++ b/bin/update_pythons.py @@ -126,7 +126,7 @@ class GraalPyVersions: msg = f"{identifier} not supported yet on GraalPy" raise RuntimeError(msg) - gpspec_str = identifier.split("-")[0].split("_")[1] + gpspec_str = identifier.split("-", maxsplit=1)[0].split("_")[1] if "." not in gpspec_str and len(gpspec_str) == 3: gpspec_str = gpspec_str[:2] + "." + gpspec_str[-1] gpspec = Specifier(f"=={gpspec_str}.*") diff --git a/cibuildwheel/platforms/android.py b/cibuildwheel/platforms/android.py index e706ccaa..3d23deb1 100644 --- a/cibuildwheel/platforms/android.py +++ b/cibuildwheel/platforms/android.py @@ -687,7 +687,7 @@ def test_wheel(state: BuildState, wheel: Path, *, build_frontend: str) -> None: ) # Android doesn't support placeholders in the test command. - if any(("{" + placeholder + "}") in test_command for placeholder in ["project", "package"]): + if any(("{" + placeholder + "}") in test_command for placeholder in ("project", "package")): msg = ( f"Test command {test_command!r} with a " "'{project}' or '{package}' placeholder is not supported on Android, " @@ -697,12 +697,12 @@ def test_wheel(state: BuildState, wheel: Path, *, build_frontend: str) -> None: # Parse test-command. test_args = shlex.split(test_command) - if test_args[0] in ["python", "python3"] and any(arg in test_args for arg in ["-c", "-m"]): + if test_args[0] in {"python", "python3"} and any(arg in test_args for arg in ("-c", "-m")): # Forward the args to the CPython testbed script. We require '-c' or '-m' # to be in the command, because without those flags, the testbed script # will prepend '-m test', which will run Python's own test suite. del test_args[0] - elif test_args[0] in ["pytest"]: + elif test_args[0] == "pytest": # We transform some commands into the `python -m` form, but this is deprecated. msg = ( f"Test command {test_command!r} is not supported on Android. " diff --git a/cibuildwheel/platforms/macos.py b/cibuildwheel/platforms/macos.py index 0e7d0275..b782dd37 100644 --- a/cibuildwheel/platforms/macos.py +++ b/cibuildwheel/platforms/macos.py @@ -151,7 +151,7 @@ def install_cpython(_tmp: Path, version: str, url: str, free_threading: bool) -> """ ) raise errors.FatalError(msg) - python_filename = url.split("/")[-1] + python_filename = url.rsplit("/", maxsplit=1)[-1] pkg_path = CIBW_CACHE_PATH / "cpython-installer" / python_filename if not pkg_path.exists(): download(url, pkg_path) diff --git a/cibuildwheel/selector.py b/cibuildwheel/selector.py index 53d08b9c..29ad204b 100644 --- a/cibuildwheel/selector.py +++ b/cibuildwheel/selector.py @@ -75,7 +75,7 @@ class BuildSelector: def __call__(self, build_id: str) -> bool: # Filter build selectors by python_requires if set if self.requires_python is not None: - py_ver_str = build_id.split("-")[0].split("_")[0] + py_ver_str = build_id.split("-", maxsplit=1)[0].split("_")[0] py_ver_str = py_ver_str.removesuffix("t") major = int(py_ver_str[2]) minor = int(py_ver_str[3:])