https://github.com/vbvictor created https://github.com/llvm/llvm-project/pull/176927
None >From 3d4bee4370cebb6ff483c547f32d352e7a7b96f8 Mon Sep 17 00:00:00 2001 From: Victor Baranov <[email protected]> Date: Tue, 20 Jan 2026 17:04:43 +0300 Subject: [PATCH] [clang-tidy][NFC] Run ruff over python scripts --- clang-tools-extra/clang-tidy/add_new_check.py | 3 +-- clang-tools-extra/clang-tidy/rename_check.py | 5 ++--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 2 +- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py | 8 ++++---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/clang-tools-extra/clang-tidy/add_new_check.py b/clang-tools-extra/clang-tidy/add_new_check.py index 80e1afe1a121c..dfa60ce7f3990 100755 --- a/clang-tools-extra/clang-tidy/add_new_check.py +++ b/clang-tools-extra/clang-tidy/add_new_check.py @@ -176,7 +176,7 @@ def write_implementation( } // namespace clang::tidy::%(namespace)s """ - % {"check_name": check_name_camel, "module": module, "namespace": namespace} + % {"check_name": check_name_camel, "namespace": namespace} ) @@ -578,7 +578,6 @@ def format_link_alias(doc_file: Tuple[str, str]) -> str: "check_name": check_name, "module": module, "check_file": check_file, - "target": target, "title": title, "autofix": autofix, } diff --git a/clang-tools-extra/clang-tidy/rename_check.py b/clang-tools-extra/clang-tidy/rename_check.py index b864bff814485..d5432eadcff6b 100755 --- a/clang-tools-extra/clang-tidy/rename_check.py +++ b/clang-tools-extra/clang-tidy/rename_check.py @@ -65,12 +65,12 @@ def deleteMatchingLines(fileName: str, pattern: str) -> bool: with io.open(fileName, "r", encoding="utf8") as f: lines = f.readlines() - not_matching_lines = [l for l in lines if not re.search(pattern, l)] + not_matching_lines = [line for line in lines if not re.search(pattern, line)] if len(not_matching_lines) == len(lines): return False print("Removing lines matching '%s' in '%s'..." % (pattern, fileName)) - print(" " + " ".join([l for l in lines if re.search(pattern, l)])) + print(" " + " ".join([line for line in lines if re.search(pattern, line)])) with io.open(fileName, "w", encoding="utf8") as f: f.writelines(not_matching_lines) @@ -307,7 +307,6 @@ def main() -> None: ) for filename in getListOfFiles(clang_tidy_path): - originalName = filename filename = fileRename( filename, old_module + "/" + old_name, new_module + "/" + new_name ) diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py index c090bdc1151df..07f2b911a03a2 100755 --- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py +++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py @@ -427,7 +427,7 @@ def main(): print(f"Writing fixes to {args.export_fixes} ...") try: merge_replacement_files(export_fixes_dir, args.export_fixes) - except: + except Exception: sys.stderr.write("Error exporting fixes.\n") traceback.print_exc() return_code = 1 diff --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py index 59523fd131185..f4c3d00734389 100755 --- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py @@ -667,7 +667,7 @@ async def main() -> None: subprocess.check_call( invocation, stdout=subprocess.DEVNULL if args.quiet else None ) - except: + except Exception: print("Unable to run clang-tidy.", file=sys.stderr) sys.exit(1) @@ -681,7 +681,7 @@ async def main() -> None: if args.source_filter: try: source_filter_re = re.compile(args.source_filter) - except: + except Exception: print( "Error: unable to compile regex from arg -source-filter:", file=sys.stderr, @@ -764,7 +764,7 @@ async def main() -> None: try: assert export_fixes_dir merge_replacement_files(export_fixes_dir, args.export_fixes) - except: + except Exception: print("Error exporting fixes.\n", file=sys.stderr) traceback.print_exc() returncode = 1 @@ -775,7 +775,7 @@ async def main() -> None: try: assert export_fixes_dir apply_fixes(args, clang_apply_replacements_binary, export_fixes_dir) - except: + except Exception: print("Error applying fixes.\n", file=sys.stderr) traceback.print_exc() returncode = 1 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
