[clang] [libclang/python/tests] Remove unused variables (PR #114397)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 31 05:22:48 PDT 2024
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/114397
Remove all occurrences of unused varialbes in the python bindings tests.
Use `_` to ignore unused values in tuple unpacking expressions.
>From 48e8bc646a7f73c1c0a762e8c1da7186f0ff2a5a Mon Sep 17 00:00:00 2001
From: Jannick Kremer <jannick.kremer at mailbox.org>
Date: Thu, 31 Oct 2024 13:14:34 +0100
Subject: [PATCH] [libclang/python/tests] Remove unused variables
---
clang/bindings/python/tests/cindex/test_cdb.py | 8 ++++----
clang/bindings/python/tests/cindex/test_cursor.py | 2 +-
clang/bindings/python/tests/cindex/test_index.py | 2 +-
clang/bindings/python/tests/cindex/test_type.py | 6 +++---
4 files changed, 9 insertions(+), 9 deletions(-)
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 77d8ca415708f8..a5e159a3a309ff 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