From 919cfc23591d86cdc20f977f85af859416845f44 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 12 May 2023 13:03:34 -0700 Subject: [PATCH] aider: Replaced all self.console.print() calls with self.io.tool_error() calls with [red] removed from the string. # Context: USER: replace all the self.console.print() calls that contain [red] with calls to self.io.tool_error() with [red] removed from the string ASSISTANT: aider/coder.py <<<<<<< ORIGINAL self.console.print( f"[red]This tool will almost certainly fail to work with {main_model}" ) ======= self.io.tool_error(f"This tool will almost certainly fail to work with {main_model}") >>>>>>> UPDATED aider/coder.py <<<<<<< ORIGINAL self.console.print("[red]No suitable git repo, will not automatically commit edits.") ======= self.io.tool_error("No suitable git repo, will not automatically commit edits.") >>>>>>> UPDATED aider/coder.py <<<<<<< ORIGINAL self.console.print("[red]Files are not in a git repo.") ======= self.io.tool_error("Files are not in a git repo.") >>>>>>> UPDATED aider/coder.py <<<<<<< ORIGINAL self.console.print("[red]Files are in different git repos.") ======= self.io.tool_error("Files are in different git repos.") >>>>>>> UPDATED aider/coder.py <<<<<<< ORIGINAL self.console.print("[red]Skipped adding new files to the git repo.") ======= self.io.tool_error("Skipped adding new files to the git repo.") >>>>>>> UPDATED aider/coder.py <<<<<<< ORIGINAL self.console.print("[red]Warning: no changes found in tracked files.") ======= self.io.tool_error("Warning: no changes found in tracked files.") >>>>>>> UPDATED aider/coder.py <<<<<<< ORIGINAL self.console.print("[red]Malformed ORIGINAL/UPDATE blocks, retrying...") self.console.print("[red]", Text(err)) ======= self.io.tool_error("Malformed ORIGINAL/UPDATE blocks, retrying...") self.io.tool_error(Text(err)) >>>>>>> UPDATED Please note that I couldn't find the `self.io.tool_error()` method in the provided code. You may need to create this method in the appropriate class or provide the correct method name to replace the `self.console.print()` calls. --- aider/coder.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index 8ca5a34b7..7375b3bd3 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -46,14 +46,12 @@ class Coder: self.commands = Commands(self.console, self) self.main_model = main_model if main_model == "gpt-3.5-turbo": - self.console.print( - f"[red]This tool will almost certainly fail to work with {main_model}" - ) + self.io.tool_error(f"This tool will almost certainly fail to work with {main_model}") self.set_repo(fnames) if not self.repo: - self.console.print("[red]No suitable git repo, will not automatically commit edits.") + self.io.tool_error("No suitable git repo, will not automatically commit edits.") self.find_common_root() self.pretty = pretty @@ -96,10 +94,10 @@ class Coder: num_repos = len(set(repo_paths)) if num_repos == 0: - self.console.print("[red]Files are not in a git repo.") + self.io.tool_error("Files are not in a git repo.") return if num_repos > 1: - self.console.print("[red]Files are in different git repos.") + self.io.tool_error("Files are in different git repos.") return # https://github.com/gitpython-developers/GitPython/issues/427 @@ -127,7 +125,7 @@ class Coder: repo.git.commit("-m", commit_message, "--no-verify") self.console.print(f"Committed new files with message: {commit_message}") else: - self.console.print("[red]Skipped adding new files to the git repo.") + self.io.tool_error("Skipped adding new files to the git repo.") return self.repo = repo @@ -261,8 +259,8 @@ class Coder: edited = self.update_files(content, inp) except ValueError as err: err = err.args[0] - self.console.print("[red]Malformed ORIGINAL/UPDATE blocks, retrying...") - self.console.print("[red]", Text(err)) + self.io.tool_error("Malformed ORIGINAL/UPDATE blocks, retrying...") + self.io.tool_error(Text(err)) return err except Exception as err: @@ -291,7 +289,7 @@ class Coder: message=commit_message, ) else: - self.console.print("[red]Warning: no changes found in tracked files.") + self.io.tool_error("Warning: no changes found in tracked files.") saved_message = prompts.files_content_gpt_no_edits self.done_messages += self.cur_messages