style: Run linter on onboarding module

This commit is contained in:
Paul Gauthier (aider) 2025-03-28 17:13:48 -10:00
parent 1b2a4db1ed
commit 15fe0afe62

View file

@ -59,10 +59,14 @@ def select_default_model(args, io, analytics):
return selected_model
# No API keys found - Offer OpenRouter OAuth
io.tool_warning("No API key environment variables found (e.g., OPENAI_API_KEY, ANTHROPIC_API_KEY...).")
io.tool_warning(
"No API key environment variables found (e.g., OPENAI_API_KEY, ANTHROPIC_API_KEY...)."
)
# Use confirm_ask which handles non-interactive cases
if io.confirm_ask(
"Authenticate with OpenRouter via browser to get an API key?", default="y", group="openrouter_oauth"
"Authenticate with OpenRouter via browser to get an API key?",
default="y",
group="openrouter_oauth",
):
analytics.event("oauth_flow_initiated", provider="openrouter")
openrouter_key = start_openrouter_oauth_flow(io, analytics)
@ -138,7 +142,9 @@ def exchange_code_for_key(code, code_verifier, io):
io.tool_error("Error: Request to OpenRouter timed out during code exchange.")
return None
except requests.exceptions.HTTPError as e:
io.tool_error(f"Error exchanging code for OpenRouter key: {e.status_code} {e.response.reason}")
io.tool_error(
f"Error exchanging code for OpenRouter key: {e.status_code} {e.response.reason}"
)
io.tool_error(f"Response: {e.response.text}")
return None
except requests.exceptions.RequestException as e:
@ -246,7 +252,9 @@ def start_openrouter_oauth_flow(io, analytics):
code_verifier, code_challenge = generate_pkce_codes()
auth_url = f"https://openrouter.ai/auth?callback_url={callback_url}&code_challenge={code_challenge}&code_challenge_method=S256"
io.tool_output("\nPlease open the following URL in your web browser to authorize Aider with OpenRouter:")
io.tool_output(
"\nPlease open the following URL in your web browser to authorize Aider with OpenRouter:"
)
io.tool_output(auth_url)
io.tool_output("\nWaiting for authentication... (Timeout: 2 minutes)")