From 34c2369380355dee305ce0d999a6fca4343a3cfa Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 11 May 2023 17:43:28 -0700 Subject: [PATCH] aider: Created a new function `confirm_ask` in the `Coder` class and replaced all calls to `Confirm.ask` with the new function. # Context: USER: make a new func self.confirm_ask which just calls Confirm.ask and returns the result. change all calls to use it. ASSISTANT: I will create a new function `confirm_ask` in the `Coder` class and replace all calls to `Confirm.ask` with the new function. ```python aider/coder.py <<<<<<< ORIGINAL class Coder: abs_fnames = set() ======= class Coder: abs_fnames = set() def confirm_ask(self, question, default="y"): return Confirm.ask(question, console=self.console, default=default) >>>>>>> UPDATED aider/coder.py <<<<<<< ORIGINAL if Confirm.ask("[bright_black]Add them?", console=self.console, default="y"): ======= if self.confirm_ask("[bright_black]Add them?"): >>>>>>> UPDATED aider/coder.py <<<<<<< ORIGINAL if Confirm.ask("[bright_black]Add {path} to git?", console=self.console, default="y"): ======= if self.confirm_ask("[bright_black]Add {path} to git?"): >>>>>>> UPDATED aider/coder.py <<<<<<< ORIGINAL ok = Confirm.ask("[bright_black]Add these files?", console=self.console, default="y") ======= ok = self.confirm_ask("[bright_black]Add these files?") >>>>>>> UPDATED ``` --- aider/coder.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index 082dbabfa..277e2104d 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -30,6 +30,9 @@ openai.api_key = os.getenv("OPENAI_API_KEY") class Coder: abs_fnames = set() + def confirm_ask(self, question, default="y"): + return Confirm.ask(question, console=self.console, default=default) + repo = None last_aider_commit_hash = None @@ -117,7 +120,7 @@ class Coder: self.console.print(f"[bright_black]Files not tracked in {repo.git_dir}:") for fn in new_files: self.console.print(f"[bright_black] {fn}") - if Confirm.ask("[bright_black]Add them?", console=self.console, default="y"): + if self.confirm_ask("[bright_black]Add them?"): for relative_fname in new_files: repo.git.add(relative_fname) self.console.print(f"[bright_black]Added {relative_fname} to the git repo") @@ -305,7 +308,7 @@ class Coder: for rel_fname in mentioned_rel_fnames: self.console.print(f"[bright_black]{rel_fname}") - ok = Confirm.ask("[bright_black]Add these files?", console=self.console, default="y") + if self.confirm_ask("[bright_black]Add {path} to git?"): if not ok: return