Fix formatting
This commit is contained in:
parent
28e5f45598
commit
af8fae68fe
1 changed files with 9 additions and 3 deletions
|
|
@ -4,14 +4,18 @@ import re
|
|||
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 = []
|
||||
added_lines = []
|
||||
phase = "minus"
|
||||
for line in change_lines:
|
||||
if line.startswith("-"):
|
||||
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:])
|
||||
continue
|
||||
if line.startswith("+"):
|
||||
|
|
@ -19,7 +23,9 @@ def should_include_change(change_lines: list[str], search: str, replace: str) ->
|
|||
added_lines.append(line[1:])
|
||||
continue
|
||||
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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue