Skip to content

Commit 25fa2a4

Browse files
authored
[CI] Add vulture, a deadcode checker for python. NFC (#25382)
Adding this actually turned up a bug in test code where we were skipping more variants of a test than we needed to because a tautological `if` condition.
1 parent 446c7d1 commit 25fa2a4

File tree

7 files changed

+19
-8
lines changed

7 files changed

+19
-8
lines changed

.circleci/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,12 @@ jobs:
507507
- run: ruff check
508508
# TODO (cclauss): When ruff supports rules these errors without --preview, remove following line
509509
- run: ruff check --preview --select=E20,E30,E221,E225,E226
510+
vulture:
511+
executor: focal
512+
steps:
513+
- checkout
514+
- pip-install
515+
- run: vulture . --min-confidence 100
510516
mypy:
511517
executor: focal
512518
steps:
@@ -1213,6 +1219,7 @@ workflows:
12131219
jobs:
12141220
- ruff
12151221
- mypy
1222+
- vulture
12161223
- eslint
12171224
- build-docs
12181225
- build-linux

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,6 @@ ignore_missing_imports = true
111111

112112
[tool.deadcode]
113113
exclude = ["out", "cache", "third_party", "test/third_party", "node_modules", "site/source/_themes", "site/source/conf.py"]
114+
115+
[tool.vulture]
116+
exclude = ["out", "cache", "third_party", "test/third_party", "node_modules", "site/source/_themes", "site/source/conf.py"]

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ruff==0.11.7
1111
types-requests==2.32.0.20241016
1212
unittest-xml-reporting==3.2.0
1313
deadcode==2.3.1
14+
vulture==2.14
1415

1516
# This version is mentioned in `site/source/docs/site/about.rst`.
1617
# Please keep them in sync.

test/test_benchmark.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def __init__(self, name, cc, cxx, args=None):
160160
self.cxx = cxx
161161
self.args = args or [OPTIMIZATIONS]
162162

163-
def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder, has_output_parser):
163+
def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder):
164164
native_args = native_args or []
165165
shared_args = shared_args or []
166166
self.parent = parent
@@ -213,7 +213,7 @@ def __init__(self, name, engine, extra_args=None, env=None, binaryen_opts=None):
213213
self.env.update(env)
214214
self.binaryen_opts = binaryen_opts or []
215215

216-
def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder, has_output_parser):
216+
def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder):
217217
emcc_args = emcc_args or []
218218
self.filename = filename
219219
llvm_root = self.env.get('LLVM') or config.LLVM_ROOT
@@ -294,7 +294,7 @@ def __init__(self, name, engine, args=None, binaryen_opts=None):
294294
self.args = args or [OPTIMIZATIONS]
295295
self.binaryen_opts = binaryen_opts or []
296296

297-
def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder, has_output_parser):
297+
def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder):
298298
cheerp_args = [
299299
'-fno-math-errno',
300300
]
@@ -459,7 +459,7 @@ def do_benchmark(self, name, src, expected_output='FAIL', args=None,
459459
reps = 0
460460
baseline = b
461461
print('Running benchmarker: %s: %s' % (b.__class__.__name__, b.name))
462-
b.build(self, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder, has_output_parser=output_parser is not None)
462+
b.build(self, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder)
463463
b.bench(args, output_parser, reps, expected_output)
464464
recorded_stats = b.display(baseline)
465465
if recorded_stats:

test/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7486,7 +7486,7 @@ def test2():
74867486
'no_dynamic': (['--bind', '-sDYNAMIC_EXECUTION=0', '-sLEGACY_VM_SUPPORT'],),
74877487
})
74887488
def test_embind_val_basics(self, args):
7489-
if '-sLEGACY_VM_SUPPORT':
7489+
if '-sLEGACY_VM_SUPPORT' in args:
74907490
if self.get_setting('MODULARIZE') == 'instance' or self.get_setting('WASM_ESM_INTEGRATION'):
74917491
self.skipTest('LEGACY_VM_SUPPORT is not compatible with EXPORT_ES6')
74927492
if self.is_wasm64():

tools/filelock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __init__(self, lock):
128128
def __enter__(self):
129129
return self.lock
130130

131-
def __exit__(self, exc_type, exc_value, traceback):
131+
def __exit__(self, _exc_type, _exc_value, _traceback):
132132
self.lock.release()
133133
return None
134134

@@ -330,7 +330,7 @@ def __enter__(self):
330330
self.acquire()
331331
return self
332332

333-
def __exit__(self, exc_type, exc_value, traceback):
333+
def __exit__(self, _exc_type, _exc_value, _traceback):
334334
self.release()
335335
return None
336336

tools/gen_struct_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def __enter__(self):
123123
self.code.append('puts("{");')
124124
return self
125125

126-
def __exit__(self, exc_type, exc_val, exc_tb):
126+
def __exit__(self, _exc_type, _exc_val, _exc_tb):
127127
if self.has_data:
128128
self.code.append('puts("");')
129129
self.code.append('printf("}");')

0 commit comments

Comments
 (0)