Skip to content

Commit 34b4f1e

Browse files
[pre-commit.ci] pre-commit autoupdate (#2474)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.13 → v0.12.0](astral-sh/ruff-pre-commit@v0.11.13...v0.12.0) - [github.com/pre-commit/mirrors-mypy: v1.16.0 → v1.16.1](pre-commit/mirrors-mypy@v1.16.0...v1.16.1) - [github.com/python-jsonschema/check-jsonschema: 0.33.0 → 0.33.1](python-jsonschema/check-jsonschema@0.33.0...0.33.1) * chore: address new lints Signed-off-by: Henry Schreiner <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner <[email protected]>
1 parent e69b553 commit 34b4f1e

File tree

8 files changed

+22
-39
lines changed

8 files changed

+22
-39
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ repos:
1414
- id: trailing-whitespace
1515

1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.11.13
17+
rev: v0.12.0
1818
hooks:
1919
- id: ruff
2020
args: ["--fix", "--show-fixes"]
2121
- id: ruff-format
2222

2323
- repo: https://github.com/pre-commit/mirrors-mypy
24-
rev: v1.16.0
24+
rev: v1.16.1
2525
hooks:
2626
- id: mypy
2727
name: mypy 3.11 on cibuildwheel/
@@ -80,7 +80,7 @@ repos:
8080

8181

8282
- repo: https://github.com/python-jsonschema/check-jsonschema
83-
rev: 0.33.0
83+
rev: 0.33.1
8484
hooks:
8585
- id: check-dependabot
8686
- id: check-github-actions

bin/run_example_ci_configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def git_repo_has_changes() -> bool:
2828

2929
def generate_basic_project(path: Path) -> None:
3030
sys.path.insert(0, "")
31-
from test.test_projects.c import new_c_project
31+
from test.test_projects.c import new_c_project # noqa: PLC0415
3232

3333
project = new_c_project()
3434
project.generate(path)

cibuildwheel/environment.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,16 @@ def evaluated_value(self, **_: Any) -> str:
7373
return self.value
7474

7575

76+
@dataclasses.dataclass
7677
class EnvironmentAssignmentBash:
7778
"""
7879
An environment variable, in bash syntax. The value can use bash constructs
7980
like "$OTHER_VAR" and "$(command arg1 arg2)".
8081
"""
8182

83+
name: str
84+
value: str
85+
8286
def __init__(self, assignment: str):
8387
name, equals, value = assignment.partition("=")
8488
if not equals:
@@ -96,11 +100,6 @@ def evaluated_value(
96100
def __repr__(self) -> str:
97101
return f"{self.name}={self.value}"
98102

99-
def __eq__(self, other: object) -> bool:
100-
if isinstance(other, EnvironmentAssignmentBash):
101-
return self.name == other.name and self.value == other.value
102-
return False
103-
104103

105104
@dataclasses.dataclass(kw_only=True)
106105
class ParsedEnvironment:

cibuildwheel/resources/install_certifi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def main() -> None:
3333
[sys.executable, "-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"]
3434
)
3535

36-
import certifi
36+
import certifi # noqa: PLC0415
3737

3838
# change working directory to the default SSL directory
3939
os.chdir(openssl_dir)

cibuildwheel/util/helpers.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import dataclasses
12
import itertools
23
import os
34
import re
45
import shlex
56
import textwrap
67
from collections import defaultdict
78
from collections.abc import Sequence
8-
from functools import total_ordering
99

1010
from ..typing import PathOrStr
1111

@@ -140,19 +140,17 @@ def parse_key_value_string(
140140
return dict(result)
141141

142142

143-
@total_ordering
143+
@dataclasses.dataclass(order=True)
144144
class FlexibleVersion:
145-
version_str: str
146-
version_parts: tuple[int, ...]
147-
suffix: str
148-
149-
def __init__(self, version_str: str) -> None:
150-
self.version_str = version_str
145+
version_parts: tuple[int, ...] = dataclasses.field(init=False, repr=False)
146+
suffix: str = dataclasses.field(init=False, repr=False)
147+
version_str: str = dataclasses.field(compare=False)
151148

149+
def __post_init__(self) -> None:
152150
# Split into numeric parts and the optional suffix
153-
match = re.match(r"^[v]?(\d+(\.\d+)*)(.*)$", version_str)
151+
match = re.match(r"^[v]?(\d+(\.\d+)*)(.*)$", self.version_str)
154152
if not match:
155-
msg = f"Invalid version string: {version_str}"
153+
msg = f"Invalid version string: {self.version_str}"
156154
raise ValueError(msg)
157155

158156
version_part, _, suffix = match.groups()
@@ -172,18 +170,5 @@ def _remove_trailing_zeros(parts: tuple[int, ...]) -> tuple[int, ...]:
172170
parts = parts[:-1]
173171
return parts
174172

175-
def __eq__(self, other: object) -> bool:
176-
if not isinstance(other, FlexibleVersion):
177-
raise NotImplementedError()
178-
return (self.version_parts, self.suffix) == (other.version_parts, other.suffix)
179-
180-
def __lt__(self, other: object) -> bool:
181-
if not isinstance(other, FlexibleVersion):
182-
raise NotImplementedError()
183-
return (self.version_parts, self.suffix) < (other.version_parts, other.suffix)
184-
185-
def __repr__(self) -> str:
186-
return f"FlexibleVersion('{self.version_str}')"
187-
188173
def __str__(self) -> str:
189174
return self.version_str

cibuildwheel/venv.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ def virtualenv(
157157
def find_uv() -> Path | None:
158158
# Prefer uv in our environment
159159
with contextlib.suppress(ImportError, FileNotFoundError):
160-
# pylint: disable-next=import-outside-toplevel
161-
from uv import find_uv_bin
160+
from uv import find_uv_bin # noqa: PLC0415
162161

163162
return Path(find_uv_bin())
164163

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ messages_control.disable = [
172172
"unsubscriptable-object",
173173
"wrong-import-position",
174174
"unused-argument", # Handled by Ruff
175+
"import-outside-toplevel", # Handled by Ruff
175176
"broad-exception-raised", # Could be improved eventually
176177
"consider-using-in", # MyPy can't narrow "in"
177178
]

unit_test/build_selector_test.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from packaging.specifiers import SpecifierSet
22

3+
import cibuildwheel.selector
34
from cibuildwheel.selector import BuildSelector, EnableGroup
45

56

@@ -224,10 +225,8 @@ def test_build_riscv64_enable():
224225

225226

226227
def test_testing_selector():
227-
# local import to avoid pytest trying to collect this as a test class!
228-
from cibuildwheel.selector import TestSelector
229-
230-
test_selector = TestSelector(skip_config="cp36-*")
228+
# This is not a global import to keep pytest from collecting it as a test
229+
test_selector = cibuildwheel.selector.TestSelector(skip_config="cp36-*")
231230

232231
assert not test_selector("cp36-win_amd64")
233232
assert test_selector("cp37-manylinux_x86_64")

0 commit comments

Comments
 (0)