1- import difflib
21import re
32from pathlib import Path
43from typing import Any , Optional
54
6- from git import Repo , InvalidGitRepositoryError
7- from patchwork .logger import logger
5+ from git import InvalidGitRepositoryError , Repo
86from openai .types .chat import ChatCompletionMessageParam
97
108from patchwork .common .client .llm .aio import AioLlmClient
1513 AnalyzeImplementStrategy ,
1614)
1715from patchwork .common .tools import CodeEditTool , Tool
16+ from patchwork .logger import logger
1817from patchwork .step import Step
1918from patchwork .steps .FixIssue .typed import FixIssueInputs , FixIssueOutputs
2019
@@ -100,7 +99,7 @@ def is_stop(self, messages: list[ChatCompletionMessageParam]) -> bool:
10099class FixIssue (Step , input_class = FixIssueInputs , output_class = FixIssueOutputs ):
101100 def __init__ (self , inputs ):
102101 """Initialize the FixIssue step.
103-
102+
104103 Args:
105104 inputs: Dictionary containing input parameters including:
106105 - base_path: Optional path to the repository root
@@ -145,12 +144,12 @@ def __init__(self, inputs):
145144
146145 def run (self ):
147146 """Execute the FixIssue step.
148-
147+
149148 This method:
150149 1. Executes the multi-turn LLM conversation to analyze and fix the issue
151150 2. Tracks file modifications made by the CodeEditTool
152151 3. Generates in-memory diffs for all modified files
153-
152+
154153 Returns:
155154 dict: Dictionary containing list of modified files with their diffs
156155 """
@@ -162,8 +161,7 @@ def run(self):
162161 if not isinstance (tool , CodeEditTool ):
163162 continue
164163 tool_modified_files = [
165- dict (path = str (file_path .relative_to (cwd )), diff = "" )
166- for file_path in tool .tool_records ["modified_files" ]
164+ dict (path = str (file_path .relative_to (cwd )), diff = "" ) for file_path in tool .tool_records ["modified_files" ]
167165 ]
168166 modified_files .extend (tool_modified_files )
169167
@@ -174,7 +172,7 @@ def run(self):
174172 file = modified_file ["path" ]
175173 try :
176174 # Try to get the diff using git
177- diff = self .repo .git .diff (' HEAD' , file )
175+ diff = self .repo .git .diff (" HEAD" , file )
178176 modified_file ["diff" ] = diff or ""
179177 except Exception as e :
180178 # Git-specific errors (untracked files, etc) - keep empty diff
0 commit comments