From ba9307374e3d3248fc6bd91ca47918327c342dfe Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 18 May 2023 18:21:44 -0700 Subject: [PATCH] cleanup Coder params --- aider/coder.py | 15 +++++++++++---- aider/main.py | 14 ++++++-------- tests/test_commands.py | 12 ++---------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index 29a6440be..f257f16ed 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -28,14 +28,21 @@ class Coder: last_aider_commit_hash = None last_asked_for_commit_time = 0 - def __init__(self, main_model, fnames, pretty, show_diffs, auto_commits, io, dry_run): + def __init__( + self, + io, + main_model="gpt-4", + fnames=None, + pretty=True, + show_diffs=False, + auto_commits=True, + dry_run=False, + ): self.abs_fnames = set() - - self.io = io - self.cur_messages = [] self.done_messages = [] + self.io = io self.auto_commits = auto_commits self.dry_run = dry_run diff --git a/aider/main.py b/aider/main.py index 10fcdd611..2a9981019 100644 --- a/aider/main.py +++ b/aider/main.py @@ -88,8 +88,6 @@ def main(args=None, input=None, output=None): default=False, ) args = parser.parse_args(args) - fnames = args.files - pretty = args.pretty io = InputOutput( args.pretty, @@ -103,13 +101,13 @@ def main(args=None, input=None, output=None): io.tool(*sys.argv, log_only=True) coder = Coder( - args.model, - fnames, - pretty, - args.show_diffs, - args.auto_commits, io, - args.dry_run, + main_model=args.model, + fnames=args.files, + pretty=args.pretty, + show_diffs=args.show_diffs, + auto_commits=args.auto_commits, + dry_run=args.dry_run, ) if args.auto_commits: coder.commit(ask=True, prefix="wip: ", which="repo_files") diff --git a/tests/test_commands.py b/tests/test_commands.py index 58eb99725..02d99bdac 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -4,6 +4,7 @@ import unittest from aider.commands import Commands from aider.io import InputOutput as IO from aider.coder import Coder +from unittest.mock import MagicMock # noqa: F401 class TestCommands(unittest.TestCase): @@ -12,18 +13,9 @@ class TestCommands(unittest.TestCase): os.chdir(tmpdir) io = IO(pretty=False, yes=True) - coder = Coder( - main_model="gpt-3.5-turbo", - fnames=[], - pretty=False, - show_diffs=False, - auto_commits=False, - io=io, - dry_run=False, - ) + coder = Coder(io) commands = Commands(io, coder) - # Mock the Confirm.ask method to return True for creating files with unittest.mock.patch("rich.prompt.Confirm.ask", return_value=True): commands.cmd_add("foo.txt bar.txt")