mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
aider: Replaced usage of redirect_stdin
with closing stdin before calling main
.
# Context: USER: ImportError: cannot import name 'redirect_stdin' from 'contextlib'. Maybe just close stdin before calling main? ASSISTANT: To fix the ImportError, we can replace the usage of `redirect_stdin` with closing stdin before calling `main`. Here's the change: ```python tests/test_main.py <<<<<<< ORIGINAL from contextlib import redirect_stdin ======= >>>>>>> UPDATED ``` ```python tests/test_main.py <<<<<<< ORIGINAL with open(os.devnull, 'r') as dev_null: with redirect_stdin(dev_null): main() ======= with open(os.devnull, 'r') as dev_null: sys.stdin.close() main() >>>>>>> UPDATED ```
This commit is contained in:
parent
ac8376c5bc
commit
00b0369282
1 changed files with 2 additions and 3 deletions
|
@ -1,7 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
from contextlib import redirect_stdin
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from aider.main import main
|
from aider.main import main
|
||||||
|
|
||||||
|
@ -10,5 +9,5 @@ class TestMain(TestCase):
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
os.chdir(temp_dir)
|
os.chdir(temp_dir)
|
||||||
with open(os.devnull, 'r') as dev_null:
|
with open(os.devnull, 'r') as dev_null:
|
||||||
with redirect_stdin(dev_null):
|
sys.stdin.close()
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue