This commit is contained in:
Paul Gauthier 2023-05-13 12:47:39 -07:00
parent ca8a30ddda
commit 4be78293da

View file

@ -100,24 +100,28 @@ tests/test_main.py
These changes will replace the usage of `/dev/null` with `prompt_toolkit`'s input mocking functions.
---
> Applied edit to tests/test_main.py
> Applied edit to tests/test_main.py
> Applied edit to tests/test_main.py
> Applied edit to tests/test_main.py
> Commit c177e29 aider: Replaced usage of /dev/null with prompt_toolkit's input mocking functions in tests.
---
> Git repo has uncommitted changes.
> Suggested commit message:
Added import statement for sys module in test_main.py.
> Commit before the chat proceeds [y/n/commit message]? Added import statement for sys module in test_main.py.
> Commit 6724fcd Added import statement for sys module in test_main.py.
---
#### > /add aider/main.py
> Added aider/main.py to the chat
---
#### > I am getting this error: FAILED tests/test_main.py::TestMain::test_main_with_empty_git_dir_new_file - TypeError: main() got an unexpected keyword argument 'input'
I apologize for the confusion. It seems I made a mistake in the `main()` function definition in `aider/main.py`. The `main()` function should accept `input` and `output` keyword arguments. Here's the fix:
@ -141,10 +145,10 @@ def main(args=None, input=None, output=None):
Now, the `main()` function will accept the `input` and `output` keyword arguments, and the tests should pass.
---
> Applied edit to aider/main.py
> Commit 79dfba9 aider: Fixed main() function to accept input and output keyword arguments.
---
#### > we need to pass those into InputOutput and to prompt_toolkit right?
Yes, you're right. We need to pass the `input` and `output` arguments to the `InputOutput` class and then to the `prompt_toolkit.prompt()` function. Here's how to modify the `aider/getinput.py` and `aider/main.py` files:
@ -204,12 +208,12 @@ aider/main.py
These changes will ensure that the `input` and `output` arguments are passed to the `InputOutput` class and then to the `prompt_toolkit.prompt()` function.
---
> Applied edit to aider/getinput.py
> Applied edit to aider/getinput.py
> Applied edit to aider/main.py
> Commit cea9d2a aider: Updated InputOutput class to accept input and output arguments and passed them to prompt_toolkit.prompt() function.
---
#### > FAILED tests/test_main.py::TestMain::test_main_with_empty_git_dir_new_file - TypeError: prompt() got an unexpected keyword argument 'input'
I apologize for the confusion. It seems I made a mistake in the `prompt_toolkit.prompt()` function call. The `prompt()` function accepts `stdin` and `stdout` arguments instead of `input` and `output`. Here's the fix:
@ -229,10 +233,10 @@ aider/getinput.py
These changes will ensure that the `input` and `output` arguments are passed correctly to the `prompt_toolkit.prompt()` function.
---
> Applied edit to aider/getinput.py
> Commit 55d3540 aider: Fixed `prompt()` function call in `get_input()` method to pass `stdin` and `stdout` arguments instead of `input` and `output`.
---
#### > prompt_toolkit.shortcuts.prompt(message: AnyFormattedText | None = None, *, history: History | None = None, editing_mode: EditingMode | None = None, refresh_interval: float | None = None, vi_mode: bool | None = None, lexer: Lexer | None = None, completer: Completer | None = None, complete_in_thread: bool | None = None, is_password: bool | None = None, key_bindings: KeyBindingsBase | None = None, bottom_toolbar: AnyFormattedText | None = None, style: BaseStyle | None = None, color_depth: ColorDepth | None = None, cursor: AnyCursorShapeConfig = None, include_default_pygments_style: FilterOrBool | None = None, style_transformation: StyleTransformation | None = None, swap_light_and_dark_colors: FilterOrBool | None = None, rprompt: AnyFormattedText | None = None, multiline: FilterOrBool | None = None, prompt_continuation: PromptContinuationText | None = None, wrap_lines: FilterOrBool | None = None, enable_history_search: FilterOrBool | None = None, search_ignore_case: FilterOrBool | None = None, complete_while_typing: FilterOrBool | None = None, validate_while_typing: FilterOrBool | None = None, complete_style: CompleteStyle | None = None, auto_suggest: AutoSuggest | None = None, validator: Validator | None = None, clipboard: Clipboard | None = None, mouse_support: FilterOrBool | None = None, input_processors: list[Processor] | None = None, placeholder: AnyFormattedText | None = None, reserve_space_for_menu: int | None = None, enable_system_prompt: FilterOrBool | None = None, enable_suspend: FilterOrBool | None = None, enable_open_in_editor: FilterOrBool | None = None, tempfile_suffix: str | Callable[[], str] | None = None, tempfile: str | Callable[[], str] | None = None, default: str = '', accept_default: bool = False, pre_run: Callable[[], None] | None = None) → str
I apologize for the confusion earlier. It seems that the `prompt_toolkit.prompt()` function does not accept `stdin` and `stdout` arguments directly. Instead, we need to use the `Application` class from `prompt_toolkit` to create a custom application with the desired input and output. Here's how to modify the `aider/getinput.py` file:
@ -289,11 +293,11 @@ aider/getinput.py
These changes will ensure that the `input` and `output` arguments are passed correctly to the `prompt_toolkit`'s `PromptSession` class.
---
> Applied edit to aider/getinput.py
> Applied edit to aider/getinput.py
> Commit ac92cca aider: Replaced `prompt()` with `PromptSession()` to correctly pass input and output arguments.
---
#### > try using create_input(StringIO('')) in the tests
@ -344,13 +348,13 @@ tests/test_main.py
These changes will replace the usage of `create_pipe_input()` with `create_input(StringIO(''))` in the test cases.
---
> Applied edit to tests/test_main.py
> Applied edit to tests/test_main.py
> Applied edit to tests/test_main.py
> Applied edit to tests/test_main.py
> Commit 4bb043f aider: Replaced the usage of `create_pipe_input()` with `create_input(StringIO(''))` in the test cases.
---
#### > nice, that worked!
I'm glad the changes worked for you! If you have any more requests or need further assistance, feel free to ask.