Skip to content

Commit a7ac01b

Browse files
authored
Enable unused-parameter check in ruff. NFC (emscripten-core#23467)
This leads to some useful cleanups!
1 parent 3355efe commit a7ac01b

File tree

8 files changed

+22
-23
lines changed

8 files changed

+22
-23
lines changed

emcc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -650,15 +650,15 @@ def run(args):
650650
# settings until we reach the linking phase.
651651
settings.limit_settings(COMPILE_TIME_SETTINGS)
652652

653-
phase_setup(options, state, newargs)
653+
phase_setup(options, state)
654654

655655
if options.reproduce:
656656
create_reproduce_file(options.reproduce, args)
657657

658658
if state.mode == Mode.POST_LINK_ONLY:
659659
if len(options.input_files) != 1:
660660
exit_with_error('--post-link requires a single input file')
661-
separate_linker_flags(options, state, newargs)
661+
separate_linker_flags(state, newargs)
662662
# Delay import of link.py to avoid processing this file when only compiling
663663
from tools import link
664664
link.run_post_link(options.input_files[0], options, state)
@@ -743,7 +743,7 @@ def phase_parse_arguments(state):
743743
return options, newargs
744744

745745

746-
def separate_linker_flags(options, state, newargs):
746+
def separate_linker_flags(state, newargs):
747747
newargs = list(newargs)
748748

749749
if settings.RUNTIME_LINKED_LIBS:
@@ -819,7 +819,7 @@ def get_next_arg():
819819

820820

821821
@ToolchainProfiler.profile_block('setup')
822-
def phase_setup(options, state, newargs):
822+
def phase_setup(options, state):
823823
"""Second phase: configure and setup the compiler based on the specified settings and arguments.
824824
"""
825825

@@ -994,7 +994,7 @@ def get_clang_command_asm():
994994
# filter out the link flags
995995
assert state.mode == Mode.COMPILE_AND_LINK
996996
assert not options.dash_c
997-
compile_args, input_files = separate_linker_flags(options, state, newargs)
997+
compile_args, input_files = separate_linker_flags(state, newargs)
998998
compile_args = filter_out_link_flags(compile_args)
999999
linker_inputs = []
10001000
seen_names = {}

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ lint.select = [
2727
]
2828

2929
lint.ignore = [
30-
"ARG001",
3130
"ARG002",
3231
"ARG005",
3332
"B006",
@@ -50,6 +49,8 @@ lint.ignore = [
5049
"PLW2901",
5150
]
5251
lint.per-file-ignores."emrun.py" = [ "PLE0704" ]
52+
lint.per-file-ignores."tools/ports/*.py" = [ "ARG001" ]
53+
lint.per-file-ignores."test/other/ports/*.py" = [ "ARG001" ]
5354
lint.mccabe.max-complexity = 51 # Recommended: 10
5455
lint.pylint.allow-magic-value-types = [
5556
"bytes",

test/common.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,6 @@ def get_library(self, name, generated_libs, configure=['sh', './configure'], #
16441644
make_args = ['-j', str(shared.get_num_cores())]
16451645

16461646
build_dir = self.get_build_dir()
1647-
output_dir = self.get_dir()
16481647

16491648
emcc_args = []
16501649
if not native:
@@ -1677,7 +1676,7 @@ def get_library(self, name, generated_libs, configure=['sh', './configure'], #
16771676
cflags = ' '.join(emcc_args)
16781677
env_init.setdefault('CFLAGS', cflags)
16791678
env_init.setdefault('CXXFLAGS', cflags)
1680-
return build_library(name, build_dir, output_dir, generated_libs, configure,
1679+
return build_library(name, build_dir, generated_libs, configure,
16811680
make, make_args, self.library_cache,
16821681
cache_name, env_init=env_init, native=native)
16831682

@@ -2359,7 +2358,6 @@ def btest(self, filename, expected=None,
23592358

23602359
def build_library(name,
23612360
build_dir,
2362-
output_dir,
23632361
generated_libs,
23642362
configure,
23652363
make,

test/runner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def run_tests(options, suites):
364364
return num_failures
365365

366366

367-
def parse_args(args):
367+
def parse_args():
368368
parser = argparse.ArgumentParser(prog='runner.py', description=__doc__)
369369
parser.add_argument('--save-dir', action='store_true',
370370
help='Save the temporary directory used during for each '
@@ -412,8 +412,8 @@ def configure():
412412
parallel_testsuite.NUM_CORES = os.environ.get('EMTEST_CORES') or os.environ.get('EMCC_CORES')
413413

414414

415-
def main(args):
416-
options = parse_args(args)
415+
def main():
416+
options = parse_args()
417417

418418
# Some options make sense being set in the environment, others not-so-much.
419419
# TODO(sbc): eventually just make these command-line only.
@@ -494,7 +494,7 @@ def prepend_default(arg):
494494

495495
if __name__ == '__main__':
496496
try:
497-
sys.exit(main(sys.argv))
497+
sys.exit(main())
498498
except KeyboardInterrupt:
499499
logger.warning('KeyboardInterrupt')
500500
sys.exit(1)

test/test_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ def test_zzz_poppler(self):
11091109
}
11101110
''' % DEFAULT_ARG)
11111111

1112-
def lib_builder(name, native, env_init):
1112+
def lib_builder(name, native, env_init): # noqa
11131113
return self.get_poppler_library(env_init=env_init)
11141114

11151115
# TODO: Fix poppler native build and remove skip_native=True

test/test_browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from tools.utils import delete_dir
3232

3333

34-
def test_chunked_synchronous_xhr_server(support_byte_ranges, chunkSize, data, checksum, port):
34+
def test_chunked_synchronous_xhr_server(support_byte_ranges, data, port):
3535
class ChunkedServerHandler(BaseHTTPRequestHandler):
3636
def sendheaders(s, extra=None, length=None):
3737
length = length or len(data)
@@ -1722,7 +1722,7 @@ def test_chunked_synchronous_xhr(self):
17221722
data = os.urandom(10 * chunkSize + 1) # 10 full chunks and one 1 byte chunk
17231723
checksum = zlib.adler32(data) & 0xffffffff # Python 2 compatibility: force bigint
17241724

1725-
server = multiprocessing.Process(target=test_chunked_synchronous_xhr_server, args=(True, chunkSize, data, checksum, self.PORT))
1725+
server = multiprocessing.Process(target=test_chunked_synchronous_xhr_server, args=(True, data, self.PORT))
17261726
server.start()
17271727

17281728
# block until the server is actually ready

tools/link.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,7 @@ def phase_link(linker_arguments, wasm_target, js_syms):
19091909

19101910

19111911
@ToolchainProfiler.profile_block('post link')
1912-
def phase_post_link(options, state, in_wasm, wasm_target, target, js_syms, base_metadata=None, linker_inputs=None):
1912+
def phase_post_link(options, in_wasm, wasm_target, target, js_syms, base_metadata=None, linker_inputs=None):
19131913
global final_js
19141914

19151915
target_basename = unsuffixed_basename(target)
@@ -1941,7 +1941,7 @@ def phase_post_link(options, state, in_wasm, wasm_target, target, js_syms, base_
19411941

19421942
# If we are not emitting any JS then we are all done now
19431943
if options.oformat != OFormat.WASM:
1944-
phase_final_emitting(options, state, target, js_target, wasm_target)
1944+
phase_final_emitting(options, target, js_target, wasm_target)
19451945

19461946

19471947
@ToolchainProfiler.profile_block('emscript')
@@ -2110,7 +2110,7 @@ def create_worker_file(input_file, target_dir, output_file, options):
21102110

21112111

21122112
@ToolchainProfiler.profile_block('final emitting')
2113-
def phase_final_emitting(options, state, target, js_target, wasm_target):
2113+
def phase_final_emitting(options, target, js_target, wasm_target):
21142114
global final_js
21152115

21162116
if shared.SKIP_SUBPROCS:
@@ -3100,7 +3100,7 @@ def run_post_link(wasm_input, options, state):
31003100
settings.limit_settings(None)
31013101
target, wasm_target = phase_linker_setup(options, state)
31023102
process_libraries(state)
3103-
phase_post_link(options, state, wasm_input, wasm_target, target, {})
3103+
phase_post_link(options, wasm_input, wasm_target, target, {})
31043104

31053105

31063106
def run(linker_inputs, options, state):
@@ -3171,6 +3171,6 @@ def add_js_deps(sym):
31713171

31723172
# Perform post-link steps (unless we are running bare mode)
31733173
if options.oformat != OFormat.BARE:
3174-
phase_post_link(options, state, wasm_target, wasm_target, target, js_syms, base_metadata, linker_inputs)
3174+
phase_post_link(options, wasm_target, wasm_target, target, js_syms, base_metadata, linker_inputs)
31753175

31763176
return 0

tools/maint/rebaseline_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def process_changed_file(filename):
6262
return f'{filename}: {old_size} => {size} [{delta:+} bytes / {percent_delta:+.2f}%]\n'
6363

6464

65-
def main(argv):
65+
def main():
6666
parser = argparse.ArgumentParser()
6767
parser.add_argument('-s', '--skip-tests', action='store_true', help="Don't actually run the tests, just analyze the existing results")
6868
parser.add_argument('-b', '--new-branch', action='store_true', help='Create a new branch containing the updates')
@@ -131,4 +131,4 @@ def main(argv):
131131

132132

133133
if __name__ == '__main__':
134-
sys.exit(main(sys.argv))
134+
sys.exit(main())

0 commit comments

Comments
 (0)