Skip to content

Commit 7f21cc3

Browse files
committed
Scripts: Drop dead assignments and stray f-string prefixes
Enable ruff F841 (unused variable) and F541 (empty f-string) and address flagged code locations. Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
1 parent d8922d3 commit 7f21cc3

5 files changed

Lines changed: 14 additions & 19 deletions

File tree

proofs/cbmc/lib/summarize.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ def export_result_json(output_path, run_file):
137137

138138
failures, runtimes = [], []
139139
for name, status, duration_str in proof_table[1:]: # skip header
140-
is_timeout = duration_str == "TIMEOUT"
141140
is_success = status == "Success"
142141

143142
if not is_success:

ruff.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,4 @@ ignore = [
1818
"E713", # `not in` rather than `not X in Y`
1919
"E731", # lambda assignment
2020
"E741", # ambiguous variable name
21-
"F541", # f-string without any placeholders
22-
"F841", # unused variable
2321
]

scripts/autogen

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,7 +2592,6 @@ def get_syscaps():
25922592

25932593
def check_macro_typos():
25942594
files = get_all_files()
2595-
configs = get_config_options()
25962595
syscaps = get_syscaps()
25972596

25982597
macros = set(map(lambda t: t[1], get_defines(all=True)))
@@ -2713,7 +2712,6 @@ def check_asm_loop_labels_for_file(filename):
27132712
content = read_file(filename)
27142713

27152714
# Find function symbol name
2716-
func_pattern = r"MLK_ASM_FN_SYMBOL\((.*)\)"
27172715
res = _RE_FUNC_SYMBOL.search(content)
27182716
if res is None:
27192717
raise Exception(f"Could not find function symbol in assembly file {filename}")
@@ -2894,7 +2892,7 @@ def update_via_simpasm(
28942892
# Add syntax option for x86_64
28952893
if arch == "x86_64" and x86_64_syntax != "att":
28962894
cmd += ["--syntax", x86_64_syntax]
2897-
r = subprocess.run(
2895+
subprocess.run(
28982896
cmd,
28992897
stdout=subprocess.DEVNULL,
29002898
stderr=subprocess.PIPE,
@@ -3290,7 +3288,7 @@ def synchronize_backends(
32903288
)
32913289

32923290
update_via_copy(
3293-
f"dev/x86_64/meta.h",
3291+
"dev/x86_64/meta.h",
32943292
"mlkem/src/native/x86_64/meta.h",
32953293
transform=lambda c: adjust_header_guard_for_filename(
32963294
c, "mlkem/src/native/x86_64/meta.h"
@@ -3404,7 +3402,7 @@ def adjust_header_guard_for_filename(content, header_file):
34043402
yield f"#define {guard_name}"
34053403

34063404
def gen_footer():
3407-
yield f"#endif"
3405+
yield "#endif"
34083406
yield ""
34093407

34103408
guard = list(gen_guard())
@@ -3714,7 +3712,7 @@ def gen_c_citations_for(filename, bibliography):
37143712
raise Exception(
37153713
f"Could not find bibliography entry {cite_id} referenced in {filename}"
37163714
)
3717-
references.append(f" *")
3715+
references.append(" *")
37183716
references.append(f" * - [{cite_id}]")
37193717
prefix = " * "
37203718
# Wrap long lines at 80 chars
@@ -3799,11 +3797,11 @@ def gen_bib_file(bibliography):
37993797
content.append(f"### `{cite_id}`")
38003798
content.append("")
38013799
content.append(f"* {entry.name}")
3802-
content.append(f"* Author(s):")
3800+
content.append("* Author(s):")
38033801
for author in entry.authors:
38043802
content.append(f" - {author}")
38053803
content.append(f"* URL: {entry.url}")
3806-
content.append(f"* Referenced from:")
3804+
content.append("* Referenced from:")
38073805
# Usages are pairs of (filename, line_count)
38083806
# Ignore line_count for now, as it would require `autogen` after
38093807
# a change to source files.

scripts/simpasm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def simplify(logger, args, asm_input, asm_output=None):
274274
autogen_header = [
275275
"",
276276
"/*",
277-
f" * WARNING: This file is auto-derived from the mlkem-native source file",
277+
" * WARNING: This file is auto-derived from the mlkem-native source file",
278278
f" * {asm_input} using scripts/simpasm. Do not modify it directly.",
279279
" */",
280280
"",
@@ -352,7 +352,7 @@ def simplify(logger, args, asm_input, asm_output=None):
352352
+ elf_stack_section
353353
)
354354

355-
logger.debug(f"Assembling simplified assembly ...")
355+
logger.debug("Assembling simplified assembly ...")
356356
logger.debug(new_asm)
357357
logger.debug(f"Command: {' '.join(cmd)}")
358358
run_cmd(cmd, input=new_asm)

scripts/tests

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ def cli():
13171317
)
13181318

13191319
# wycheproof arguments
1320-
wycheproof_parser = cmd_subparsers.add_parser(
1320+
cmd_subparsers.add_parser(
13211321
"wycheproof", help="Run Wycheproof client", parents=[common_parser]
13221322
)
13231323

@@ -1377,7 +1377,7 @@ def cli():
13771377
action="store_true",
13781378
default=False,
13791379
)
1380-
size_parser = cmd_subparsers.add_parser(
1380+
cmd_subparsers.add_parser(
13811381
"size",
13821382
help="Run the code size measurement for all object file",
13831383
parents=[common_parser],
@@ -1493,12 +1493,12 @@ def cli():
14931493
)
14941494

14951495
# kat arguments
1496-
kat_parser = cmd_subparsers.add_parser(
1496+
cmd_subparsers.add_parser(
14971497
"kat", help="Run the kat tests for all parameter sets", parents=[common_parser]
14981498
)
14991499

15001500
# unit arguments
1501-
unit_parser = cmd_subparsers.add_parser(
1501+
cmd_subparsers.add_parser(
15021502
"unit",
15031503
help="Run the unit tests for all parameter sets",
15041504
parents=[common_parser],
@@ -1524,14 +1524,14 @@ def cli():
15241524
)
15251525

15261526
# alloc arguments
1527-
alloc_parser = cmd_subparsers.add_parser(
1527+
cmd_subparsers.add_parser(
15281528
"alloc",
15291529
help="Run the alloc tests for all parameter sets",
15301530
parents=[common_parser],
15311531
)
15321532

15331533
# rng_fail arguments
1534-
rng_fail_parser = cmd_subparsers.add_parser(
1534+
cmd_subparsers.add_parser(
15351535
"rng_fail",
15361536
help="Run the RNG failure tests for all parameter sets",
15371537
parents=[common_parser],

0 commit comments

Comments
 (0)