Skip to content

Commit 7025fad

Browse files
committed
Get last few confirmations and helper functions async, fix tests to account for that
1 parent 9f79808 commit 7025fad

8 files changed

Lines changed: 76 additions & 65 deletions

File tree

aider/commands.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __init__(
8686
self.original_read_only_fnames = set(original_read_only_fnames or [])
8787
self.cmd_running = False
8888

89-
def cmd_model(self, args):
89+
async def cmd_model(self, args):
9090
"Switch the Main Model to a new LLM"
9191

9292
model_name = args.strip()
@@ -100,7 +100,7 @@ def cmd_model(self, args):
100100
editor_model=self.coder.main_model.editor_model.name,
101101
weak_model=self.coder.main_model.weak_model.name,
102102
)
103-
models.sanity_check_models(self.io, model)
103+
await models.sanity_check_models(self.io, model)
104104

105105
# Check if the current edit format is the default for the old model
106106
old_model_edit_format = self.coder.main_model.edit_format
@@ -113,7 +113,7 @@ def cmd_model(self, args):
113113

114114
raise SwitchCoder(main_model=model, edit_format=new_edit_format)
115115

116-
def cmd_editor_model(self, args):
116+
async def cmd_editor_model(self, args):
117117
"Switch the Editor Model to a new LLM"
118118

119119
model_name = args.strip()
@@ -122,10 +122,10 @@ def cmd_editor_model(self, args):
122122
editor_model=model_name,
123123
weak_model=self.coder.main_model.weak_model.name,
124124
)
125-
models.sanity_check_models(self.io, model)
125+
await models.sanity_check_models(self.io, model)
126126
raise SwitchCoder(main_model=model)
127127

128-
def cmd_weak_model(self, args):
128+
async def cmd_weak_model(self, args):
129129
"Switch the Weak Model to a new LLM"
130130

131131
model_name = args.strip()
@@ -134,7 +134,7 @@ def cmd_weak_model(self, args):
134134
editor_model=self.coder.main_model.editor_model.name,
135135
weak_model=model_name,
136136
)
137-
models.sanity_check_models(self.io, model)
137+
await models.sanity_check_models(self.io, model)
138138
raise SwitchCoder(main_model=model)
139139

140140
def cmd_chat_mode(self, args):
@@ -1370,7 +1370,7 @@ async def cmd_help(self, args):
13701370
from aider.coders.base_coder import Coder
13711371

13721372
if not self.help:
1373-
res = install_help_extra(self.io)
1373+
res = await install_help_extra(self.io)
13741374
if not res:
13751375
self.io.tool_error("Unable to initialize interactive help.")
13761376
return

aider/help.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
warnings.simplefilter("ignore", category=FutureWarning)
1616

1717

