Skip to content

Commit 2302f07

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

2 files changed

Lines changed: 15 additions & 24 deletions

File tree

clang_tools/main.py

Lines changed: 5 additions & 3 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:
@@ -30,7 +29,10 @@ def _is_version_like(target: str) -> bool:
3029

3130
#: Known tool names supported by wheel installs
3231
WHEEL_TOOLS = {
33-
"clang-format", "clang-tidy", "clang-query", "clang-apply-replacements",
32+
"clang-format",
33+
"clang-tidy",
34+
"clang-query",
35+
"clang-apply-replacements",
3436
}
3537

3638

tests/test_main.py

Lines changed: 10 additions & 21 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,
@@ -202,9 +199,7 @@ def test_main_install_wheel_success(monkeypatch: pytest.MonkeyPatch, capsys):
202199

203200
def test_main_install_wheel_failure(monkeypatch: pytest.MonkeyPatch, capsys):
204201
"""``--wheel`` with a failing _wheel_install returns 1."""
205-
monkeypatch.setattr(
206-
"clang_tools.main._wheel_install", lambda tools, ver: 1
207-
)
202+
monkeypatch.setattr("clang_tools.main._wheel_install", lambda tools, ver: 1)
208203
monkeypatch.setattr(
209204
sys,
210205
"argv",
@@ -261,9 +256,7 @@ def mock_wheel(tools, version):
261256
assert tracked == [(["clang-tidy"], "18")]
262257

263258

264-
def test_main_install_auto_detect_binary(
265-
monkeypatch: pytest.MonkeyPatch, tmp_path
266-
):
259+
def test_main_install_auto_detect_binary(monkeypatch: pytest.MonkeyPatch, tmp_path):
267260
"""Auto-detect installs binary for version in supported range."""
268261
monkeypatch.chdir(tmp_path)
269262
monkeypatch.setattr(
@@ -313,9 +306,7 @@ def test_main_install_auto_detect_fallback(
313306
assert "falling back to wheel" in result.err
314307

315308

316-
def test_main_install_auto_detect_non_version(
317-
monkeypatch: pytest.MonkeyPatch, capsys
318-
):
309+
def test_main_install_auto_detect_non_version(monkeypatch: pytest.MonkeyPatch, capsys):
319310
"""Auto-detect treats non-version target as tool name (wheel install)."""
320311
tracked_install: list = []
321312

@@ -371,9 +362,7 @@ def test_main_install_auto_detect_invalid_version(
371362
# ---- ``uninstall`` subcommand -----------------------------------------
372363

373364

374-
def test_main_uninstall_subcommand(
375-
monkeypatch: pytest.MonkeyPatch, tmp_path, capsys
376-
):
365+
def test_main_uninstall_subcommand(monkeypatch: pytest.MonkeyPatch, tmp_path, capsys):
377366
"""``clang-tools uninstall 12`` removes installed tools."""
378367
tool_name = "clang-format"
379368
version = "12"

0 commit comments

Comments
 (0)