chore: some cleanup and checks (#2792)

* chore: clean up config a bit

* chore: add an extra check

* Apply suggestions from code review

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
This commit is contained in:
Henry Schreiner
2026-03-24 23:51:49 -04:00
committed by GitHub
parent 5d52226105
commit 6df84da3e7
10 changed files with 35 additions and 34 deletions
+7
View File
@@ -112,3 +112,10 @@ site/
# PyCharm # PyCharm
.idea/ .idea/
# Lockfiles
*.lock
*.pylock
# OS files
.DS_Store
+2 -3
View File
@@ -19,7 +19,7 @@ repos:
rev: 4924b0e01e032fea073ad04a1c5cfa7e4add0afb # frozen: v0.15.6 rev: 4924b0e01e032fea073ad04a1c5cfa7e4add0afb # frozen: v0.15.6
hooks: hooks:
- id: ruff-check - id: ruff-check
args: ["--fix", "--show-fixes"] args: ["--fix"]
- id: ruff-format - id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
@@ -91,8 +91,7 @@ repos:
- id: check-github-actions - id: check-github-actions
- id: check-github-workflows - id: check-github-workflows
- id: check-gitlab-ci - id: check-gitlab-ci
# Disabled due to schema issue for now: - id: check-readthedocs
# - id: check-readthedocs
- id: check-travis - id: check-travis
- id: check-jsonschema - id: check-jsonschema
name: Check projects name: Check projects
-1
View File
@@ -15,7 +15,6 @@ from tempfile import mkdtemp
from typing import Any, Literal, TextIO from typing import Any, Literal, TextIO
import cibuildwheel import cibuildwheel
import cibuildwheel.util
from cibuildwheel import errors from cibuildwheel import errors
from cibuildwheel.architecture import Architecture, allowed_architectures_check from cibuildwheel.architecture import Architecture, allowed_architectures_check
from cibuildwheel.ci import CIProvider, detect_ci_provider, fix_ansi_codes_for_github_actions from cibuildwheel.ci import CIProvider, detect_ci_provider, fix_ansi_codes_for_github_actions
+1 -1
View File
@@ -62,7 +62,7 @@ def github_api_request(path: str, *, max_retries: int = 3) -> dict[str, Any]:
# pylint: disable=E1101 # pylint: disable=E1101
if ( if (
isinstance(e, urllib.error.HTTPError) isinstance(e, urllib.error.HTTPError)
and (e.code == 403 or e.code == 429) and (e.code in {403, 429})
and e.headers.get("x-ratelimit-remaining") == "0" and e.headers.get("x-ratelimit-remaining") == "0"
): ):
reset_time = int(e.headers.get("x-ratelimit-reset", 0)) reset_time = int(e.headers.get("x-ratelimit-reset", 0))
+4 -2
View File
@@ -274,7 +274,8 @@ def setup_python(
build_frontend: BuildFrontendName, build_frontend: BuildFrontendName,
xbuild_tools: Sequence[str] | None, xbuild_tools: Sequence[str] | None,
) -> tuple[Path, dict[str, str]]: ) -> tuple[Path, dict[str, str]]:
if build_frontend == "build[uv]" or build_frontend == "uv": # Not using set because mypy can't narrow it
if build_frontend == "build[uv]" or build_frontend == "uv": # noqa: PLR1714
msg = "uv doesn't support iOS" msg = "uv doesn't support iOS"
raise errors.FatalError(msg) raise errors.FatalError(msg)
@@ -431,7 +432,8 @@ def build(options: Options, tmp_path: Path) -> None:
build_options = options.build_options(config.identifier) build_options = options.build_options(config.identifier)
build_frontend = build_options.build_frontend build_frontend = build_options.build_frontend
# uv doesn't support iOS # uv doesn't support iOS
if build_frontend.name == "build[uv]" or build_frontend.name == "uv": # Not using set because mypy can't narrow it
if build_frontend.name == "build[uv]" or build_frontend.name == "uv": # noqa: PLR1714
msg = "uv doesn't support iOS" msg = "uv doesn't support iOS"
raise errors.FatalError(msg) raise errors.FatalError(msg)
+1 -2
View File
@@ -169,9 +169,8 @@ def find_compatible_wheel(wheels: Sequence[T], identifier: str) -> T | None:
elif platform.startswith("pyodide"): elif platform.startswith("pyodide"):
# each Pyodide version has its own platform tag # each Pyodide version has its own platform tag
continue continue
else:
# Windows should exactly match # Windows should exactly match
if tag.platform != platform: elif tag.platform != platform:
continue continue
# If all the filters above pass, then the wheel is a previously built compatible wheel. # If all the filters above pass, then the wheel is a previously built compatible wheel.
+3 -5
View File
@@ -128,10 +128,8 @@ files = [
"noxfile.py", "noxfile.py",
] ]
warn_unused_configs = true warn_unused_configs = true
strict = true strict = true
disallow_untyped_defs = false disallow_untyped_defs = false
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = false warn_unreachable = false
@@ -190,6 +188,7 @@ messages_control.disable = [
] ]
[tool.ruff] [tool.ruff]
show-fixes = true
line-length = 100 line-length = 100
[tool.ruff.lint] [tool.ruff.lint]
@@ -228,12 +227,11 @@ extend-select = [
"TC", # flake8-type-checking "TC", # flake8-type-checking
] ]
ignore = [ ignore = [
"PLR", # Design related pylint codes "PLR09", # Design related pylint codes
"PLR2004", # Magic value in comparison
"RET504", "RET505", "RET508", # else after control flow "RET504", "RET505", "RET508", # else after control flow
"PT007", # Lists of tuples in Pytest "PT007", # Lists of tuples in Pytest
"PYI025", # Set as AbstractSet "PYI025", # Set as AbstractSet
"ISC001", # Conflicts with formatter
"EXE003", # Ruff doesn't like uv?
"PTH123", # open -> Path.open "PTH123", # open -> Path.open
] ]
flake8-unused-arguments.ignore-variadic-names = true flake8-unused-arguments.ignore-variadic-names = true
+1 -1
View File
@@ -184,7 +184,7 @@ def get_default_repair_command(platform: str) -> str:
return "auditwheel repair -w {dest_dir} {wheel}" return "auditwheel repair -w {dest_dir} {wheel}"
elif platform == "macos": elif platform == "macos":
return "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}" return "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"
elif platform == "windows" or platform == "pyodide": elif platform in {"windows", "pyodide"}:
return "" return ""
else: else:
msg = f"Unknown platform: {platform!r}" msg = f"Unknown platform: {platform!r}"
+8 -10
View File
@@ -539,11 +539,10 @@ def test_disable_host_mount(
def test_local_image( def test_local_image(
container_engine: OCIContainerEngineConfig, platform: OCIPlatform, tmp_path: Path container_engine: OCIContainerEngineConfig, platform: OCIPlatform, tmp_path: Path
) -> None: ) -> None:
if ( if detect_ci_provider() == CIProvider.travis_ci and DEFAULT_OCI_PLATFORM not in {
detect_ci_provider() == CIProvider.travis_ci OCIPlatform.AMD64,
and DEFAULT_OCI_PLATFORM != OCIPlatform.AMD64 platform,
and platform != DEFAULT_OCI_PLATFORM }:
):
pytest.skip("Skipping test because docker on this platform does not support QEMU") pytest.skip("Skipping test because docker on this platform does not support QEMU")
if container_engine.name == "podman" and platform == OCIPlatform.ARMV7: if container_engine.name == "podman" and platform == OCIPlatform.ARMV7:
# both GHA & local macOS arm64 podman desktop are failing # both GHA & local macOS arm64 podman desktop are failing
@@ -569,11 +568,10 @@ def test_local_image(
@pytest.mark.parametrize("platform", list(OCIPlatform)) @pytest.mark.parametrize("platform", list(OCIPlatform))
def test_multiarch_image(container_engine, platform): def test_multiarch_image(container_engine, platform):
if ( if detect_ci_provider() == CIProvider.travis_ci and DEFAULT_OCI_PLATFORM not in {
detect_ci_provider() == CIProvider.travis_ci OCIPlatform.AMD64,
and DEFAULT_OCI_PLATFORM != OCIPlatform.AMD64 platform,
and platform != DEFAULT_OCI_PLATFORM }:
):
pytest.skip("Skipping test because docker on this platform does not support QEMU") pytest.skip("Skipping test because docker on this platform does not support QEMU")
if container_engine.name == "podman" and platform == OCIPlatform.ARMV7: if container_engine.name == "podman" and platform == OCIPlatform.ARMV7:
# both GHA & local macOS arm64 podman desktop are failing # both GHA & local macOS arm64 podman desktop are failing
+1 -2
View File
@@ -339,8 +339,7 @@ def test_resolve_cascade_merge_list(ignore_empty, rule):
if not ignore_empty: if not ignore_empty:
assert answer == "b1 b2" assert answer == "b1 b2"
else: elif rule == InheritRule.PREPEND:
if rule == InheritRule.PREPEND:
assert answer == "b1 b2 a1 a2" assert answer == "b1 b2 a1 a2"
elif rule == InheritRule.NONE: elif rule == InheritRule.NONE:
assert answer == "b1 b2" assert answer == "b1 b2"