@@ -241,17 +241,24 @@ def load_logs(
241241 def compare_logs (gen_lines : list [str ], ref_lines : list [str ]) -> None :
242242 """Compare log lines, ignoring specific differences."""
243243
244+ def get_section_ignore_lines (line : str ) -> list [str ]:
245+ """Return ignore lines for a section if the line starts with the section."""
246+ section = line .rsplit (SECTION_SEPARATOR , 1 )[- 1 ].strip ()
247+ for key , ignore_lines in IGNORE_SECTIONS .items ():
248+ if section .startswith (key ):
249+ return ignore_lines
250+
251+ return []
252+
244253 def extra_lines (
245254 lines1 : list [str ], lines2 : list [str ]
246255 ) -> list [Optional [str ]]:
247- """Return lines in lines1 but not in lines2, with line numbers and ignoring specified lines ."""
248- diffs : list [ Optional [ str ]] = []
256+ """Return lines in lines1 but not in lines2 with line numbers."""
257+ diffs = []
249258 section_ignore_lines = []
250- section = None
251259 for ind , line in enumerate (lines1 ):
252260 if line .startswith (SECTION_SEPARATOR ):
253- section = line .rsplit (SECTION_SEPARATOR )[- 1 ].strip ()
254- section_ignore_lines = IGNORE_SECTIONS .get (section , [])
261+ section_ignore_lines = get_section_ignore_lines (line )
255262 if line not in lines2 and not should_skip_line (
256263 line , ignore_lines = IGNORE_LINES + section_ignore_lines
257264 ):
@@ -282,13 +289,12 @@ def extra_lines(
282289 # Case 2: same line counts, check for diffs
283290 diffs = []
284291 section_ignore_lines = []
285- section = None
292+
286293 for ind , (gen_l , ref_l ) in enumerate (zip (gen_lines , ref_lines )):
287294 if gen_l .startswith (SECTION_SEPARATOR ) and ref_l .startswith (
288295 SECTION_SEPARATOR
289296 ):
290- section = gen_l .rsplit (SECTION_SEPARATOR )[- 1 ].strip ()
291- section_ignore_lines = IGNORE_SECTIONS .get (section , [])
297+ section_ignore_lines = get_section_ignore_lines (gen_l )
292298 if gen_l != ref_l and not should_skip_line (
293299 gen_l , ref_l , ignore_lines = IGNORE_LINES + section_ignore_lines
294300 ):
0 commit comments