From 9badb711fff88089a89154d23846450f495bdbd2 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 8 May 2025 07:49:38 -0700 Subject: [PATCH] style: Run linter on aider/models.py --- aider/models.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/aider/models.py b/aider/models.py index cf0f832c7..1cb64d0bb 100644 --- a/aider/models.py +++ b/aider/models.py @@ -238,7 +238,6 @@ class ModelInfoManager: return cached_info - def fetch_openrouter_model_info(self, model): """ Fetch model info by scraping the openrouter model page. @@ -246,19 +245,23 @@ class ModelInfoManager: Example: openrouter/qwen/qwen-2.5-72b-instruct:free Returns a dict with keys: max_tokens, max_input_tokens, max_output_tokens, input_cost_per_token, output_cost_per_token. """ - url_part = model[len("openrouter/"):] + url_part = model[len("openrouter/") :] url = "https://openrouter.ai/" + url_part try: import requests + response = requests.get(url, timeout=5, verify=self.verify_ssl) if response.status_code != 200: return {} html = response.text import re - if re.search(rf'The model\s*.*{re.escape(url_part)}.* is not available', html, re.IGNORECASE): + + if re.search( + rf"The model\s*.*{re.escape(url_part)}.* is not available", html, re.IGNORECASE + ): print(f"\033[91mError: Model '{url_part}' is not available\033[0m") return {} - text = re.sub(r'<[^>]+>', ' ', html) + text = re.sub(r"<[^>]+>", " ", html) context_match = re.search(r"([\d,]+)\s*context", text) if context_match: context_str = context_match.group(1).replace(",", "") @@ -283,6 +286,7 @@ class ModelInfoManager: print("Error fetching openrouter info:", str(e)) return {} + model_info_manager = ModelInfoManager() @@ -523,7 +527,6 @@ class Model(ModelSettings): self.use_repo_map = True return # <-- - # use the defaults if self.edit_format == "diff": self.use_repo_map = True