@@ -556,23 +556,23 @@ def adjust_preprocessor_comments_for_filename(
556556 # - `force_print` indicates if a comment should be omitted
557557 if_stack = []
558558
559- def merge_escaped_lines (l , i ):
560- while l .endswith ("\\ " ):
561- l = l .removesuffix ("\\ " ).rstrip () + content [i + 1 ].lstrip ()
559+ def merge_escaped_lines (line , i ):
560+ while line .endswith ("\\ " ):
561+ line = line .removesuffix ("\\ " ).rstrip () + content [i + 1 ].lstrip ()
562562 i = i + 1
563- return (l , i )
563+ return (line , i )
564564
565- def merge_commented_lines (l , i ):
565+ def merge_commented_lines (line , i ):
566566 # Not very robust, but good enough
567- if not "/*" in l or "*/" in l :
568- return (l , i )
567+ if "/*" not in line or "*/" in line :
568+ return (line , i )
569569 i += 1
570570 while "*/" not in content [i ]:
571- l += content [i ]
571+ line += content [i ]
572572 i += 1
573573
574- l += content [i ]
575- return (l , i )
574+ line += content [i ]
575+ return (line , i )
576576
577577 def should_print (cur_line_no , conds , line_no , force_print ):
578578 line_threshold = 5
@@ -631,26 +631,26 @@ def adjust_preprocessor_comments_for_filename(
631631
632632 i = 0
633633 while i < len (content ):
634- l = content [i ].strip ()
634+ line = content [i ].strip ()
635635 # Replace #ifdef by #if defined(...)
636- if l .startswith ("#ifdef " ):
637- l = "#if defined(" + l .removeprefix ("#ifdef" ).strip () + ")"
638- if l .startswith ("#ifndef " ):
639- l = "#if !defined(" + l .removeprefix ("#ifndef" ).strip () + ")"
640- if l .startswith ("#if" ):
641- l , _ = merge_escaped_lines (l , i )
642- cond = l .removeprefix ("#if" )
636+ if line .startswith ("#ifdef " ):
637+ line = "#if defined(" + line .removeprefix ("#ifdef" ).strip () + ")"
638+ if line .startswith ("#ifndef " ):
639+ line = "#if !defined(" + line .removeprefix ("#ifndef" ).strip () + ")"
640+ if line .startswith ("#if" ):
641+ line , _ = merge_escaped_lines (line , i )
642+ cond = line .removeprefix ("#if" )
643643 if_stack .append (([cond ], i , True , False ))
644644 new_content .append (content [i ])
645- elif l .startswith ("#elif" ):
645+ elif line .startswith ("#elif" ):
646646 conds , _ , _ , force_print = if_stack .pop ()
647- l , _ = merge_escaped_lines (l , i )
648- conds .append (l .removeprefix ("#elif" ))
647+ line , _ = merge_escaped_lines (line , i )
648+ conds .append (line .removeprefix ("#elif" ))
649649 if_stack .append ((conds , i , True , force_print ))
650650 new_content .append (content [i ])
651- elif l .startswith ("#else" ):
652- l , i = merge_escaped_lines (l , i )
653- _ , i = merge_commented_lines (l , i )
651+ elif line .startswith ("#else" ):
652+ line , i = merge_escaped_lines (line , i )
653+ _ , i = merge_commented_lines (line , i )
654654 conds , j , branch , force_print = if_stack .pop ()
655655 assert branch is True
656656 print_else = should_print (i , cond , j , force_print )
@@ -660,9 +660,9 @@ def adjust_preprocessor_comments_for_filename(
660660 new_content .append (adhoc_format ("#else" , cond ))
661661 else :
662662 new_content .append ("#else" )
663- elif l .startswith ("#endif" ):
664- l , i = merge_escaped_lines (l , i )
665- _ , i = merge_commented_lines (l , i )
663+ elif line .startswith ("#endif" ):
664+ line , i = merge_escaped_lines (line , i )
665+ _ , i = merge_commented_lines (line , i )
666666 conds , j , branch , force_print = if_stack .pop ()
667667 print_endif = should_print (i , conds , j , force_print )
668668 if print_endif is False :
@@ -675,7 +675,7 @@ def adjust_preprocessor_comments_for_filename(
675675 # handle `#if ...` inside documentation as this would
676676 # lead to nested `/* ... */`.
677677 i_old = i
678- _ , i = merge_commented_lines (l , i_old )
678+ _ , i = merge_commented_lines (line , i_old )
679679 new_content += content [i_old : i + 1 ]
680680 i += 1
681681
@@ -944,12 +944,12 @@ def print_hol_light_array(g, as_int=True, entries_per_line=8, pad=0):
944944 c = "&" if as_int is True else ""
945945 return f"{ prefix } { c } { n :>{pad }} ;"
946946
947- l = list (map (format_hol_light_int , g ))
947+ items = list (map (format_hol_light_int , g ))
948948 # Remove `;` from end of last entry
949- l [- 1 ] = l [- 1 ][:- 1 ]
949+ items [- 1 ] = items [- 1 ][:- 1 ]
950950
951- for i in range (0 , len (l ), entries_per_line ):
952- yield " " + " " .join (l [i : i + entries_per_line ])
951+ for i in range (0 , len (items ), entries_per_line ):
952+ yield " " + " " .join (items [i : i + entries_per_line ])
953953
954954
955955def gen_aarch64_hol_light_zeta_file ():
@@ -1200,8 +1200,8 @@ def gen_avx2_fwd_ntt_zetas():
12001200 root_pairs = list (
12011201 map (lambda x : gen_twiddles (layer , block_base + x , repeat ), block_offsets )
12021202 )
1203- yield from (r for l in root_pairs for r in l [1 ])
1204- yield from (r for l in root_pairs for r in l [0 ])
1203+ yield from (r for pair in root_pairs for r in pair [1 ])
1204+ yield from (r for pair in root_pairs for r in pair [0 ])
12051205
12061206 # Layers 1 twiddle
12071207 yield from gen_twiddles_many (0 , 0 , range (1 ), 4 )
@@ -1710,11 +1710,11 @@ def print_hol_light_word64_list(g, entries_per_line=4):
17101710 Analogous to print_hol_light_array but for int64 word lists.
17111711 Yields lines with leading indent, semicolon-separated.
17121712 """
1713- l = [f"word 0x{ v :016X} " for v in g ]
1713+ items = [f"word 0x{ v :016X} " for v in g ]
17141714
1715- for i in range (0 , len (l ), entries_per_line ):
1716- row = l [i : i + entries_per_line ]
1717- is_last = i + entries_per_line >= len (l )
1715+ for i in range (0 , len (items ), entries_per_line ):
1716+ row = items [i : i + entries_per_line ]
1717+ is_last = i + entries_per_line >= len (items )
17181718 line = "; " .join (row )
17191719 if not is_last :
17201720 line += ";"
@@ -2105,8 +2105,8 @@ def get_all_files():
21052105
21062106
21072107def get_defines_from_file (c ):
2108- for l in read_file (c ).split ("\n " ):
2109- m = _RE_DEFINE .match (l )
2108+ for line in read_file (c ).split ("\n " ):
2109+ m = _RE_DEFINE .match (line )
21102110 if m :
21112111 yield (c , m .group (1 ))
21122112
@@ -2143,7 +2143,9 @@ def get_checked_defines():
21432143
21442144def gen_monolithic_undef_all_core (filt = None , desc = "" ):
21452145 if filt is None :
2146- filt = lambda c : True
2146+
2147+ def filt (c ):
2148+ return True
21472149
21482150 if desc != "" :
21492151 yield "/*"
@@ -2655,22 +2657,22 @@ def check_macro_typos():
26552657def check_asm_register_aliases_for_file (filename ):
26562658 """Checks that `filename` has no mismatching or dangling register aliases"""
26572659
2658- def get_alias_def (l ):
2659- s = list (filter (lambda s : s != "" , l .strip ().split (" " )))
2660+ def get_alias_def (line ):
2661+ s = list (filter (lambda s : s != "" , line .strip ().split (" " )))
26602662 if len (s ) < 3 or s [1 ] != ".req" :
26612663 return None
26622664 return s [0 ]
26632665
2664- def get_alias_undef (l ):
2665- if l .strip ().startswith (".unreq" ) is False :
2666+ def get_alias_undef (line ):
2667+ if line .strip ().startswith (".unreq" ) is False :
26662668 return None
2667- return list (filter (lambda s : s != "" , l .strip ().split (" " )))[1 ]
2669+ return list (filter (lambda s : s != "" , line .strip ().split (" " )))[1 ]
26682670
26692671 content = read_file (filename )
26702672 aliases = {}
2671- for i , l in enumerate (content .split ("\n " )):
2672- alias_def = get_alias_def (l )
2673- alias_undef = get_alias_undef (l )
2673+ for i , line in enumerate (content .split ("\n " )):
2674+ alias_def = get_alias_def (line )
2675+ alias_undef = get_alias_undef (line )
26742676 if alias_def is not None :
26752677 if alias_def in aliases .keys ():
26762678 raise Exception (
@@ -3225,7 +3227,9 @@ def synchronize_file(f, in_dir, out_dir, delete=False, no_simplify=False, **kwar
32253227 # don't do it here, the dry-run would fail because of a
32263228 # mismatching intermediate file
32273229 if f .endswith (".h" ):
3228- transform = lambda c : adjust_header_guard_for_filename (c , outfile_full )
3230+
3231+ def transform (c ):
3232+ return adjust_header_guard_for_filename (c , outfile_full )
32293233 else :
32303234 transform = None
32313235 update_via_copy (f , outfile_full , transform = transform )
@@ -3410,8 +3414,8 @@ def adjust_header_guard_for_filename(content, header_file):
34103414
34113415 # Skip over initial commentary
34123416 insert_at = None
3413- for i , l in enumerate (content ):
3414- if l .strip () == "" or l .startswith (("/*" , " *" )):
3417+ for i , line in enumerate (content ):
3418+ if line .strip () == "" or line .startswith (("/*" , " *" )):
34153419 continue
34163420 insert_at = i
34173421 break
@@ -3623,8 +3627,8 @@ def gen_markdown_citations_for(filename, bibliography):
36233627
36243628 # Lookup all citations in style `[^ID]`
36253629 citations = {}
3626- for i , l in enumerate (content ):
3627- for m in _RE_MARKDOWN_CITE .finditer (l ):
3630+ for i , line in enumerate (content ):
3631+ for m in _RE_MARKDOWN_CITE .finditer (line ):
36283632 cite_id = m .group ("id" )
36293633 uses = citations .get (cite_id , [])
36303634 uses .append ((filename , i ))
@@ -3641,8 +3645,8 @@ def gen_markdown_citations_for(filename, bibliography):
36413645 # Find explicit footnote definitions outside the bibliography block
36423646 # These are lines matching `[^ID]: ...` and should be excluded from autogeneration
36433647 explicit_footnotes = set ()
3644- for l in content :
3645- m = re .match (r"^\[\^(\w+)\]:" , l )
3648+ for line in content :
3649+ m = re .match (r"^\[\^(\w+)\]:" , line )
36463650 if m :
36473651 explicit_footnotes .add (m .group (1 ))
36483652
@@ -3691,8 +3695,8 @@ def gen_c_citations_for(filename, bibliography):
36913695
36923696 # Lookup all citations in style `@[ID]`
36933697 citations = {}
3694- for i , l in enumerate (content ):
3695- for m in _RE_C_CITE .finditer (l ):
3698+ for i , line in enumerate (content ):
3699+ for m in _RE_C_CITE .finditer (line ):
36963700 cite_id = m .group ("id" )
36973701 uses = citations .get (cite_id , [])
36983702 # Remember usage. +1 because line counting starts at 1
@@ -3742,8 +3746,8 @@ def gen_c_citations_for(filename, bibliography):
37423746 # Add references to file after initial header section
37433747 # Skip over copyright
37443748 insert_at = None
3745- for i , l in enumerate (content ):
3746- if l .startswith (("/*" , " *" )):
3749+ for i , line in enumerate (content ):
3750+ if line .startswith (("/*" , " *" )):
37473751 continue
37483752 insert_at = i
37493753 break
0 commit comments