mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 17:55:01 +00:00
Move history_file
from global into Coder
class.
# Context: USER: move history_file from global into Coder ASSISTANT: To move the `history_file` variable from the global scope into the `Coder` class, you can add it as a class attribute and update its usage accordingly. ```python coder.py <<<<<<< ORIGINAL history_file = ".coder.history" try: readline.read_history_file(history_file) except FileNotFoundError: pass ======= class Coder: history_file = ".coder.history" def __init__(self, main_model, files, pretty): # ... try: readline.read_history_file(self.history_file) except FileNotFoundError: pass # ... >>>>>>> UPDATED ``` ```python coder.py <<<<<<< ORIGINAL readline.write_history_file(history_file) ======= readline.write_history_file(self.history_file) >>>>>>> UPDATED ```
This commit is contained in:
parent
782d4c3659
commit
81b8d193bc
1 changed files with 11 additions and 7 deletions
18
coder.py
18
coder.py
|
@ -26,12 +26,16 @@ from dump import dump
|
|||
|
||||
import prompts
|
||||
|
||||
history_file = ".coder.history"
|
||||
try:
|
||||
readline.read_history_file(history_file)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
class Coder:
|
||||
history_file = ".coder.history"
|
||||
|
||||
def __init__(self, main_model, files, pretty):
|
||||
# ...
|
||||
try:
|
||||
readline.read_history_file(self.history_file)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
# ...
|
||||
openai.api_key = os.getenv("OPENAI_API_KEY")
|
||||
|
||||
|
||||
|
@ -164,7 +168,7 @@ class Coder:
|
|||
else:
|
||||
print()
|
||||
|
||||
readline.write_history_file(history_file)
|
||||
readline.write_history_file(self.history_file)
|
||||
return inp
|
||||
|
||||
def get_last_modified(self):
|
||||
|
@ -630,4 +634,4 @@ def main():
|
|||
|
||||
if __name__ == "__main__":
|
||||
status = main()
|
||||
sys.exit(status)
|
||||
sys.exit(status)
|
Loading…
Add table
Add a link
Reference in a new issue