Skip to content

Commit b6928ec

Browse files
committed
fix: improve code formatting and readability in clang_tidy.py
1 parent 29d5708 commit b6928ec

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

cpp_linter_hooks/clang_tidy.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def _find_compile_commands() -> Optional[str]:
2424
return None
2525

2626

27-
def _resolve_compile_db(hook_args, other_args) -> Tuple[Optional[str], Optional[Tuple[int, str]]]:
27+
def _resolve_compile_db(
28+
hook_args, other_args
29+
) -> Tuple[Optional[str], Optional[Tuple[int, str]]]:
2830
"""Resolve the compile_commands.json directory to pass as -p to clang-tidy.
2931
3032
Returns (db_path, None) on success or (None, (retval, message)) on error.
@@ -64,7 +66,9 @@ def _exec_clang_tidy(command) -> Tuple[int, str]:
6466
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8"
6567
)
6668
output = (sp.stdout or "") + (sp.stderr or "")
67-
retval = 1 if sp.returncode != 0 or "warning:" in output or "error:" in output else 0
69+
retval = (
70+
1 if sp.returncode != 0 or "warning:" in output or "error:" in output else 0
71+
)
6872
return retval, output
6973
except FileNotFoundError as e:
7074
return 1, str(e)
@@ -81,7 +85,9 @@ def run_clang_tidy(args=None) -> Tuple[int, str]:
8185

8286
if compile_db_path:
8387
if hook_args.verbose:
84-
print(f"Using compile_commands.json from: {compile_db_path}", file=sys.stderr)
88+
print(
89+
f"Using compile_commands.json from: {compile_db_path}", file=sys.stderr
90+
)
8591
other_args = ["-p", compile_db_path] + other_args
8692

8793
return _exec_clang_tidy(["clang-tidy"] + other_args)

0 commit comments

Comments
 (0)