style: Run linter on patch_coder.py

This commit is contained in:
Paul Gauthier (aider) 2025-04-14 14:36:27 -07:00
parent 8cc8027b40
commit 8b9238ebc9

View file

@ -20,7 +20,9 @@ class Chunk:
orig_index: int = -1
del_lines: List[str] = field(default_factory=list)
ins_lines: List[str] = field(default_factory=list)
context_before: List[str] = field(default_factory=list) # Store context for validation/application
context_before: List[str] = field(
default_factory=list
) # Store context for validation/application
@dataclass
@ -158,7 +160,6 @@ class PatchCoder(Coder):
return edits
def apply_edits(self, edits: List[PatchAction]):
"""
Applies the parsed PatchActions to the corresponding files.
@ -180,7 +181,9 @@ class PatchCoder(Coder):
raise ValueError(f"ADD change for {action.path} has no content")
# Ensure parent directory exists
path_obj.parent.mkdir(parents=True, exist_ok=True)
self.io.write_text(full_path, action.new_content.rstrip('\n') + '\n') # Ensure single trailing newline
self.io.write_text(
full_path, action.new_content.rstrip("\n") + "\n"
) # Ensure single trailing newline
elif action.type == ActionType.DELETE:
if not path_obj.exists():
@ -201,7 +204,9 @@ class PatchCoder(Coder):
# Apply the update logic using the parsed chunks
new_content = self._apply_update(current_content, action.chunks, action.path)
target_full_path = self.abs_root_path(action.move_path) if action.move_path else full_path
target_full_path = (
self.abs_root_path(action.move_path) if action.move_path else full_path
)
target_path_obj = pathlib.Path(target_full_path)
# Ensure parent directory exists for target
@ -219,7 +224,6 @@ class PatchCoder(Coder):
# Raise a ValueError to signal failure, consistent with other coders.
raise ValueError(f"Error applying action '{action.type}' to {action.path}: {e}")
def _apply_update(self, text: str, chunks: List[Chunk], path: str) -> str:
"""
Applies UPDATE chunks to the given text content.
@ -251,7 +255,8 @@ class PatchCoder(Coder):
# The current simplified parser doesn't provide enough info (like validated indices).
# Raising NotImplementedError until a proper parser/applier is integrated.
raise NotImplementedError(
"_apply_update requires a robust parser and context handling, similar to apply_patch.py"
"_apply_update requires a robust parser and context handling, similar to"
" apply_patch.py"
)
# --- Hypothetical logic assuming correct indices ---
@ -275,7 +280,6 @@ class PatchCoder(Coder):
# current_orig_line_num = chunk_start_index + num_del
# --- End Hypothetical ---
# Add remaining lines after the last chunk
dest_lines.extend(orig_lines[current_orig_line_num:])