[llvm] [CI] fix possibly undefined variable in code-format job (PR #165454)

Baranov Victor via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 28 11:25:43 PDT 2025


https://github.com/vbvictor created https://github.com/llvm/llvm-project/pull/165454

The error was generated by pylint, it seems correct because since `hook_main()` until `comments.append(fmt.comment)` there we no definition of `comments`:

>From 2481d965babcd0b80af3d5eefd3219870e55d298 Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Tue, 28 Oct 2025 21:22:09 +0300
Subject: [PATCH] [CI] fix possibly undefined variable

---
 llvm/utils/git/code-format-helper.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py
index 406a72817acb8..6104429af74ef 100755
--- a/llvm/utils/git/code-format-helper.py
+++ b/llvm/utils/git/code-format-helper.py
@@ -482,6 +482,7 @@ def hook_main():
         args.changed_files.append(line)
 
     failed_fmts = []
+    comments = []
     for fmt in ALL_FORMATTERS:
         if fmt.has_tool():
             if not fmt.run(args.changed_files, args):



More information about the llvm-commits mailing list