Fix formatting

This commit is contained in:
Sven van Heugten 2026-03-05 19:23:00 +01:00
parent 28e5f45598
commit af8fae68fe
No known key found for this signature in database
GPG key ID: D612F88666F4F660

View file

@ -4,14 +4,18 @@ import re
import sys import sys
def should_include_change(change_lines: list[str], search: str, replace: str) -> bool: def should_include_change(
change_lines: list[str], search: str, replace: str
) -> bool:
removed_lines = [] removed_lines = []
added_lines = [] added_lines = []
phase = "minus" phase = "minus"
for line in change_lines: for line in change_lines:
if line.startswith("-"): if line.startswith("-"):
if phase != "minus": if phase != "minus":
raise ValueError("Non-consecutive '-' and '+' lines in change block.") raise ValueError(
"Non-consecutive '-' and '+' lines in change block."
)
removed_lines.append(line[1:]) removed_lines.append(line[1:])
continue continue
if line.startswith("+"): if line.startswith("+"):
@ -19,7 +23,9 @@ def should_include_change(change_lines: list[str], search: str, replace: str) ->
added_lines.append(line[1:]) added_lines.append(line[1:])
continue continue
raise ValueError("Unexpected non-change line in change block.") raise ValueError("Unexpected non-change line in change block.")
transformed_removed = [re.sub(search, replace, line) for line in removed_lines] transformed_removed = [
re.sub(search, replace, line) for line in removed_lines
]
return transformed_removed == added_lines return transformed_removed == added_lines