From 2570a4d193e43c49a2baca4ed0ad471674f2b20b Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Sun, 25 Aug 2024 07:55:08 -0700 Subject: [PATCH] style: Format code with black --- aider/models.py | 4 +++- aider/utils.py | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/aider/models.py b/aider/models.py index f8a3ba484..de748bd9e 100644 --- a/aider/models.py +++ b/aider/models.py @@ -458,7 +458,9 @@ class Model(ModelSettings): cache_dir.mkdir(parents=True, exist_ok=True) current_time = time.time() - cache_age = current_time - cache_file.stat().st_mtime if cache_file.exists() else float('inf') + cache_age = ( + current_time - cache_file.stat().st_mtime if cache_file.exists() else float("inf") + ) if cache_file.exists() and cache_age < 86400: # 86400 seconds = 1 day content = safe_read_json(cache_file) diff --git a/aider/utils.py b/aider/utils.py index fb09f05f0..018cc2878 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -82,6 +82,7 @@ def make_repo(path=None): import json + def is_image_file(file_name): """ Check if the given file name has an image file extension. @@ -92,16 +93,18 @@ def is_image_file(file_name): file_name = str(file_name) # Convert file_name to string return any(file_name.endswith(ext) for ext in IMAGE_EXTENSIONS) + def safe_read_json(file_path): try: - with open(file_path, 'r') as f: + with open(file_path, "r") as f: return json.load(f) except Exception: return None + def safe_write_json(file_path, data): try: - with open(file_path, 'w') as f: + with open(file_path, "w") as f: json.dump(data, f) return True except Exception: