From a9ca534de7c2daf8e4c707325cd5024d13bb189e Mon Sep 17 00:00:00 2001 From: Harshad Hegde Date: Fri, 15 Dec 2023 15:31:44 -0600 Subject: [PATCH] Activate Bugbear rules --- pyproject.toml | 2 +- src/curate_gpt/cli.py | 2 +- src/curate_gpt/utils/vectordb_operations.py | 2 +- src/llm_gpt4all.py | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 336f326..bb028a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -97,7 +97,7 @@ fixable = ["ALL"] # Select or ignore from https://beta.ruff.rs/docs/rules/ select = [ - # "B", # bugbear + "B", # bugbear # "D", # pydocstyle # "E", # pycodestyle errors "F", # Pyflakes diff --git a/src/curate_gpt/cli.py b/src/curate_gpt/cli.py index e80308f..494bba4 100644 --- a/src/curate_gpt/cli.py +++ b/src/curate_gpt/cli.py @@ -1243,7 +1243,7 @@ def ask(query, path, collection, model, show_references, _continue, conversation conversation = load_conversation(conversation_id) print(f"CONTINUING CONVERSATION {conversation}") except UnknownModelError as ex: - raise click.ClickException(str(ex)) + raise click.ClickException(str(ex)) from ex chatbot = ChatAgent(path) chatbot.extractor = extractor chatbot.knowledge_source = db diff --git a/src/curate_gpt/utils/vectordb_operations.py b/src/curate_gpt/utils/vectordb_operations.py index 65cf46d..86d322d 100644 --- a/src/curate_gpt/utils/vectordb_operations.py +++ b/src/curate_gpt/utils/vectordb_operations.py @@ -36,6 +36,6 @@ def match_collections( tm_ix, tm_vals = top_matches(sim_matrix) logger.info(f"Yielding {len(tm_ix)} matches") i = 0 - for ix, val in zip(tm_ix, tm_vals): + for ix, val in zip(tm_ix, tm_vals, strict=True): yield left_objs[i][0], right_objs[ix][0], val i += 1 diff --git a/src/llm_gpt4all.py b/src/llm_gpt4all.py index 5efa459..bcd1647 100644 --- a/src/llm_gpt4all.py +++ b/src/llm_gpt4all.py @@ -163,14 +163,16 @@ def fetch_cached_json(url, path, cache_timeout): json.dump(response.json(), file) return response.json() - except (httpx.HTTPError, urllib3.exceptions.NameResolutionError): + except (httpx.HTTPError, urllib3.exceptions.NameResolutionError) as ex: # If there's an existing file, load it if path.is_file(): with open(path, "r") as file: return json.load(file) else: # If not, raise an error - raise DownloadError(f"Failed to download data and no cache is available at {path}") + raise DownloadError( + f"Failed to download data and no cache is available at {path}. Error: {ex}" + ) from ex def human_readable_size(size_bytes):