Skip to content

Commit 6df84da

Browse files
authored
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>
1 parent 5d52226 commit 6df84da

10 files changed

Lines changed: 35 additions & 34 deletions

File tree

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,10 @@ site/
112112

113113
# PyCharm
114114
.idea/
115+
116+
# Lockfiles
117+
*.lock
118+
*.pylock
119+
120+
# OS files
121+
.DS_Store

.pre-commit-config.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
rev: 4924b0e01e032fea073ad04a1c5cfa7e4add0afb # frozen: v0.15.6
2020
hooks:
2121
- id: ruff-check
22-
args: ["--fix", "--show-fixes"]
22+
args: ["--fix"]
2323
- id: ruff-format
2424

2525
- repo: https://github.com/pre-commit/mirrors-mypy
@@ -91,8 +91,7 @@ repos:
9191
- id: check-github-actions
9292
- id: check-github-workflows
9393
- id: check-gitlab-ci
94-
# Disabled due to schema issue for now:
95-
# - id: check-readthedocs
94+
- id: check-readthedocs
9695
- id: check-travis
9796
- id: check-jsonschema
9897
name: Check projects

cibuildwheel/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from typing import Any, Literal, TextIO
1616

1717
import cibuildwheel
18-
import cibuildwheel.util
1918
from cibuildwheel import errors
2019
from cibuildwheel.architecture import Architecture, allowed_architectures_check
2120
from cibuildwheel.ci import CIProvider, detect_ci_provider, fix_ansi_codes_for_github_actions

cibuildwheel/extra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def github_api_request(path: str, *, max_retries: int = 3) -> dict[str, Any]:
6262
# pylint: disable=E1101
6363
if (
6464
isinstance(e, urllib.error.HTTPError)
65-
and (e.code == 403 or e.code == 429)
65+
and (e.code in {403, 429})
6666
and e.headers.get("x-ratelimit-remaining") == "0"
6767
):
6868
reset_time = int(e.headers.get("x-ratelimit-reset", 0))

cibuildwheel/platforms/ios.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ def setup_python(
274274
build_frontend: BuildFrontendName,
275275
xbuild_tools: Sequence[str] | None,
276276
) -> tuple[Path, dict[str, str]]:
277-
if build_frontend == "build[uv]" or build_frontend == "uv":
277+
# Not using set because mypy can't narrow it
278+
if build_frontend == "build[uv]" or build_frontend == "uv": # noqa: PLR1714
278279
msg = "uv doesn't support iOS"
279280
raise errors.FatalError(msg)
280281

@@ -431,7 +432,8 @@ def build(options: Options, tmp_path: Path) -> None:
431432
build_options = options.build_options(config.identifier)
432433
build_frontend = build_options.build_frontend
433434
# uv doesn't support iOS
434-
if build_frontend.name == "build[uv]" or build_frontend.name == "uv":
435+
# Not using set because mypy can't narrow it
436+
if build_frontend.name == "build[uv]" or build_frontend.name == "uv": # noqa: PLR1714
435437
msg = "uv doesn't support iOS"
436438
raise errors.FatalError(msg)
437439

cibuildwheel/util/packaging.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,9 @@ def find_compatible_wheel(wheels: Sequence[T], identifier: str) -> T | None:
169169
elif platform.startswith("pyodide"):
170170
# each Pyodide version has its own platform tag
171171
continue
172-
else:
173-
# Windows should exactly match
174-
if tag.platform != platform:
175-
continue
172+
# Windows should exactly match
173+
elif tag.platform != platform:
174+
continue
176175

177176
# If all the filters above pass, then the wheel is a previously built compatible wheel.
178177
return wheel

pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,8 @@ files = [
128128
"noxfile.py",
129129
]
130130
warn_unused_configs = true
131-
132131
strict = true
133132
disallow_untyped_defs = false
134-
135133
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
136134
warn_unreachable = false
137135

@@ -190,6 +188,7 @@ messages_control.disable = [
190188
]
191189

