[clang] 4493897 - [libclang/python/tests] Remove unused variables (#114397)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 31 07:21:03 PDT 2024


Author: Jannick Kremer
Date: 2024-10-31T15:20:59+01:00
New Revision: 4493897499abbc60b1aa9e99717db93ae8450e6d

URL: https://github.com/llvm/llvm-project/commit/4493897499abbc60b1aa9e99717db93ae8450e6d
DIFF: https://github.com/llvm/llvm-project/commit/4493897499abbc60b1aa9e99717db93ae8450e6d.diff

LOG: [libclang/python/tests] Remove unused variables (#114397)

Remove all occurrences of unused varialbes in the python bindings tests.
Use `_` to ignore unused values in tuple unpacking expressions.

Added: 
    

Modified: 
    clang/bindings/python/tests/cindex/test_cdb.py
    clang/bindings/python/tests/cindex/test_cursor.py
    clang/bindings/python/tests/cindex/test_index.py
    clang/bindings/python/tests/cindex/test_type.py

Removed: 
    


################################################################################
diff  --git a/clang/bindings/python/tests/cindex/test_cdb.py b/clang/bindings/python/tests/cindex/test_cdb.py
index a5cc22796aa2ad..b19c2b7bf721ae 100644
--- a/clang/bindings/python/tests/cindex/test_cdb.py
+++ b/clang/bindings/python/tests/cindex/test_cdb.py
@@ -31,7 +31,7 @@ def test_create_fail(self):
         with open(os.devnull, "wb") as null:
             os.dup2(null.fileno(), 2)
         with self.assertRaises(CompilationDatabaseError) as cm:
-            cdb = CompilationDatabase.fromDirectory(path)
+            CompilationDatabase.fromDirectory(path)
         os.dup2(stderr, 2)
         os.close(stderr)
 
@@ -40,7 +40,7 @@ def test_create_fail(self):
 
     def test_create(self):
         """Check we can load a compilation database"""
-        cdb = CompilationDatabase.fromDirectory(kInputsDir)
+        CompilationDatabase.fromDirectory(kInputsDir)
 
     def test_lookup_succeed(self):
         """Check we get some results if the file exists in the db"""
@@ -175,7 +175,7 @@ def test_compilationDB_references(self):
         cmds = cdb.getCompileCommands("/home/john.doe/MyProject/project.cpp")
         del cdb
         gc.collect()
-        workingdir = cmds[0].directory
+        cmds[0].directory
 
     def test_compilationCommands_references(self):
         """Ensure CompilationsCommand keeps a reference to CompilationCommands"""
@@ -185,4 +185,4 @@ def test_compilationCommands_references(self):
         cmd0 = cmds[0]
         del cmds
         gc.collect()
-        workingdir = cmd0.directory
+        cmd0.directory

diff  --git a/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py
index f118613e3209d2..81c7f1c74966f1 100644
--- a/clang/bindings/python/tests/cindex/test_cursor.py
+++ b/clang/bindings/python/tests/cindex/test_cursor.py
@@ -170,7 +170,7 @@ def test_references(self):
         self.assertIsInstance(cursor.translation_unit, TranslationUnit)
 
         # If the TU was destroyed, this should cause a segfault.
-        parent = cursor.semantic_parent
+        cursor.semantic_parent
 
     def test_canonical(self):
         source = "struct X; struct X; struct X { int member; };"

diff  --git a/clang/bindings/python/tests/cindex/test_index.py b/clang/bindings/python/tests/cindex/test_index.py
index bf29628f5e4e79..72146f5f5b08b5 100644
--- a/clang/bindings/python/tests/cindex/test_index.py
+++ b/clang/bindings/python/tests/cindex/test_index.py
@@ -14,7 +14,7 @@
 
 class TestIndex(unittest.TestCase):
     def test_create(self):
-        index = Index.create()
+        Index.create()
 
     # FIXME: test Index.read
 

diff  --git a/clang/bindings/python/tests/cindex/test_type.py b/clang/bindings/python/tests/cindex/test_type.py
index 928a9794e42133..ef6630c93bb258 100644
--- a/clang/bindings/python/tests/cindex/test_type.py
+++ b/clang/bindings/python/tests/cindex/test_type.py
@@ -138,7 +138,7 @@ def test_references(self):
         self.assertIsInstance(t.translation_unit, TranslationUnit)
 
         # If the TU was destroyed, this should cause a segfault.
-        decl = t.get_declaration()
+        t.get_declaration()
 
     def testConstantArray(self):
         tu = get_tu(constarrayInput)
@@ -459,8 +459,8 @@ def test_offset(self):
             (["-target", "i386-pc-win32"], (8, 16, 0, 32, 64, 96)),
             (["-target", "msp430-none-none"], (2, 14, 0, 32, 64, 96)),
         ]
-        for flags, values in tries:
-            align, total, f1, bariton, foo, bar = values
+        for _, values in tries:
+            _, _, f1, bariton, foo, bar = values
             tu = get_tu(source)
             teststruct = get_cursor(tu, "Test")
             children = list(teststruct.get_children())


        


More information about the cfe-commits mailing list