Skip to content

Commit 0d0e80c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d4b5186 commit 0d0e80c

2 files changed

Lines changed: 14 additions & 30 deletions

File tree

clang_tools/main.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818

1919
def _is_version_like(target: str) -> bool:
20-
"""Check if *target* looks like a version number (e.g. ``"18"``, ``"18.1"``).
21-
"""
20+
"""Check if *target* looks like a version number (e.g. ``"18"``, ``"18.1"``)."""
2221
try:
2322
parts = target.split(".")
2423
for p in parts:
@@ -52,8 +51,7 @@ def _wheel_install(tools: list[str], version: Optional[str]) -> int:
5251

5352

5453
def _validate_wheel_tool(target: str) -> bool:
55-
"""Print an error and return `False` if *target* is not a wheel tool.
56-
"""
54+
"""Print an error and return `False` if *target* is not a wheel tool."""
5755
if target not in WHEEL_TOOLS:
5856
print(
5957
f"{YELLOW}Error: '{target}' is not available as a"
@@ -150,8 +148,7 @@ def _handle_install(args: argparse.Namespace) -> int:
150148
"""Dispatch ``install`` subcommand based on flags."""
151149
if args.binary and args.wheel:
152150
print(
153-
f"{YELLOW}Error: --binary and --wheel are mutually"
154-
f" exclusive{RESET_COLOR}",
151+
f"{YELLOW}Error: --binary and --wheel are mutually exclusive{RESET_COLOR}",
155152
file=sys.stderr,
156153
)
157154
return 1

tests/test_main.py

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# _is_version_like helper
1212
# ---------------------------------------------------------------------------
1313

14+
1415
@pytest.mark.parametrize(
1516
"target,expected",
1617
[
@@ -30,6 +31,7 @@ def test_is_version_like(target: str, expected: bool):
3031
# Parser – install subcommand
3132
# ---------------------------------------------------------------------------
3233

34+
3335
@pytest.fixture
3436
def parser() -> ArgumentParser:
3537
return get_parser()
@@ -102,6 +104,7 @@ def test_uninstall_subcommand_defaults(parser: ArgumentParser):
102104
# Integration / functional tests
103105
# ---------------------------------------------------------------------------
104106

107+
105108
def test_main_no_args(monkeypatch: pytest.MonkeyPatch, capsys):
106109
"""``clang-tools`` with no args prints help."""
107110
monkeypatch.setattr(sys, "argv", ["clang-tools"])
@@ -138,9 +141,7 @@ def test_main_install_binary(monkeypatch: pytest.MonkeyPatch, tmp_path):
138141
assert bin_path.exists()
139142

140143

141-
def test_main_install_binary_requires_version(
142-
monkeypatch: pytest.MonkeyPatch, capsys
143-
):
144+
def test_main_install_binary_requires_version(monkeypatch: pytest.MonkeyPatch, capsys):
144145
"""``--binary`` with a non-version target is an error."""
145146
monkeypatch.setattr(
146147
sys,
@@ -153,9 +154,7 @@ def test_main_install_binary_requires_version(
153154
assert exit_code == 1
154155

155156

156-
def test_main_install_binary_invalid_version(
157-
monkeypatch: pytest.MonkeyPatch, capsys
158-
):
157+
def test_main_install_binary_invalid_version(monkeypatch: pytest.MonkeyPatch, capsys):
159158
"""``--binary`` with a non-version target shows error."""
160159
monkeypatch.setattr(
161160
sys,
@@ -168,9 +167,7 @@ def test_main_install_binary_invalid_version(
168167
assert exit_code == 1
169168

170169

171-
def test_main_install_binary_and_wheel_mutex(
172-
monkeypatch: pytest.MonkeyPatch, capsys
173-
):
170+
def test_main_install_binary_and_wheel_mutex(monkeypatch: pytest.MonkeyPatch, capsys):
174171
"""``--binary`` and ``--wheel`` together is an error."""
175172
monkeypatch.setattr(
176173
sys,
@@ -200,9 +197,7 @@ def test_main_install_wheel_success(monkeypatch: pytest.MonkeyPatch, capsys):
200197
assert result.err == ""
201198

202199

203-
def test_main_install_wheel_unsupported_tool(
204-
monkeypatch: pytest.MonkeyPatch, capsys
205-
):
200+
def test_main_install_wheel_unsupported_tool(monkeypatch: pytest.MonkeyPatch, capsys):
206201
"""``--wheel`` with a binary-only tool name shows error."""
207202
monkeypatch.setattr(
208203
sys,
@@ -217,9 +212,7 @@ def test_main_install_wheel_unsupported_tool(
217212

218213
def test_main_install_wheel_failure(monkeypatch: pytest.MonkeyPatch, capsys):
219214
"""``--wheel`` with a failing _wheel_install returns 1."""
220-
monkeypatch.setattr(
221-
"clang_tools.main._wheel_install", lambda tools, ver: 1
222-
)
215+
monkeypatch.setattr("clang_tools.main._wheel_install", lambda tools, ver: 1)
223216
monkeypatch.setattr(
224217
sys,
225218
"argv",
@@ -276,9 +269,7 @@ def mock_wheel(tools, version):
276269
assert tracked == [(["clang-tidy"], "18")]
277270

278271

279-
def test_main_install_auto_detect_binary(
280-
monkeypatch: pytest.MonkeyPatch, tmp_path
281-
):
272+
def test_main_install_auto_detect_binary(monkeypatch: pytest.MonkeyPatch, tmp_path):
282273
"""Auto-detect installs binary for version in supported range."""
283274
monkeypatch.chdir(tmp_path)
284275
monkeypatch.setattr(
@@ -328,9 +319,7 @@ def test_main_install_auto_detect_fallback(
328319
assert "falling back to wheel" in result.err
329320

330321

331-
def test_main_install_auto_detect_non_version(
332-
monkeypatch: pytest.MonkeyPatch, capsys
333-
):
322+
def test_main_install_auto_detect_non_version(monkeypatch: pytest.MonkeyPatch, capsys):
334323
"""Auto-detect treats non-version target as tool name (wheel install)."""
335324
tracked_install: list = []
336325

@@ -386,9 +375,7 @@ def test_main_install_auto_detect_invalid_version(
386375
# ---- ``uninstall`` subcommand -----------------------------------------
387376

388377

389-
def test_main_uninstall_subcommand(
390-
monkeypatch: pytest.MonkeyPatch, tmp_path, capsys
391-
):
378+
def test_main_uninstall_subcommand(monkeypatch: pytest.MonkeyPatch, tmp_path, capsys):
392379
"""``clang-tools uninstall 12`` removes installed tools."""
393380
tool_name = "clang-format"
394381
version = "12"

0 commit comments

Comments
 (0)