192190
[tool.ruff]
191+
show-fixes = true
193192
line-length = 100
194193

195194
[tool.ruff.lint]
@@ -228,12 +227,11 @@ extend-select = [
228227
"TC", # flake8-type-checking
229228
]
230229
ignore = [
231-
"PLR", # Design related pylint codes
230+
"PLR09", # Design related pylint codes
231+
"PLR2004", # Magic value in comparison
232232
"RET504", "RET505", "RET508", # else after control flow
233233
"PT007", # Lists of tuples in Pytest
234234
"PYI025", # Set as AbstractSet
235-
"ISC001", # Conflicts with formatter
236-
"EXE003", # Ruff doesn't like uv?
237235
"PTH123", # open -> Path.open
238236
]
239237
flake8-unused-arguments.ignore-variadic-names = true

unit_test/main_tests/main_options_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def get_default_repair_command(platform: str) -> str:
184184
return "auditwheel repair -w {dest_dir} {wheel}"
185185
elif platform == "macos":
186186
return "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"
187-
elif platform == "windows" or platform == "pyodide":
187+
elif platform in {"windows", "pyodide"}:
188188
return ""
189189
else:
190190
msg = f"Unknown platform: {platform!r}"

unit_test/oci_container_test.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,10 @@ def test_disable_host_mount(
539539
def test_local_image(
540540
container_engine: OCIContainerEngineConfig, platform: OCIPlatform, tmp_path: Path
541541
) -> None:
542-
if (
543-
detect_ci_provider() == CIProvider.travis_ci
544-
and DEFAULT_OCI_PLATFORM != OCIPlatform.AMD64
545-
and platform != DEFAULT_OCI_PLATFORM
546-
):
542+
if detect_ci_provider() == CIProvider.travis_ci and DEFAULT_OCI_PLATFORM not in {
543+
OCIPlatform.AMD64,
544+
platform,
545+
}:
547546
pytest.skip("Skipping test because docker on this platform does not support QEMU")
548547
if container_engine.name == "podman" and platform == OCIPlatform.ARMV7:
549548
# both GHA & local macOS arm64 podman desktop are failing
@@ -569,11 +568,10 @@ def test_local_image(
569568

570569
@pytest.mark.parametrize("platform", list(OCIPlatform))
571570
def test_multiarch_image(container_engine, platform):
572-
if (
573-
detect_ci_provider() == CIProvider.travis_ci
574-
and DEFAULT_OCI_PLATFORM != OCIPlatform.AMD64
575-
and platform != DEFAULT_OCI_PLATFORM
576-
):
571+
if detect_ci_provider() == CIProvider.travis_ci and DEFAULT_OCI_PLATFORM not in {
572+
OCIPlatform.AMD64,
573+
platform,
574+
}:
577575
pytest.skip("Skipping test because docker on this platform does not support QEMU")
578576
if container_engine.name == "podman" and platform == OCIPlatform.ARMV7:
579577
# both GHA & local macOS arm64 podman desktop are failing

unit_test/options_toml_test.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,12 @@ def test_resolve_cascade_merge_list(ignore_empty, rule):
339339

340340
if not ignore_empty:
341341
assert answer == "b1 b2"
342-
else:
343-
if rule == InheritRule.PREPEND:
344-
assert answer == "b1 b2 a1 a2"
345-
elif rule == InheritRule.NONE:
346-
assert answer == "b1 b2"
347-
elif rule == InheritRule.APPEND:
348-
assert answer == "a1 a2 b1 b2"
342+
elif rule == InheritRule.PREPEND:
343+
assert answer == "b1 b2 a1 a2"
344+
elif rule == InheritRule.NONE:
345+
assert answer == "b1 b2"
346+
elif rule == InheritRule.APPEND:
347+
assert answer == "a1 a2 b1 b2"
349348

350349

351350
@pytest.mark.parametrize("rule", [InheritRule.PREPEND, InheritRule.NONE, InheritRule.APPEND])

0 commit comments

Comments
 (0)