Skip to content

Commit 9ee22bf

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

2 files changed

Lines changed: 15 additions & 32 deletions

File tree

clang_tools/main.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717

1818
def _is_version_like(target: str) -> bool:
19-
"""Check if *target* looks like a version number (e.g. ``"18"``, ``"18.1"``).
20-
"""
19+
"""Check if *target* looks like a version number (e.g. ``"18"``, ``"18.1"``)."""
2120
try:
2221
parts = target.split(".")
2322
for p in parts:
@@ -191,9 +190,7 @@ def main() -> int:
191190
# ---- Legacy backward-compat path ----------------------------------
192191
if args._legacy_uninstall or args._legacy_install:
193192
if args._legacy_uninstall:
194-
uninstall_clang_tools(
195-
args._legacy_uninstall, args.tool, args.directory
196-
)
193+
uninstall_clang_tools(args._legacy_uninstall, args.tool, args.directory)
197194
if args._legacy_install:
198195
version = Version(args._legacy_install)
199196
if version.info != (0, 0, 0):

tests/test_main.py

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Args:
2525
# _is_version_like helper
2626
# ---------------------------------------------------------------------------
2727

28+
2829
@pytest.mark.parametrize(
2930
"target,expected",
3031
[
@@ -44,6 +45,7 @@ def test_is_version_like(target: str, expected: bool):
4445
# Parser – new subcommands
4546
# ---------------------------------------------------------------------------
4647

48+
4749
@pytest.fixture
4850
def parser() -> ArgumentParser:
4951
return get_parser()
@@ -116,6 +118,7 @@ def test_uninstall_subcommand_defaults(parser: ArgumentParser):
116118
# Backward-compat legacy flags (still work)
117119
# ---------------------------------------------------------------------------
118120

121+
119122
@pytest.mark.parametrize("arg_name", ["install", "uninstall"])
120123
@pytest.mark.parametrize("arg_value", [str(v) for v in range(7, 17)])
121124
def test_legacy_arg_parser(arg_name: str, arg_value: str, parser: ArgumentParser):
@@ -142,6 +145,7 @@ def test_legacy_default_args(parser: ArgumentParser):
142145
# Integration / functional tests
143146
# ---------------------------------------------------------------------------
144147

148+
145149
def test_main_no_args(monkeypatch: pytest.MonkeyPatch, capsys):
146150
"""``clang-tools`` with no args prints help."""
147151
monkeypatch.setattr(sys, "argv", ["clang-tools"])
@@ -151,9 +155,7 @@ def test_main_no_args(monkeypatch: pytest.MonkeyPatch, capsys):
151155
assert exit_code == 0
152156

153157

154-
def test_main_legacy_uninstall(
155-
monkeypatch: pytest.MonkeyPatch, tmp_path, capsys
156-
):
158+
def test_main_legacy_uninstall(monkeypatch: pytest.MonkeyPatch, tmp_path, capsys):
157159
"""Legacy ``--uninstall`` flag still works."""
158160
tool_name = "clang-format"
159161
version = "12"
@@ -203,9 +205,7 @@ def test_main_legacy_install(monkeypatch: pytest.MonkeyPatch, tmp_path):
203205
assert bin_path.exists()
204206

205207

206-
def test_main_legacy_install_invalid_version(
207-
monkeypatch: pytest.MonkeyPatch, capsys
208-
):
208+
def test_main_legacy_install_invalid_version(monkeypatch: pytest.MonkeyPatch, capsys):
209209
"""Legacy ``--install`` with invalid version shows error."""
210210
monkeypatch.setattr(
211211
sys,
@@ -251,9 +251,7 @@ def test_main_install_binary(monkeypatch: pytest.MonkeyPatch, tmp_path):
251251
assert bin_path.exists()
252252

253253

254-
def test_main_install_binary_requires_version(
255-
monkeypatch: pytest.MonkeyPatch, capsys
256-
):
254+
def test_main_install_binary_requires_version(monkeypatch: pytest.MonkeyPatch, capsys):
257255
"""``--binary`` with a non-version target is an error."""
258256
monkeypatch.setattr(
259257
sys,
@@ -271,9 +269,7 @@ def test_main_install_binary_requires_version(
271269
assert exit_code == 1
272270

273271

274-
def test_main_install_binary_invalid_version(
275-
monkeypatch: pytest.MonkeyPatch, capsys
276-
):
272+
def test_main_install_binary_invalid_version(monkeypatch: pytest.MonkeyPatch, capsys):
277273
"""``--binary`` with a non-version target shows 'requires a version number'."""
278274
monkeypatch.setattr(
279275
sys,
@@ -291,9 +287,7 @@ def test_main_install_binary_invalid_version(
291287
assert exit_code == 1
292288

293289

294-
def test_main_install_binary_and_wheel_mutex(
295-
monkeypatch: pytest.MonkeyPatch, capsys
296-
):
290+
def test_main_install_binary_and_wheel_mutex(monkeypatch: pytest.MonkeyPatch, capsys):
297291
"""``--binary`` and ``--wheel`` together is an error."""
298292
monkeypatch.setattr(
299293
sys,
@@ -331,9 +325,7 @@ def test_main_install_wheel_success(monkeypatch: pytest.MonkeyPatch, capsys):
331325

332326
def test_main_install_wheel_failure(monkeypatch: pytest.MonkeyPatch, capsys):
333327
"""``--wheel`` with a failing _wheel_install returns 1."""
334-
monkeypatch.setattr(
335-
"clang_tools.main._wheel_install", lambda tools, ver: 1
336-
)
328+
monkeypatch.setattr("clang_tools.main._wheel_install", lambda tools, ver: 1)
337329
monkeypatch.setattr(
338330
sys,
339331
"argv",
@@ -390,9 +382,7 @@ def mock_wheel(tools, version):
390382
assert tracked == [(["clang-tidy"], "18")]
391383

392384

393-
def test_main_install_auto_detect_binary(
394-
monkeypatch: pytest.MonkeyPatch, tmp_path
395-
):
385+
def test_main_install_auto_detect_binary(monkeypatch: pytest.MonkeyPatch, tmp_path):
396386
"""Auto-detect installs binary for version in supported range."""
397387
monkeypatch.chdir(tmp_path)
398388
monkeypatch.setattr(
@@ -443,9 +433,7 @@ def test_main_install_auto_detect_fallback(
443433
assert "falling back to wheel" in result.err
444434

445435

446-
def test_main_install_auto_detect_non_version(
447-
monkeypatch: pytest.MonkeyPatch, capsys
448-
):
436+
def test_main_install_auto_detect_non_version(monkeypatch: pytest.MonkeyPatch, capsys):
449437
"""Auto-detect treats non-version target as tool name (wheel install)."""
450438
tracked_install: list = []
451439

@@ -510,9 +498,7 @@ def test_main_install_auto_detect_invalid_version(
510498
# ---- New ``uninstall`` subcommand -------------------------------------
511499

512500

513-
def test_main_uninstall_subcommand(
514-
monkeypatch: pytest.MonkeyPatch, tmp_path, capsys
515-
):
501+
def test_main_uninstall_subcommand(monkeypatch: pytest.MonkeyPatch, tmp_path, capsys):
516502
"""``clang-tools uninstall 12`` removes installed tools."""
517503
tool_name = "clang-format"
518504
version = "12"

0 commit comments

Comments
 (0)