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.
This commit is contained in:
Paul Gauthier 2023-05-12 13:03:34 -07:00
parent b7299565f1
commit 919cfc2359

View file

@ -46,14 +46,12 @@ class Coder:
self.commands = Commands(self.console, self) self.commands = Commands(self.console, self)
self.main_model = main_model self.main_model = main_model
if main_model == "gpt-3.5-turbo": if main_model == "gpt-3.5-turbo":
self.console.print( self.io.tool_error(f"This tool will almost certainly fail to work with {main_model}")
f"[red]This tool will almost certainly fail to work with {main_model}"
)
self.set_repo(fnames) self.set_repo(fnames)
if not self.repo: 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.find_common_root()
self.pretty = pretty self.pretty = pretty
@ -96,10 +94,10 @@ class Coder:
num_repos = len(set(repo_paths)) num_repos = len(set(repo_paths))
if num_repos == 0: 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 return
if num_repos > 1: 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 return
# https://github.com/gitpython-developers/GitPython/issues/427 # https://github.com/gitpython-developers/GitPython/issues/427
@ -127,7 +125,7 @@ class Coder:
repo.git.commit("-m", commit_message, "--no-verify") repo.git.commit("-m", commit_message, "--no-verify")
self.console.print(f"Committed new files with message: {commit_message}") self.console.print(f"Committed new files with message: {commit_message}")
else: 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 return
self.repo = repo self.repo = repo
@ -261,8 +259,8 @@ class Coder:
edited = self.update_files(content, inp) edited = self.update_files(content, inp)
except ValueError as err: except ValueError as err:
err = err.args[0] err = err.args[0]
self.console.print("[red]Malformed ORIGINAL/UPDATE blocks, retrying...") self.io.tool_error("Malformed ORIGINAL/UPDATE blocks, retrying...")
self.console.print("[red]", Text(err)) self.io.tool_error(Text(err))
return err return err
except Exception as err: except Exception as err:
@ -291,7 +289,7 @@ class Coder:
message=commit_message, message=commit_message,
) )
else: 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 saved_message = prompts.files_content_gpt_no_edits
self.done_messages += self.cur_messages self.done_messages += self.cur_messages