18-
def install_help_extra(io):
18+
async def install_help_extra(io):
1919
pip_install_cmd = [
2020
"aider-ce[help]",
2121
"--extra-index-url",
2222
"https://download.pytorch.org/whl/cpu",
2323
]
24-
res = utils.check_pip_install_extra(
24+
res = await utils.check_pip_install_extra(
2525
io,
2626
"llama_index.embeddings.huggingface",
2727
"To use interactive /help you need to install the help extras",

aider/main.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ def guessed_wrong_repo(io, git_root, fnames, git_dname):
8989
return str(check_repo)
9090

9191

92-
def make_new_repo(git_root, io):
92+
async def make_new_repo(git_root, io):
9393
try:
9494
repo = git.Repo.init(git_root)
95-
check_gitignore(git_root, io, False)
95+
await check_gitignore(git_root, io, False)
9696
except ANY_GIT_ERROR as err: # issue #1233
9797
io.tool_error(f"Unable to create git repo in {git_root}")
9898
io.tool_output(str(err))
@@ -102,7 +102,7 @@ def make_new_repo(git_root, io):
102102
return repo
103103

104104

105-
def setup_git(git_root, io):
105+
async def setup_git(git_root, io):
106106
if git is None:
107107
return
108108

@@ -123,11 +123,11 @@ def setup_git(git_root, io):
123123
"You should probably run aider in your project's directory, not your home dir."
124124
)
125125
return
126-
elif cwd and io.confirm_ask(
126+
elif cwd and await io.confirm_ask(
127127
"No git repo found, create one to track aider's changes (recommended)?"
128128
):
129129
git_root = str(cwd.resolve())
130-
repo = make_new_repo(git_root, io)
130+
repo = await make_new_repo(git_root, io)
131131

132132
if not repo:
133133
return
@@ -156,7 +156,7 @@ def setup_git(git_root, io):
156156
return repo.working_tree_dir
157157

158158

159-
def check_gitignore(git_root, io, ask=True):
159+
async def check_gitignore(git_root, io, ask=True):
160160
if not git_root:
161161
return
162162

@@ -192,7 +192,9 @@ def check_gitignore(git_root, io, ask=True):
192192

193193
if ask:
194194
io.tool_output("You can skip this check with --no-gitignore")
195-
if not io.confirm_ask(f"Add {', '.join(patterns_to_add)} to .gitignore (recommended)?"):
195+
if not await io.confirm_ask(
196+
f"Add {', '.join(patterns_to_add)} to .gitignore (recommended)?"
197+
):
196198
return
197199

198200
content += "\n".join(patterns_to_add) + "\n"
@@ -209,16 +211,16 @@ def check_gitignore(git_root, io, ask=True):
209211
io.tool_output(f" {pattern}")
210212

211213

212-
def check_streamlit_install(io):
213-
return utils.check_pip_install_extra(
214+
async def check_streamlit_install(io):
215+
return await utils.check_pip_install_extra(
214216
io,
215217
"streamlit",
216218
"You need to install the aider browser feature",
217219
["aider-ce[browser]"],
218220
)
219221

220222

221-
def write_streamlit_credentials():
223+
async def write_streamlit_credentials():
222224
from streamlit.file_util import get_streamlit_file_path
223225

224226
# See https://github.com/Aider-AI/aider/issues/772
@@ -722,7 +724,7 @@ def get_io(pretty):
722724
" personal info."
723725
)
724726
io.tool_output(f"For more info: {urls.analytics}")
725-
disable = not io.confirm_ask(
727+
disable = not await io.confirm_ask(
726728
"Allow collection of anonymous analytics to help improve aider?"
727729
)
728730

@@ -740,7 +742,7 @@ def get_io(pretty):
740742
analytics.event("launched")
741743

742744
if args.gui and not return_coder:
743-
if not check_streamlit_install(io):
745+
if not await check_streamlit_install(io):
744746
analytics.event("exit", reason="Streamlit not installed")
745747
return
746748
analytics.event("gui session")
@@ -807,22 +809,22 @@ def get_io(pretty):
807809
return 0 if not update_available else 1
808810

809811
if args.install_main_branch:
810-
success = install_from_main_branch(io)
812+
success = await install_from_main_branch(io)
811813
analytics.event("exit", reason="Installed main branch")
812814
return 0 if success else 1
813815

814816
if args.upgrade:
815-
success = install_upgrade(io)
817+
success = await install_upgrade(io)
816818
analytics.event("exit", reason="Upgrade completed")
817819
return 0 if success else 1
818820

819821
if args.check_update:
820822
check_version(io, verbose=args.verbose)
821823

822824
if args.git:
823-
git_root = setup_git(git_root, io)
825+
git_root = await setup_git(git_root, io)
824826
if args.gitignore:
825-
check_gitignore(git_root, io)
827+
await check_gitignore(git_root, io)
826828

827829
if args.verbose:
828830
show = format_settings(parser, args)
@@ -970,7 +972,7 @@ def get_io(pretty):
970972
return 1
971973

972974
if args.show_model_warnings:
973-
problem = models.sanity_check_models(io, main_model)
975+
problem = await models.sanity_check_models(io, main_model)
974976
if problem:
975977
analytics.event("model warning", main_model=main_model)
976978
io.tool_output("You can skip this check with --no-show-model-warnings")

aider/models.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -846,17 +846,24 @@ def set_thinking_tokens(self, value):
846846
if current_beta:
847847
beta_features.update(current_beta.split(","))
848848
beta_features.add("thinking-2025-10-22")
849-
self.extra_params["extra_headers"]["anthropic-beta"] = ",".join(sorted(beta_features))
849+
self.extra_params["extra_headers"]["anthropic-beta"] = ",".join(
850+
sorted(beta_features)
851+
)
850852
else:
851853
if "thinking" in self.extra_params:
852854
del self.extra_params["thinking"]
853855
# Remove thinking beta header if thinking is disabled
854-
if "extra_headers" in self.extra_params and "anthropic-beta" in self.extra_params["extra_headers"]:
856+
if (
857+
"extra_headers" in self.extra_params
858+
and "anthropic-beta" in self.extra_params["extra_headers"]
859+
):
855860
current_beta = self.extra_params["extra_headers"]["anthropic-beta"]
856861
beta_features = set(current_beta.split(","))
857862
beta_features.discard("thinking-2025-10-22")
858863
if beta_features:
859-
self.extra_params["extra_headers"]["anthropic-beta"] = ",".join(sorted(beta_features))
864+
self.extra_params["extra_headers"]["anthropic-beta"] = ",".join(
865+
sorted(beta_features)
866+
)
860867
else:
861868
del self.extra_params["extra_headers"]["anthropic-beta"]
862869
if not self.extra_params["extra_headers"]:
@@ -1145,25 +1152,25 @@ def validate_variables(vars):
11451152
return dict(keys_in_environment=True, missing_keys=missing)
11461153

11471154

1148-
def sanity_check_models(io, main_model):
1149-
problem_main = sanity_check_model(io, main_model)
1155+
async def sanity_check_models(io, main_model):
1156+
problem_main = await sanity_check_model(io, main_model)
11501157

11511158
problem_weak = None
11521159
if main_model.weak_model and main_model.weak_model is not main_model:
1153-
problem_weak = sanity_check_model(io, main_model.weak_model)
1160+
problem_weak = await sanity_check_model(io, main_model.weak_model)
11541161

11551162
problem_editor = None
11561163
if (
11571164
main_model.editor_model
11581165
and main_model.editor_model is not main_model
11591166
and main_model.editor_model is not main_model.weak_model
11601167
):
1161-
problem_editor = sanity_check_model(io, main_model.editor_model)
1168+
problem_editor = await sanity_check_model(io, main_model.editor_model)
11621169

11631170
return problem_main or problem_weak or problem_editor
11641171

11651172

1166-
def sanity_check_model(io, model):
1173+
async def sanity_check_model(io, model):
11671174
show = False
11681175

11691176
if model.missing_keys:
@@ -1185,7 +1192,7 @@ def sanity_check_model(io, model):
11851192
io.tool_warning(f"Warning for {model}: Unknown which environment variables are required.")
11861193

11871194
# Check for model-specific dependencies
1188-
check_for_dependencies(io, model.name)
1195+
await check_for_dependencies(io, model.name)
11891196

11901197
if not model.info:
11911198
show = True
@@ -1202,7 +1209,7 @@ def sanity_check_model(io, model):
12021209
return show
12031210

12041211

1205-
def check_for_dependencies(io, model_name):
1212+
async def check_for_dependencies(io, model_name):
12061213
"""
12071214
Check for model-specific dependencies and install them if needed.
12081215
@@ -1212,13 +1219,13 @@ def check_for_dependencies(io, model_name):
12121219
"""
12131220
# Check if this is a Bedrock model and ensure boto3 is installed
12141221
if model_name.startswith("bedrock/"):
1215-
check_pip_install_extra(
1222+
await check_pip_install_extra(
12161223
io, "boto3", "AWS Bedrock models require the boto3 package.", ["boto3"]
12171224
)
12181225

12191226
# Check if this is a Vertex AI model and ensure google-cloud-aiplatform is installed
12201227
elif model_name.startswith("vertex_ai/"):
1221-
check_pip_install_extra(
1228+
await check_pip_install_extra(
12221229
io,
12231230
"google.cloud.aiplatform",
12241231
"Google Vertex AI models require the google-cloud-aiplatform package.",

aider/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def touch_file(fname):
338338
return False
339339

340340

341-
def check_pip_install_extra(io, module, prompt, pip_install_cmd, self_update=False):
341+
async def check_pip_install_extra(io, module, prompt, pip_install_cmd, self_update=False):
342342
if module:
343343
try:
344344
__import__(module)
@@ -357,7 +357,9 @@ def check_pip_install_extra(io, module, prompt, pip_install_cmd, self_update=Fal
357357
print(printable_shell_command(cmd)) # plain print so it doesn't line-wrap
358358
return
359359

360-
if not io.confirm_ask("Run pip install?", default="y", subject=printable_shell_command(cmd)):
360+
if not await io.confirm_ask(
361+
"Run pip install?", default="y", subject=printable_shell_command(cmd)
362+
):
361363
return
362364

363365
success, output = run_install(cmd)

aider/versioncheck.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
VERSION_CHECK_FNAME = Path.home() / ".aider" / "caches" / "versioncheck"
1313

1414

15-
def install_from_main_branch(io):
15+
async def install_from_main_branch(io):
1616
"""
1717
Install the latest version of aider from the main branch of the GitHub repository.
1818
"""
1919

20-
return utils.check_pip_install_extra(
20+
return await utils.check_pip_install_extra(
2121
io,
2222
None,
2323
"Install the development version of aider from the main branch?",
@@ -26,7 +26,7 @@ def install_from_main_branch(io):
2626
)
2727

2828

29-
def install_upgrade(io, latest_version=None):
29+
async def install_upgrade(io, latest_version=None):
3030
"""
3131
Install the latest version of aider from PyPI.
3232
"""
@@ -46,7 +46,7 @@ def install_upgrade(io, latest_version=None):
4646
io.tool_warning(text)
4747
return True
4848

49-
success = utils.check_pip_install_extra(
49+
success = await utils.check_pip_install_extra(
5050
io,
5151
None,
5252
new_ver_text,
@@ -75,7 +75,7 @@ def check_version(io, just_check=False, verbose=False):
7575
import requests
7676

7777
try:
78-
response = requests.get("https://pypi.org/pypi/aider-chat/json")
78+
response = requests.get("https://pypi.org/pypi/aider-ce/json")
7979
data = response.json()
8080
latest_version = data["info"]["version"]
8181
current_version = aider.__version__

0 commit comments

Comments
 (0)