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