From 8043613e0aadcb6d5fffd4f1dc466f911088ac73 Mon Sep 17 00:00:00 2001 From: Simon Suo <simonsdsuo@gmail.com> Date: Mon, 30 Oct 2023 11:05:23 -0700 Subject: [PATCH] Check for unused import in ruff (#8574) --- .vscode/settings.json | 9 ++++----- docs/conf.py | 2 -- ...torStoreIndex_vs_CustomIndex_combined.ipynb | 4 +--- .../NebulaGraphKGIndexDemo.ipynb | 4 +--- docs/examples/low_level/ingestion.ipynb | 4 ++-- llama_index/agent/react/base.py | 1 - llama_index/agent/types.py | 2 +- llama_index/callbacks/finetuning_handler.py | 4 +--- llama_index/composability/base.py | 2 +- .../embeddings/text_embeddings_inference.py | 2 +- llama_index/evaluation/base.py | 4 ++-- llama_index/evaluation/correctness.py | 2 +- llama_index/evaluation/dataset_generation.py | 2 +- llama_index/evaluation/faithfulness.py | 4 ++-- llama_index/evaluation/guideline.py | 2 +- llama_index/evaluation/pairwise.py | 2 +- llama_index/evaluation/relevancy.py | 4 ++-- llama_index/evaluation/semantic_similarity.py | 2 +- .../finetuning/cross_encoders/cross_encoder.py | 2 +- llama_index/graph_stores/nebulagraph.py | 2 +- llama_index/indices/base_retriever.py | 2 +- .../indices/managed/vectara/retriever.py | 4 ++-- .../indices/postprocessor/llm_rerank.py | 2 +- .../indices/postprocessor/longllmlingua.py | 5 +---- llama_index/indices/postprocessor/types.py | 2 +- llama_index/indices/query/base.py | 3 +-- .../indices/query/query_transform/base.py | 2 +- llama_index/indices/struct_store/json_query.py | 2 +- llama_index/llm_predictor/vellum/predictor.py | 2 +- llama_index/llm_predictor/vellum/types.py | 1 - llama_index/llms/ai21.py | 2 +- llama_index/llms/bedrock.py | 2 -- llama_index/llms/bedrock_utils.py | 5 +---- .../node_parser/unstructured_element.py | 6 +++--- llama_index/playground/base.py | 2 +- .../program/predefined/evaporate/extractor.py | 2 +- llama_index/program/utils.py | 1 - llama_index/prompts/mixin.py | 2 +- llama_index/query_engine/__init__.py | 3 ++- .../query_engine/flare/answer_inserter.py | 2 +- llama_index/query_engine/flare/base.py | 2 +- .../query_engine/multistep_query_engine.py | 2 +- .../query_engine/pandas_query_engine.py | 2 +- .../query_engine/retriever_query_engine.py | 2 +- .../query_engine/sub_question_query_engine.py | 2 +- .../query_engine/transform_query_engine.py | 2 +- llama_index/question_gen/guidance_generator.py | 2 +- llama_index/question_gen/llm_generators.py | 2 +- llama_index/question_gen/openai_generator.py | 2 +- llama_index/question_gen/types.py | 2 +- llama_index/readers/deeplake.py | 2 +- llama_index/readers/discord_reader.py | 2 +- llama_index/readers/faiss.py | 2 +- .../readers/file/image_caption_reader.py | 4 ++-- llama_index/readers/file/image_reader.py | 6 +++--- .../readers/file/image_vision_llm_reader.py | 4 ++-- llama_index/readers/file/mbox_reader.py | 2 +- llama_index/readers/file/slides_reader.py | 6 +++--- llama_index/readers/google_readers/gdocs.py | 6 +++--- llama_index/readers/google_readers/gsheets.py | 6 +++--- llama_index/readers/metal.py | 2 +- llama_index/readers/milvus.py | 8 ++++---- llama_index/readers/schema/base.py | 2 +- llama_index/readers/steamship/file_reader.py | 2 +- llama_index/readers/weaviate/reader.py | 4 ++-- llama_index/readers/web.py | 14 +++++++------- llama_index/readers/wikipedia.py | 2 +- .../response_synthesizers/accumulate.py | 4 ++-- llama_index/response_synthesizers/base.py | 5 ++--- .../response_synthesizers/generation.py | 4 ++-- llama_index/response_synthesizers/refine.py | 4 ++-- .../response_synthesizers/simple_summarize.py | 2 +- .../response_synthesizers/tree_summarize.py | 4 ++-- llama_index/selectors/embedding_selectors.py | 6 ++---- llama_index/selectors/llm_selectors.py | 2 +- llama_index/selectors/pydantic_selectors.py | 2 +- llama_index/selectors/types.py | 4 ++-- .../storage/docstore/dynamodb_docstore.py | 2 -- .../index_store/dynamodb_index_store.py | 2 -- .../storage/kvstore/dynamodb_kvstore.py | 2 +- llama_index/text_splitter/code_splitter.py | 2 +- llama_index/tools/query_engine.py | 2 +- llama_index/vector_stores/chroma.py | 2 +- llama_index/vector_stores/cogsearch.py | 2 +- llama_index/vector_stores/docarray/hnsw.py | 2 +- .../vector_stores/docarray/in_memory.py | 2 +- llama_index/vector_stores/dynamodb.py | 2 +- llama_index/vector_stores/elasticsearch.py | 2 +- llama_index/vector_stores/metal.py | 2 +- llama_index/vector_stores/milvus.py | 2 +- llama_index/vector_stores/postgres.py | 10 ++++------ llama_index/vector_stores/qdrant.py | 2 +- llama_index/vector_stores/rocksetdb.py | 2 +- llama_index/vector_stores/tair.py | 2 +- llama_index/vector_stores/tencentvectordb.py | 3 +-- llama_index/vector_stores/timescalevector.py | 2 +- llama_index/vector_stores/weaviate.py | 6 +++--- llama_index/vector_stores/weaviate_utils.py | 2 +- pyproject.toml | 1 + tests/evaluation/test_base.py | 4 ++-- tests/finetuning/test_base.py | 18 ++++++------------ tests/output_parsers/test_selection.py | 2 -- tests/prompts/test_mixin.py | 3 +-- tests/vector_stores/test_cassandra.py | 6 +++--- tests/vector_stores/test_postgres.py | 6 +++--- tests/vector_stores/test_tencentvectordb.py | 2 +- 106 files changed, 151 insertions(+), 189 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 598a079bc..5e8319696 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,9 @@ { - "python.formatting.provider": "none", - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.organizeImports": true - }, "[python]": { + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll": true + }, "editor.defaultFormatter": "ms-python.black-formatter" }, "python.testing.pytestArgs": ["tests"], diff --git a/docs/conf.py b/docs/conf.py index 7f0de33d8..174e71ccc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,8 +13,6 @@ import os import sys -import sphinx_rtd_theme - sys.path.insert(0, os.path.abspath("../")) with open("../llama_index/VERSION") as f: diff --git a/docs/examples/index_structs/knowledge_graph/KnowledgeGraphIndex_vs_VectorStoreIndex_vs_CustomIndex_combined.ipynb b/docs/examples/index_structs/knowledge_graph/KnowledgeGraphIndex_vs_VectorStoreIndex_vs_CustomIndex_combined.ipynb index 0d0d09401..e43670db8 100644 --- a/docs/examples/index_structs/knowledge_graph/KnowledgeGraphIndex_vs_VectorStoreIndex_vs_CustomIndex_combined.ipynb +++ b/docs/examples/index_structs/knowledge_graph/KnowledgeGraphIndex_vs_VectorStoreIndex_vs_CustomIndex_combined.ipynb @@ -215,9 +215,7 @@ "os.environ[\"NEBULA_PASSWORD\"] = \"nebula\"\n", "os.environ[\n", " \"NEBULA_ADDRESS\"\n", - "] = ( # assumed we have NebulaGraph 3.5.0 or newer installed locally\n", - " \"127.0.0.1:9669\"\n", - ")\n", + "] = \"127.0.0.1:9669\" # assumed we have NebulaGraph 3.5.0 or newer installed locally\n", "\n", "# Assume that the graph has already been created\n", "# Create a NebulaGraph cluster with:\n", diff --git a/docs/examples/index_structs/knowledge_graph/NebulaGraphKGIndexDemo.ipynb b/docs/examples/index_structs/knowledge_graph/NebulaGraphKGIndexDemo.ipynb index e16537a0a..444128431 100644 --- a/docs/examples/index_structs/knowledge_graph/NebulaGraphKGIndexDemo.ipynb +++ b/docs/examples/index_structs/knowledge_graph/NebulaGraphKGIndexDemo.ipynb @@ -189,9 +189,7 @@ "] = \"<password>\" # replace with your password, by default it is \"nebula\"\n", "os.environ[\n", " \"NEBULA_ADDRESS\"\n", - "] = ( # assumed we have NebulaGraph 3.5.0 or newer installed locally\n", - " \"127.0.0.1:9669\"\n", - ")\n", + "] = \"127.0.0.1:9669\" # assumed we have NebulaGraph 3.5.0 or newer installed locally\n", "\n", "# Assume that the graph has already been created\n", "# Create a NebulaGraph cluster with:\n", diff --git a/docs/examples/low_level/ingestion.ipynb b/docs/examples/low_level/ingestion.ipynb index 2d6387d83..d35129d05 100644 --- a/docs/examples/low_level/ingestion.ipynb +++ b/docs/examples/low_level/ingestion.ipynb @@ -111,8 +111,8 @@ "metadata": {}, "outputs": [], "source": [ - "dotenv_path = ( # Google Colabs will not let you open a .env, but you can set\n", - " \"env\"\n", + "dotenv_path = (\n", + " \"env\" # Google Colabs will not let you open a .env, but you can set\n", ")\n", "with open(dotenv_path, \"w\") as f:\n", " f.write('PINECONE_API_KEY=\"<your api key>\"\\n')\n", diff --git a/llama_index/agent/react/base.py b/llama_index/agent/react/base.py index edb1a189e..fbffcbc3f 100644 --- a/llama_index/agent/react/base.py +++ b/llama_index/agent/react/base.py @@ -15,7 +15,6 @@ from typing import ( ) from aiostream import stream as async_stream -from aiostream.core import Stream from llama_index.agent.react.formatter import ReActChatFormatter from llama_index.agent.react.output_parser import ReActOutputParser diff --git a/llama_index/agent/types.py b/llama_index/agent/types.py index 7aa73e74a..8cd296b89 100644 --- a/llama_index/agent/types.py +++ b/llama_index/agent/types.py @@ -6,7 +6,7 @@ from llama_index.chat_engine.types import BaseChatEngine, StreamingAgentChatResp from llama_index.indices.query.base import BaseQueryEngine from llama_index.indices.query.schema import QueryBundle from llama_index.llms.base import ChatMessage -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType, PromptMixinType from llama_index.response.schema import RESPONSE_TYPE, Response diff --git a/llama_index/callbacks/finetuning_handler.py b/llama_index/callbacks/finetuning_handler.py index 97927cb43..811c7be81 100644 --- a/llama_index/callbacks/finetuning_handler.py +++ b/llama_index/callbacks/finetuning_handler.py @@ -1,8 +1,6 @@ import json from abc import abstractmethod -from typing import Any, Dict, List, Optional, Type - -from pydantic import BaseModel +from typing import Any, Dict, List, Optional from llama_index.callbacks.base import BaseCallbackHandler from llama_index.callbacks.schema import CBEventType, EventPayload diff --git a/llama_index/composability/base.py b/llama_index/composability/base.py index 7012aa024..1eb6b0cfc 100644 --- a/llama_index/composability/base.py +++ b/llama_index/composability/base.py @@ -1,4 +1,4 @@ """Composable graph.""" # TODO: remove this file, only keep for backwards compatibility -from llama_index.indices.composability.graph import ComposableGraph +from llama_index.indices.composability.graph import ComposableGraph # noqa diff --git a/llama_index/embeddings/text_embeddings_inference.py b/llama_index/embeddings/text_embeddings_inference.py index 62162ee98..e7140a2c4 100644 --- a/llama_index/embeddings/text_embeddings_inference.py +++ b/llama_index/embeddings/text_embeddings_inference.py @@ -39,7 +39,7 @@ class TextEmbeddingsInference(BaseEmbedding): callback_manager: Optional[CallbackManager] = None, ): try: - import httpx + import httpx # noqa except ImportError: raise ImportError( "TextEmbeddingsInterface requires httpx to be installed.\n" diff --git a/llama_index/evaluation/base.py b/llama_index/evaluation/base.py index 037f017ad..bd44cc7ff 100644 --- a/llama_index/evaluation/base.py +++ b/llama_index/evaluation/base.py @@ -1,10 +1,10 @@ """Evaluator.""" import asyncio -from abc import ABC, abstractmethod +from abc import abstractmethod from typing import Any, Optional, Sequence from llama_index.bridge.pydantic import BaseModel, Field -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptMixin, PromptMixinType from llama_index.response.schema import Response diff --git a/llama_index/evaluation/correctness.py b/llama_index/evaluation/correctness.py index 5386af644..8257d6320 100644 --- a/llama_index/evaluation/correctness.py +++ b/llama_index/evaluation/correctness.py @@ -10,7 +10,7 @@ from llama_index.prompts import ( MessageRole, PromptTemplate, ) -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType DEFAULT_SYSTEM_TEMPLATE = """ You are an expert evaluation system for a question answering chatbot. diff --git a/llama_index/evaluation/dataset_generation.py b/llama_index/evaluation/dataset_generation.py index 65514fad0..87bad050e 100644 --- a/llama_index/evaluation/dataset_generation.py +++ b/llama_index/evaluation/dataset_generation.py @@ -5,7 +5,7 @@ import asyncio import json import re import uuid -from typing import Dict, List, Optional, Tuple +from typing import Dict, List, Tuple from pydantic import BaseModel, Field diff --git a/llama_index/evaluation/faithfulness.py b/llama_index/evaluation/faithfulness.py index e972f855c..46cd3f367 100644 --- a/llama_index/evaluation/faithfulness.py +++ b/llama_index/evaluation/faithfulness.py @@ -1,13 +1,13 @@ """Faithfulness evaluation.""" from __future__ import annotations -from typing import Any, Optional, Sequence, Union +from typing import Any, Sequence from llama_index import ServiceContext from llama_index.evaluation.base import BaseEvaluator, EvaluationResult from llama_index.indices import SummaryIndex from llama_index.prompts import BasePromptTemplate, PromptTemplate -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.schema import Document DEFAULT_EVAL_TEMPLATE = PromptTemplate( diff --git a/llama_index/evaluation/guideline.py b/llama_index/evaluation/guideline.py index 95ef50a28..debb1d437 100644 --- a/llama_index/evaluation/guideline.py +++ b/llama_index/evaluation/guideline.py @@ -7,7 +7,7 @@ from llama_index.bridge.pydantic import BaseModel, Field from llama_index.evaluation.base import BaseEvaluator, EvaluationResult from llama_index.output_parsers import PydanticOutputParser from llama_index.prompts import BasePromptTemplate, PromptTemplate -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType logger = logging.getLogger(__name__) diff --git a/llama_index/evaluation/pairwise.py b/llama_index/evaluation/pairwise.py index d11e2d5af..4223f88b7 100644 --- a/llama_index/evaluation/pairwise.py +++ b/llama_index/evaluation/pairwise.py @@ -11,7 +11,7 @@ from llama_index.prompts import ( MessageRole, PromptTemplate, ) -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType DEFAULT_SYSTEM_TEMPLATE = """ You are an expert evaluation system for a question answering chatbot. diff --git a/llama_index/evaluation/relevancy.py b/llama_index/evaluation/relevancy.py index 4ba37a75a..0ee2f1e42 100644 --- a/llama_index/evaluation/relevancy.py +++ b/llama_index/evaluation/relevancy.py @@ -1,13 +1,13 @@ """Relevancy evaluation.""" from __future__ import annotations -from typing import Any, Optional, Sequence, Union +from typing import Any, Sequence from llama_index import ServiceContext from llama_index.evaluation.base import BaseEvaluator, EvaluationResult from llama_index.indices import SummaryIndex from llama_index.prompts import BasePromptTemplate, PromptTemplate -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.schema import Document DEFAULT_EVAL_TEMPLATE = PromptTemplate( diff --git a/llama_index/evaluation/semantic_similarity.py b/llama_index/evaluation/semantic_similarity.py index e2ad6c70d..1e2d7efdd 100644 --- a/llama_index/evaluation/semantic_similarity.py +++ b/llama_index/evaluation/semantic_similarity.py @@ -3,7 +3,7 @@ from typing import Any, Callable, Optional, Sequence from llama_index.embeddings.base import SimilarityMode, similarity from llama_index.evaluation.base import BaseEvaluator, EvaluationResult from llama_index.indices.service_context import ServiceContext -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType class SemanticSimilarityEvaluator(BaseEvaluator): diff --git a/llama_index/finetuning/cross_encoders/cross_encoder.py b/llama_index/finetuning/cross_encoders/cross_encoder.py index 2ad4b2138..2bf783c45 100644 --- a/llama_index/finetuning/cross_encoders/cross_encoder.py +++ b/llama_index/finetuning/cross_encoders/cross_encoder.py @@ -108,7 +108,7 @@ class CrossEncoderFinetuneEngine(BaseCrossEncoderFinetuningEngine): self.model.model.push_to_hub(repo_id=repo_id) self.model.tokenizer.push_to_hub(repo_id=repo_id) - except ValueError as e: + except ValueError: raise ValueError( "HuggingFace CLI/Hub login not " "completed provide token to login using" diff --git a/llama_index/graph_stores/nebulagraph.py b/llama_index/graph_stores/nebulagraph.py index 3ea8e4177..408455650 100644 --- a/llama_index/graph_stores/nebulagraph.py +++ b/llama_index/graph_stores/nebulagraph.py @@ -130,7 +130,7 @@ class NebulaGraphStore(GraphStore): **kwargs: Keyword arguments. """ try: - import nebula3 + import nebula3 # noqa except ImportError: raise ImportError( "Please install NebulaGraph Python client first: " diff --git a/llama_index/indices/base_retriever.py b/llama_index/indices/base_retriever.py index 819c389bf..770d76790 100644 --- a/llama_index/indices/base_retriever.py +++ b/llama_index/indices/base_retriever.py @@ -1,4 +1,4 @@ -from abc import ABC, abstractmethod +from abc import abstractmethod from typing import List, Optional from llama_index.indices.query.schema import QueryBundle, QueryType diff --git a/llama_index/indices/managed/vectara/retriever.py b/llama_index/indices/managed/vectara/retriever.py index 5fb08c263..58f3a54e3 100644 --- a/llama_index/indices/managed/vectara/retriever.py +++ b/llama_index/indices/managed/vectara/retriever.py @@ -4,7 +4,7 @@ An index that that is built on top of Vectara. import json import logging -from typing import Any, List, Optional +from typing import Any, List from llama_index.constants import DEFAULT_SIMILARITY_TOP_K from llama_index.indices.base_retriever import BaseRetriever @@ -69,7 +69,7 @@ class VectaraRetriever(BaseRetriever): Args: query: Query Bundle """ - similarity_top_k = self._similarity_top_k + self._similarity_top_k corpus_key = { "customer_id": self._index._vectara_customer_id, "corpus_id": self._index._vectara_corpus_id, diff --git a/llama_index/indices/postprocessor/llm_rerank.py b/llama_index/indices/postprocessor/llm_rerank.py index 27ecef1da..432ededb0 100644 --- a/llama_index/indices/postprocessor/llm_rerank.py +++ b/llama_index/indices/postprocessor/llm_rerank.py @@ -11,7 +11,7 @@ from llama_index.indices.utils import ( ) from llama_index.prompts import BasePromptTemplate from llama_index.prompts.default_prompts import DEFAULT_CHOICE_SELECT_PROMPT -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.schema import NodeWithScore diff --git a/llama_index/indices/postprocessor/longllmlingua.py b/llama_index/indices/postprocessor/longllmlingua.py index 1e0391d7c..034de82eb 100644 --- a/llama_index/indices/postprocessor/longllmlingua.py +++ b/llama_index/indices/postprocessor/longllmlingua.py @@ -1,12 +1,9 @@ """Optimization related classes and functions.""" import logging -from typing import Any, Callable, Dict, List, Optional +from typing import Any, Dict, List, Optional from llama_index.bridge.pydantic import Field, PrivateAttr -from llama_index.embeddings.base import BaseEmbedding -from llama_index.embeddings.openai import OpenAIEmbedding from llama_index.indices.postprocessor.types import BaseNodePostprocessor -from llama_index.indices.query.embedding_utils import get_top_k_embeddings from llama_index.indices.query.schema import QueryBundle from llama_index.schema import MetadataMode, NodeWithScore, TextNode diff --git a/llama_index/indices/postprocessor/types.py b/llama_index/indices/postprocessor/types.py index c254a6752..a0e68a295 100644 --- a/llama_index/indices/postprocessor/types.py +++ b/llama_index/indices/postprocessor/types.py @@ -4,7 +4,7 @@ from typing import List, Optional from llama_index.bridge.pydantic import Field from llama_index.callbacks import CallbackManager from llama_index.indices.query.schema import QueryBundle -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType, PromptMixinType from llama_index.schema import BaseComponent, NodeWithScore diff --git a/llama_index/indices/query/base.py b/llama_index/indices/query/base.py index ddfb1d76e..8e7596db9 100644 --- a/llama_index/indices/query/base.py +++ b/llama_index/indices/query/base.py @@ -1,12 +1,11 @@ """Base query engine.""" import logging -from abc import ABC, abstractmethod +from abc import abstractmethod from typing import Any, Dict, List, Optional, Sequence from llama_index.callbacks.base import CallbackManager from llama_index.indices.query.schema import QueryBundle, QueryType -from llama_index.prompts.base import BasePromptTemplate from llama_index.prompts.mixin import PromptDictType, PromptMixin from llama_index.response.schema import RESPONSE_TYPE from llama_index.schema import NodeWithScore diff --git a/llama_index/indices/query/query_transform/base.py b/llama_index/indices/query/query_transform/base.py index 5bcd8d023..f488cc664 100644 --- a/llama_index/indices/query/query_transform/base.py +++ b/llama_index/indices/query/query_transform/base.py @@ -2,7 +2,7 @@ import dataclasses from abc import abstractmethod -from typing import Any, Dict, Optional, cast +from typing import Dict, Optional, cast from llama_index.indices.query.query_transform.prompts import ( DEFAULT_DECOMPOSE_QUERY_TRANSFORM_PROMPT, diff --git a/llama_index/indices/struct_store/json_query.py b/llama_index/indices/struct_store/json_query.py index d09faf68b..a749db43f 100644 --- a/llama_index/indices/struct_store/json_query.py +++ b/llama_index/indices/struct_store/json_query.py @@ -7,7 +7,7 @@ from llama_index.indices.query.schema import QueryBundle from llama_index.indices.service_context import ServiceContext from llama_index.prompts import BasePromptTemplate, PromptTemplate from llama_index.prompts.default_prompts import DEFAULT_JSON_PATH_PROMPT -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType, PromptMixinType from llama_index.prompts.prompt_type import PromptType from llama_index.response.schema import Response from llama_index.utils import print_text diff --git a/llama_index/llm_predictor/vellum/predictor.py b/llama_index/llm_predictor/vellum/predictor.py index 1d18448e1..f3ebf2063 100644 --- a/llama_index/llm_predictor/vellum/predictor.py +++ b/llama_index/llm_predictor/vellum/predictor.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, Optional, Tuple, cast +from typing import Any, Tuple, cast from llama_index.bridge.pydantic import PrivateAttr from llama_index.callbacks import CallbackManager diff --git a/llama_index/llm_predictor/vellum/types.py b/llama_index/llm_predictor/vellum/types.py index 3655aec7b..806900a5b 100644 --- a/llama_index/llm_predictor/vellum/types.py +++ b/llama_index/llm_predictor/vellum/types.py @@ -1,7 +1,6 @@ from __future__ import annotations from dataclasses import dataclass -from typing import Optional @dataclass(frozen=True, eq=True) diff --git a/llama_index/llms/ai21.py b/llama_index/llms/ai21.py index bc77c164c..305aadbca 100644 --- a/llama_index/llms/ai21.py +++ b/llama_index/llms/ai21.py @@ -44,7 +44,7 @@ class AI21(CustomLLM): ) -> None: """Initialize params.""" try: - import ai21 as _ + import ai21 as _ # noqa except ImportError as e: raise ImportError( "You must install the `ai21` package to use AI21." diff --git a/llama_index/llms/bedrock.py b/llama_index/llms/bedrock.py index e143cb9db..76983977d 100644 --- a/llama_index/llms/bedrock.py +++ b/llama_index/llms/bedrock.py @@ -1,5 +1,4 @@ import json -import warnings from typing import Any, Dict, Optional, Sequence from llama_index.bridge.pydantic import Field, PrivateAttr @@ -27,7 +26,6 @@ from llama_index.llms.bedrock_utils import ( get_text_from_response, stream_completion_to_chat_decorator, ) -from llama_index.llms.custom import CustomLLM class Bedrock(LLM): diff --git a/llama_index/llms/bedrock_utils.py b/llama_index/llms/bedrock_utils.py index 7e1c00afd..a560d509f 100644 --- a/llama_index/llms/bedrock_utils.py +++ b/llama_index/llms/bedrock_utils.py @@ -1,4 +1,3 @@ -import json import logging from typing import Any, Callable, Sequence @@ -17,8 +16,6 @@ from llama_index.llms.base import ( CompletionResponse, CompletionResponseGen, MessageRole, - llm_chat_callback, - llm_completion_callback, ) from llama_index.llms.generic_utils import ( completion_response_to_chat_response, @@ -98,7 +95,7 @@ def _create_retry_decorator(client: Any, max_retries: int) -> Callable[[Any], An # Wait 2^x * 1 second between each retry starting with # 4 seconds, then up to 10 seconds, then 10 seconds afterwards try: - import boto3 + import boto3 # noqa except ImportError as e: raise ImportError( "You must install the `boto3` package to use Bedrock." diff --git a/llama_index/node_parser/unstructured_element.py b/llama_index/node_parser/unstructured_element.py index ac826de31..f2b940e97 100644 --- a/llama_index/node_parser/unstructured_element.py +++ b/llama_index/node_parser/unstructured_element.py @@ -121,7 +121,7 @@ def extract_table_summaries( try: response = query_engine.query(summary_query_str) element.table_output = cast(PydanticResponse, response).response - except ValidationError as e: + except ValidationError: # There was a pydantic validation error, so we will run with text completion # fill in the summary and leave other fields blank query_engine = index.as_query_engine() @@ -227,8 +227,8 @@ class UnstructuredElementNodeParser(NodeParser): ) -> None: """Initialize.""" try: - import lxml - import unstructured + import lxml # noqa + import unstructured # noqa except ImportError: raise ImportError( "You must install the `unstructured` and `lxml` package to use this node parser." diff --git a/llama_index/playground/base.py b/llama_index/playground/base.py index 6ee2d3c2f..89fa2259c 100644 --- a/llama_index/playground/base.py +++ b/llama_index/playground/base.py @@ -2,7 +2,7 @@ from __future__ import annotations import time -from typing import Any, Dict, List, Optional, Type, Union +from typing import Any, Dict, List, Type import pandas as pd diff --git a/llama_index/program/predefined/evaporate/extractor.py b/llama_index/program/predefined/evaporate/extractor.py index 38bca8691..bb3c3c15d 100644 --- a/llama_index/program/predefined/evaporate/extractor.py +++ b/llama_index/program/predefined/evaporate/extractor.py @@ -231,7 +231,7 @@ class EvaporateExtractor: with time_limit(1): exec(fn_str, globals()) exec(f"result = get_{function_field}_field(node_text)", globals()) - except TimeoutException as e: + except TimeoutException: raise results.append(result) # type: ignore[name-defined] return results diff --git a/llama_index/program/utils.py b/llama_index/program/utils.py index ff3431110..dc58d9891 100644 --- a/llama_index/program/utils.py +++ b/llama_index/program/utils.py @@ -1,6 +1,5 @@ """Program utils.""" -from enum import Enum from typing import Any, List, Type from llama_index.bridge.pydantic import BaseModel, Field, create_model diff --git a/llama_index/prompts/mixin.py b/llama_index/prompts/mixin.py index 430fa4583..ac60b9ea5 100644 --- a/llama_index/prompts/mixin.py +++ b/llama_index/prompts/mixin.py @@ -3,7 +3,7 @@ from abc import ABC, abstractmethod from collections import defaultdict from copy import deepcopy -from typing import Dict, List, Optional, Tuple, Union +from typing import Dict, Union from llama_index.prompts.base import BasePromptTemplate diff --git a/llama_index/query_engine/__init__.py b/llama_index/query_engine/__init__.py index d5a2ae707..b4d695b40 100644 --- a/llama_index/query_engine/__init__.py +++ b/llama_index/query_engine/__init__.py @@ -57,5 +57,6 @@ __all__ = [ "CustomQueryEngine", # SQL "SQLTableRetrieverQueryEngine", - "NLSQLTableQueryEngine" "PGVectorSQLQueryEngine", + "NLSQLTableQueryEngine", + "PGVectorSQLQueryEngine", ] diff --git a/llama_index/query_engine/flare/answer_inserter.py b/llama_index/query_engine/flare/answer_inserter.py index 8bed81bba..9a2c7893e 100644 --- a/llama_index/query_engine/flare/answer_inserter.py +++ b/llama_index/query_engine/flare/answer_inserter.py @@ -1,6 +1,6 @@ """Answer inserter.""" -from abc import ABC, abstractmethod +from abc import abstractmethod from typing import Any, Dict, List, Optional from llama_index.indices.service_context import ServiceContext diff --git a/llama_index/query_engine/flare/base.py b/llama_index/query_engine/flare/base.py index ba034578b..169ee9f6c 100644 --- a/llama_index/query_engine/flare/base.py +++ b/llama_index/query_engine/flare/base.py @@ -11,7 +11,7 @@ from llama_index.indices.query.base import BaseQueryEngine from llama_index.indices.query.schema import QueryBundle from llama_index.indices.service_context import ServiceContext from llama_index.prompts.base import BasePromptTemplate, PromptTemplate -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType, PromptMixinType from llama_index.query_engine.flare.answer_inserter import ( BaseLookaheadAnswerInserter, LLMLookaheadAnswerInserter, diff --git a/llama_index/query_engine/multistep_query_engine.py b/llama_index/query_engine/multistep_query_engine.py index b4c73067d..f106c8f3a 100644 --- a/llama_index/query_engine/multistep_query_engine.py +++ b/llama_index/query_engine/multistep_query_engine.py @@ -4,7 +4,7 @@ from llama_index.callbacks.schema import CBEventType, EventPayload from llama_index.indices.query.base import BaseQueryEngine from llama_index.indices.query.query_transform.base import StepDecomposeQueryTransform from llama_index.indices.query.schema import QueryBundle -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptMixinType from llama_index.response.schema import RESPONSE_TYPE from llama_index.response_synthesizers import BaseSynthesizer, get_response_synthesizer from llama_index.schema import NodeWithScore, TextNode diff --git a/llama_index/query_engine/pandas_query_engine.py b/llama_index/query_engine/pandas_query_engine.py index 161cf1f33..dd2f2c69e 100644 --- a/llama_index/query_engine/pandas_query_engine.py +++ b/llama_index/query_engine/pandas_query_engine.py @@ -75,7 +75,7 @@ def default_output_processor( pd.reset_option("display.max_colwidth") return output_str - except Exception as e: + except Exception: raise except Exception as e: err_string = ( diff --git a/llama_index/query_engine/retriever_query_engine.py b/llama_index/query_engine/retriever_query_engine.py index cba9dd7ed..3ab4561f2 100644 --- a/llama_index/query_engine/retriever_query_engine.py +++ b/llama_index/query_engine/retriever_query_engine.py @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Sequence, Tuple +from typing import Any, List, Optional, Sequence from llama_index.bridge.pydantic import BaseModel from llama_index.callbacks.base import CallbackManager diff --git a/llama_index/query_engine/sub_question_query_engine.py b/llama_index/query_engine/sub_question_query_engine.py index 20370fb98..ef8adf932 100644 --- a/llama_index/query_engine/sub_question_query_engine.py +++ b/llama_index/query_engine/sub_question_query_engine.py @@ -9,7 +9,7 @@ from llama_index.callbacks.schema import CBEventType, EventPayload from llama_index.indices.query.base import BaseQueryEngine from llama_index.indices.query.schema import QueryBundle from llama_index.indices.service_context import ServiceContext -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptMixinType from llama_index.question_gen.llm_generators import LLMQuestionGenerator from llama_index.question_gen.openai_generator import OpenAIQuestionGenerator from llama_index.question_gen.types import BaseQuestionGenerator, SubQuestion diff --git a/llama_index/query_engine/transform_query_engine.py b/llama_index/query_engine/transform_query_engine.py index 15870e5e8..fffdadf14 100644 --- a/llama_index/query_engine/transform_query_engine.py +++ b/llama_index/query_engine/transform_query_engine.py @@ -4,7 +4,7 @@ from llama_index.callbacks.base import CallbackManager from llama_index.indices.query.base import BaseQueryEngine from llama_index.indices.query.query_transform.base import BaseQueryTransform from llama_index.indices.query.schema import QueryBundle -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptMixinType from llama_index.response.schema import RESPONSE_TYPE from llama_index.schema import NodeWithScore diff --git a/llama_index/question_gen/guidance_generator.py b/llama_index/question_gen/guidance_generator.py index 4f1cc4f67..d78732bd4 100644 --- a/llama_index/question_gen/guidance_generator.py +++ b/llama_index/question_gen/guidance_generator.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING, List, Optional, Sequence, cast from llama_index.indices.query.schema import QueryBundle from llama_index.program.guidance_program import GuidancePydanticProgram from llama_index.prompts.guidance_utils import convert_to_handlebars -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.question_gen.prompts import ( DEFAULT_SUB_QUESTION_PROMPT_TMPL, build_tools_text, diff --git a/llama_index/question_gen/llm_generators.py b/llama_index/question_gen/llm_generators.py index 22cb8bbfb..63a7501ed 100644 --- a/llama_index/question_gen/llm_generators.py +++ b/llama_index/question_gen/llm_generators.py @@ -5,7 +5,7 @@ from llama_index.indices.service_context import ServiceContext from llama_index.llm_predictor.base import BaseLLMPredictor from llama_index.output_parsers.base import StructuredOutput from llama_index.prompts.base import BasePromptTemplate, PromptTemplate -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.prompts.prompt_type import PromptType from llama_index.question_gen.output_parser import SubQuestionOutputParser from llama_index.question_gen.prompts import ( diff --git a/llama_index/question_gen/openai_generator.py b/llama_index/question_gen/openai_generator.py index 6515a9136..3349d1035 100644 --- a/llama_index/question_gen/openai_generator.py +++ b/llama_index/question_gen/openai_generator.py @@ -4,7 +4,7 @@ from llama_index.indices.query.schema import QueryBundle from llama_index.llms.base import LLM from llama_index.llms.openai import OpenAI from llama_index.program.openai_program import OpenAIPydanticProgram -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.question_gen.prompts import build_tools_text from llama_index.question_gen.types import ( BaseQuestionGenerator, diff --git a/llama_index/question_gen/types.py b/llama_index/question_gen/types.py index 608fffafb..0cf3cc7fd 100644 --- a/llama_index/question_gen/types.py +++ b/llama_index/question_gen/types.py @@ -1,4 +1,4 @@ -from abc import ABC, abstractmethod +from abc import abstractmethod from typing import List, Sequence from llama_index.bridge.pydantic import BaseModel diff --git a/llama_index/readers/deeplake.py b/llama_index/readers/deeplake.py index 00c00f43a..54a039712 100644 --- a/llama_index/readers/deeplake.py +++ b/llama_index/readers/deeplake.py @@ -67,7 +67,7 @@ class DeepLakeReader(BaseReader): "`deeplake` package not found, please run `pip install deeplake`" ) try: - import deeplake + import deeplake # noqa except ImportError: raise ImportError(import_err_msg) self.token = token diff --git a/llama_index/readers/discord_reader.py b/llama_index/readers/discord_reader.py index 0b400d2b3..1a9353bd5 100644 --- a/llama_index/readers/discord_reader.py +++ b/llama_index/readers/discord_reader.py @@ -101,7 +101,7 @@ class DiscordReader(BasePydanticReader): def __init__(self, discord_token: Optional[str] = None) -> None: """Initialize with parameters.""" try: - import discord + import discord # noqa except ImportError: raise ImportError( "`discord.py` package not found, please run `pip install discord.py`" diff --git a/llama_index/readers/faiss.py b/llama_index/readers/faiss.py index 3be122c77..79e7ac120 100644 --- a/llama_index/readers/faiss.py +++ b/llama_index/readers/faiss.py @@ -30,7 +30,7 @@ class FaissReader(BaseReader): https://github.com/facebookresearch/faiss/wiki/Installing-Faiss """ try: - import faiss + import faiss # noqa except ImportError: raise ImportError(import_err_msg) diff --git a/llama_index/readers/file/image_caption_reader.py b/llama_index/readers/file/image_caption_reader.py index 7ab94a0b0..ce2f4c814 100644 --- a/llama_index/readers/file/image_caption_reader.py +++ b/llama_index/readers/file/image_caption_reader.py @@ -23,9 +23,9 @@ class ImageCaptionReader(BaseReader): if parser_config is None: """Init parser.""" try: - import sentencepiece + import sentencepiece # noqa import torch - from PIL import Image + from PIL import Image # noqa from transformers import BlipForConditionalGeneration, BlipProcessor except ImportError: raise ImportError( diff --git a/llama_index/readers/file/image_reader.py b/llama_index/readers/file/image_reader.py index e584d87a6..15e4c3d3d 100644 --- a/llama_index/readers/file/image_reader.py +++ b/llama_index/readers/file/image_reader.py @@ -29,9 +29,9 @@ class ImageReader(BaseReader): """Init parser.""" if parser_config is None and parse_text: try: - import sentencepiece - import torch - from PIL import Image + import sentencepiece # noqa + import torch # noqa + from PIL import Image # noqa from transformers import DonutProcessor, VisionEncoderDecoderModel except ImportError: raise ImportError( diff --git a/llama_index/readers/file/image_vision_llm_reader.py b/llama_index/readers/file/image_vision_llm_reader.py index e5e729e53..bb772c5cc 100644 --- a/llama_index/readers/file/image_vision_llm_reader.py +++ b/llama_index/readers/file/image_vision_llm_reader.py @@ -22,9 +22,9 @@ class ImageVisionLLMReader(BaseReader): """Init params.""" if parser_config is None: try: - import sentencepiece + import sentencepiece # noqa import torch - from PIL import Image + from PIL import Image # noqa from transformers import Blip2ForConditionalGeneration, Blip2Processor except ImportError: raise ImportError( diff --git a/llama_index/readers/file/mbox_reader.py b/llama_index/readers/file/mbox_reader.py index dfc84fb50..5e495a51f 100644 --- a/llama_index/readers/file/mbox_reader.py +++ b/llama_index/readers/file/mbox_reader.py @@ -39,7 +39,7 @@ class MboxReader(BaseReader): ) -> None: """Init params.""" try: - from bs4 import BeautifulSoup + from bs4 import BeautifulSoup # noqa except ImportError: raise ImportError( "`beautifulsoup4` package not found: `pip install beautifulsoup4`" diff --git a/llama_index/readers/file/slides_reader.py b/llama_index/readers/file/slides_reader.py index 19849833f..709845bd5 100644 --- a/llama_index/readers/file/slides_reader.py +++ b/llama_index/readers/file/slides_reader.py @@ -23,9 +23,9 @@ class PptxReader(BaseReader): def __init__(self) -> None: """Init parser.""" try: - import torch - from PIL import Image - from pptx import Presentation + import torch # noqa + from PIL import Image # noqa + from pptx import Presentation # noqa from transformers import ( AutoTokenizer, VisionEncoderDecoderModel, diff --git a/llama_index/readers/google_readers/gdocs.py b/llama_index/readers/google_readers/gdocs.py index 502dac0d9..c96daf756 100644 --- a/llama_index/readers/google_readers/gdocs.py +++ b/llama_index/readers/google_readers/gdocs.py @@ -38,9 +38,9 @@ class GoogleDocsReader(BasePydanticReader): def __init__(self) -> None: """Initialize with parameters.""" try: - import google - import google_auth_oauthlib - import googleapiclient + import google # noqa + import google_auth_oauthlib # noqa + import googleapiclient # noqa except ImportError: raise ImportError( "`google_auth_oauthlib`, `googleapiclient` and `google` " diff --git a/llama_index/readers/google_readers/gsheets.py b/llama_index/readers/google_readers/gsheets.py index 74a3f0d4c..a02af79a4 100644 --- a/llama_index/readers/google_readers/gsheets.py +++ b/llama_index/readers/google_readers/gsheets.py @@ -38,9 +38,9 @@ class GoogleSheetsReader(BasePydanticReader): def __init__(self) -> None: """Initialize with parameters.""" try: - import google - import google_auth_oauthlib - import googleapiclient + import google # noqa + import google_auth_oauthlib # noqa + import googleapiclient # noqa except ImportError: raise ImportError( "`google_auth_oauthlib`, `googleapiclient` and `google` " diff --git a/llama_index/readers/metal.py b/llama_index/readers/metal.py index 2e4740d6f..29ea228a6 100644 --- a/llama_index/readers/metal.py +++ b/llama_index/readers/metal.py @@ -18,7 +18,7 @@ class MetalReader(BaseReader): "`metal_sdk` package not found, please run `pip install metal_sdk`" ) try: - import metal_sdk + import metal_sdk # noqa except ImportError: raise ImportError(import_err_msg) from metal_sdk.metal import Metal diff --git a/llama_index/readers/milvus.py b/llama_index/readers/milvus.py index 6b0b982f8..1a0489a05 100644 --- a/llama_index/readers/milvus.py +++ b/llama_index/readers/milvus.py @@ -23,7 +23,7 @@ class MilvusReader(BaseReader): "`pymilvus` package not found, please run `pip install pymilvus`" ) try: - import pymilvus + import pymilvus # noqa except ImportError: raise ImportError(import_err_msg) @@ -50,7 +50,7 @@ class MilvusReader(BaseReader): } try: self._create_connection_alias() - except MilvusException as e: + except MilvusException: raise def load_data( @@ -75,13 +75,13 @@ class MilvusReader(BaseReader): try: self.collection = Collection(collection_name, using=self.alias) - except MilvusException as e: + except MilvusException: raise assert self.collection is not None try: self.collection.load() - except MilvusException as e: + except MilvusException: raise if search_params is None: search_params = self._create_search_params() diff --git a/llama_index/readers/schema/base.py b/llama_index/readers/schema/base.py index 648918bd1..f209eccb3 100644 --- a/llama_index/readers/schema/base.py +++ b/llama_index/readers/schema/base.py @@ -1,2 +1,2 @@ # TODO: remove this file, only keep for backwards compatibility -from llama_index.schema import Document, ImageDocument +from llama_index.schema import Document, ImageDocument # noqa diff --git a/llama_index/readers/steamship/file_reader.py b/llama_index/readers/steamship/file_reader.py index 20688b63a..9eab46731 100644 --- a/llama_index/readers/steamship/file_reader.py +++ b/llama_index/readers/steamship/file_reader.py @@ -21,7 +21,7 @@ class SteamshipFileReader(BaseReader): def __init__(self, api_key: Optional[str] = None) -> None: """Initialize the Reader.""" try: - import steamship + import steamship # noqa self.api_key = api_key except ImportError: diff --git a/llama_index/readers/weaviate/reader.py b/llama_index/readers/weaviate/reader.py index fe3df7615..4b9d46f20 100644 --- a/llama_index/readers/weaviate/reader.py +++ b/llama_index/readers/weaviate/reader.py @@ -26,9 +26,9 @@ class WeaviateReader(BaseReader): ) -> None: """Initialize with parameters.""" try: - import weaviate + import weaviate # noqa from weaviate import Client - from weaviate.auth import AuthCredentials + from weaviate.auth import AuthCredentials # noqa except ImportError: raise ImportError( "`weaviate` package not found, please run `pip install weaviate-client`" diff --git a/llama_index/readers/web.py b/llama_index/readers/web.py index 6bab9db90..da31874f7 100644 --- a/llama_index/readers/web.py +++ b/llama_index/readers/web.py @@ -36,7 +36,7 @@ class SimpleWebPageReader(BasePydanticReader): ) -> None: """Initialize with parameters.""" try: - import html2text + import html2text # noqa except ImportError: raise ImportError( "`html2text` package not found, please run `pip install html2text`" @@ -95,7 +95,7 @@ class TrafilaturaWebReader(BasePydanticReader): error_on_missing (bool): Throw an error when data cannot be parsed """ try: - import trafilatura + import trafilatura # noqa except ImportError: raise ImportError( "`trafilatura` package not found, please run `pip install trafilatura`" @@ -174,10 +174,10 @@ class BeautifulSoupWebReader(BasePydanticReader): ) -> None: """Initialize with parameters.""" try: - from urllib.parse import urlparse + from urllib.parse import urlparse # noqa - import requests - from bs4 import BeautifulSoup + import requests # noqa + from bs4 import BeautifulSoup # noqa except ImportError: raise ImportError( "`bs4`, `requests`, and `urllib` must be installed to scrape websites." @@ -253,7 +253,7 @@ class RssReader(BasePydanticReader): """ try: - import feedparser + import feedparser # noqa except ImportError: raise ImportError( "`feedparser` package not found, please run `pip install feedparser`" @@ -261,7 +261,7 @@ class RssReader(BasePydanticReader): if html_to_text: try: - import html2text + import html2text # noqa except ImportError: raise ImportError( "`html2text` package not found, please run `pip install html2text`" diff --git a/llama_index/readers/wikipedia.py b/llama_index/readers/wikipedia.py index da5eb3c37..0e1e3c21e 100644 --- a/llama_index/readers/wikipedia.py +++ b/llama_index/readers/wikipedia.py @@ -17,7 +17,7 @@ class WikipediaReader(BasePydanticReader): def __init__(self) -> None: """Initialize with parameters.""" try: - import wikipedia + import wikipedia # noqa except ImportError: raise ImportError( "`wikipedia` package not found, please run `pip install wikipedia`" diff --git a/llama_index/response_synthesizers/accumulate.py b/llama_index/response_synthesizers/accumulate.py index 465a499f8..d0a6a1e21 100644 --- a/llama_index/response_synthesizers/accumulate.py +++ b/llama_index/response_synthesizers/accumulate.py @@ -1,11 +1,11 @@ import asyncio -from typing import Any, List, Optional, Sequence, Tuple +from typing import Any, List, Optional, Sequence from llama_index.async_utils import run_async_tasks from llama_index.indices.service_context import ServiceContext from llama_index.prompts import BasePromptTemplate from llama_index.prompts.default_prompts import DEFAULT_TEXT_QA_PROMPT -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.response_synthesizers.base import BaseSynthesizer from llama_index.types import RESPONSE_TEXT_TYPE diff --git a/llama_index/response_synthesizers/base.py b/llama_index/response_synthesizers/base.py index 0fd6c5ba4..4b72edb67 100644 --- a/llama_index/response_synthesizers/base.py +++ b/llama_index/response_synthesizers/base.py @@ -8,15 +8,14 @@ Will support different modes, from 1) stuffing chunks into prompt, """ import logging -from abc import ABC, abstractmethod +from abc import abstractmethod from typing import Any, Dict, Generator, List, Optional, Sequence, Union from llama_index.bridge.pydantic import BaseModel from llama_index.callbacks.schema import CBEventType, EventPayload from llama_index.indices.query.schema import QueryBundle from llama_index.indices.service_context import ServiceContext -from llama_index.prompts.base import BasePromptTemplate -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptMixin from llama_index.response.schema import ( RESPONSE_TYPE, PydanticResponse, diff --git a/llama_index/response_synthesizers/generation.py b/llama_index/response_synthesizers/generation.py index 068fd2603..5ea5f96ae 100644 --- a/llama_index/response_synthesizers/generation.py +++ b/llama_index/response_synthesizers/generation.py @@ -1,9 +1,9 @@ -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Optional, Sequence from llama_index.indices.service_context import ServiceContext from llama_index.prompts import BasePromptTemplate from llama_index.prompts.default_prompts import DEFAULT_SIMPLE_INPUT_PROMPT -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.response_synthesizers.base import BaseSynthesizer from llama_index.types import RESPONSE_TEXT_TYPE diff --git a/llama_index/response_synthesizers/refine.py b/llama_index/response_synthesizers/refine.py index 189344e75..06ab3e051 100644 --- a/llama_index/response_synthesizers/refine.py +++ b/llama_index/response_synthesizers/refine.py @@ -1,5 +1,5 @@ import logging -from typing import Any, Callable, Generator, Optional, Sequence, Tuple, Type, cast +from typing import Any, Callable, Generator, Optional, Sequence, Type, cast from llama_index.bridge.pydantic import BaseModel, Field, ValidationError from llama_index.indices.service_context import ServiceContext @@ -10,7 +10,7 @@ from llama_index.prompts.default_prompt_selectors import ( DEFAULT_REFINE_PROMPT_SEL, DEFAULT_TEXT_QA_PROMPT_SEL, ) -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.response.utils import get_response_text from llama_index.response_synthesizers.base import BaseSynthesizer from llama_index.types import RESPONSE_TEXT_TYPE, BasePydanticProgram diff --git a/llama_index/response_synthesizers/simple_summarize.py b/llama_index/response_synthesizers/simple_summarize.py index 2c7e459d9..8ab4dd1bc 100644 --- a/llama_index/response_synthesizers/simple_summarize.py +++ b/llama_index/response_synthesizers/simple_summarize.py @@ -3,7 +3,7 @@ from typing import Any, Generator, Optional, Sequence, cast from llama_index.indices.service_context import ServiceContext from llama_index.prompts import BasePromptTemplate from llama_index.prompts.default_prompt_selectors import DEFAULT_TEXT_QA_PROMPT_SEL -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.response_synthesizers.base import BaseSynthesizer from llama_index.types import RESPONSE_TEXT_TYPE diff --git a/llama_index/response_synthesizers/tree_summarize.py b/llama_index/response_synthesizers/tree_summarize.py index 93da77cb8..77d9a1590 100644 --- a/llama_index/response_synthesizers/tree_summarize.py +++ b/llama_index/response_synthesizers/tree_summarize.py @@ -1,5 +1,5 @@ import asyncio -from typing import Any, List, Optional, Sequence, Tuple +from typing import Any, List, Optional, Sequence from llama_index.async_utils import run_async_tasks from llama_index.indices.service_context import ServiceContext @@ -7,7 +7,7 @@ from llama_index.prompts import BasePromptTemplate from llama_index.prompts.default_prompt_selectors import ( DEFAULT_TREE_SUMMARIZE_PROMPT_SEL, ) -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.response_synthesizers.base import BaseSynthesizer from llama_index.types import RESPONSE_TEXT_TYPE, BaseModel diff --git a/llama_index/selectors/embedding_selectors.py b/llama_index/selectors/embedding_selectors.py index 1fcc571af..9e18f86d9 100644 --- a/llama_index/selectors/embedding_selectors.py +++ b/llama_index/selectors/embedding_selectors.py @@ -1,18 +1,16 @@ -from typing import Any, Dict, List, Optional, Sequence, cast +from typing import Any, Dict, Optional, Sequence from llama_index.embeddings.base import BaseEmbedding from llama_index.embeddings.utils import resolve_embed_model from llama_index.indices.query.embedding_utils import get_top_k_embeddings from llama_index.indices.query.schema import QueryBundle -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.selectors.types import ( BaseSelector, - MultiSelection, SelectorResult, SingleSelection, ) from llama_index.tools.types import ToolMetadata -from llama_index.types import BaseOutputParser class EmbeddingSingleSelector(BaseSelector): diff --git a/llama_index/selectors/llm_selectors.py b/llama_index/selectors/llm_selectors.py index 6d04f33b1..1a56d0ccb 100644 --- a/llama_index/selectors/llm_selectors.py +++ b/llama_index/selectors/llm_selectors.py @@ -5,7 +5,7 @@ from llama_index.indices.service_context import ServiceContext from llama_index.llm_predictor.base import BaseLLMPredictor from llama_index.output_parsers.base import StructuredOutput from llama_index.output_parsers.selection import Answer, SelectionOutputParser -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.prompts.prompt_type import PromptType from llama_index.selectors.prompts import ( DEFAULT_MULTI_SELECT_PROMPT_TMPL, diff --git a/llama_index/selectors/pydantic_selectors.py b/llama_index/selectors/pydantic_selectors.py index 75f9a73c5..b50224088 100644 --- a/llama_index/selectors/pydantic_selectors.py +++ b/llama_index/selectors/pydantic_selectors.py @@ -3,7 +3,7 @@ from typing import Any, Dict, Optional, Sequence from llama_index.indices.query.schema import QueryBundle from llama_index.llms.openai import OpenAI from llama_index.program.openai_program import OpenAIPydanticProgram -from llama_index.prompts.mixin import PromptDictType, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.selectors.llm_selectors import _build_choices_text from llama_index.selectors.prompts import ( DEFAULT_MULTI_PYD_SELECT_PROMPT_TMPL, diff --git a/llama_index/selectors/types.py b/llama_index/selectors/types.py index 269b066a2..8ccf7f460 100644 --- a/llama_index/selectors/types.py +++ b/llama_index/selectors/types.py @@ -1,9 +1,9 @@ -from abc import ABC, abstractmethod +from abc import abstractmethod from typing import List, Sequence, Union from llama_index.bridge.pydantic import BaseModel from llama_index.indices.query.schema import QueryBundle, QueryType -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptMixin, PromptMixinType from llama_index.tools.types import ToolMetadata MetadataType = Union[str, ToolMetadata] diff --git a/llama_index/storage/docstore/dynamodb_docstore.py b/llama_index/storage/docstore/dynamodb_docstore.py index f83239b2f..38ae0c82c 100644 --- a/llama_index/storage/docstore/dynamodb_docstore.py +++ b/llama_index/storage/docstore/dynamodb_docstore.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import Optional - from llama_index.storage.docstore.keyval_docstore import KVDocumentStore from llama_index.storage.kvstore.dynamodb_kvstore import DynamoDBKVStore diff --git a/llama_index/storage/index_store/dynamodb_index_store.py b/llama_index/storage/index_store/dynamodb_index_store.py index 8f8078a66..494c9ac48 100644 --- a/llama_index/storage/index_store/dynamodb_index_store.py +++ b/llama_index/storage/index_store/dynamodb_index_store.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import Optional - from llama_index.storage.index_store.keyval_index_store import KVIndexStore from llama_index.storage.kvstore.dynamodb_kvstore import DynamoDBKVStore diff --git a/llama_index/storage/kvstore/dynamodb_kvstore.py b/llama_index/storage/kvstore/dynamodb_kvstore.py index 1baa5aa90..d60193f5b 100644 --- a/llama_index/storage/kvstore/dynamodb_kvstore.py +++ b/llama_index/storage/kvstore/dynamodb_kvstore.py @@ -2,7 +2,7 @@ from __future__ import annotations import os from decimal import Decimal -from typing import Any, Dict, List, Optional, Set, Tuple +from typing import Any, Dict, List, Set, Tuple from llama_index.storage.kvstore.types import DEFAULT_COLLECTION, BaseKVStore diff --git a/llama_index/text_splitter/code_splitter.py b/llama_index/text_splitter/code_splitter.py index 54a87341b..cc610cc9e 100644 --- a/llama_index/text_splitter/code_splitter.py +++ b/llama_index/text_splitter/code_splitter.py @@ -94,7 +94,7 @@ class CodeSplitter(TextSplitter): try: parser = tree_sitter_languages.get_parser(self.language) - except Exception as e: + except Exception: print( f"Could not get parser for language {self.language}. Check " "https://github.com/grantjenks/py-tree-sitter-languages#license " diff --git a/llama_index/tools/query_engine.py b/llama_index/tools/query_engine.py index 18654d048..154bea747 100644 --- a/llama_index/tools/query_engine.py +++ b/llama_index/tools/query_engine.py @@ -1,4 +1,4 @@ -from typing import Any, Optional, cast +from typing import Any, Optional from llama_index.indices.query.base import BaseQueryEngine from llama_index.langchain_helpers.agents.tools import IndexToolConfig, LlamaIndexTool diff --git a/llama_index/vector_stores/chroma.py b/llama_index/vector_stores/chroma.py index 5ba2bd878..6db328f43 100644 --- a/llama_index/vector_stores/chroma.py +++ b/llama_index/vector_stores/chroma.py @@ -87,7 +87,7 @@ class ChromaVectorStore(BasePydanticVectorStore): ) -> None: """Init params.""" try: - import chromadb + import chromadb # noqa except ImportError: raise ImportError(import_err_msg) from chromadb.api.models.Collection import Collection diff --git a/llama_index/vector_stores/cogsearch.py b/llama_index/vector_stores/cogsearch.py index 51e99fb32..cf075875c 100644 --- a/llama_index/vector_stores/cogsearch.py +++ b/llama_index/vector_stores/cogsearch.py @@ -287,7 +287,7 @@ class CognitiveSearchVectorStore(VectorStore): ) try: - import azure.search.documents + import azure.search.documents # noqa from azure.search.documents import SearchClient from azure.search.documents.indexes import SearchIndexClient except ImportError: diff --git a/llama_index/vector_stores/docarray/hnsw.py b/llama_index/vector_stores/docarray/hnsw.py index 7bedb55bd..d8d8712f8 100644 --- a/llama_index/vector_stores/docarray/hnsw.py +++ b/llama_index/vector_stores/docarray/hnsw.py @@ -48,7 +48,7 @@ class DocArrayHnswVectorStore(DocArrayVectorStore): `pip install docarray[hnswlib]` """ try: - import docarray + import docarray # noqa except ImportError: raise ImportError(import_err_msg) diff --git a/llama_index/vector_stores/docarray/in_memory.py b/llama_index/vector_stores/docarray/in_memory.py index 7e944fe35..4ca8d379b 100644 --- a/llama_index/vector_stores/docarray/in_memory.py +++ b/llama_index/vector_stores/docarray/in_memory.py @@ -30,7 +30,7 @@ class DocArrayInMemoryVectorStore(DocArrayVectorStore): `pip install docarray` """ try: - import docarray + import docarray # noqa except ImportError: raise ImportError(import_err_msg) diff --git a/llama_index/vector_stores/dynamodb.py b/llama_index/vector_stores/dynamodb.py index bd89f7244..87e6e5c18 100644 --- a/llama_index/vector_stores/dynamodb.py +++ b/llama_index/vector_stores/dynamodb.py @@ -2,7 +2,7 @@ from __future__ import annotations from logging import getLogger -from typing import Any, Dict, List, Optional, cast +from typing import Any, Dict, List, cast from llama_index.indices.query.embedding_utils import ( get_top_k_embeddings, diff --git a/llama_index/vector_stores/elasticsearch.py b/llama_index/vector_stores/elasticsearch.py index cba936152..98e4bf54e 100644 --- a/llama_index/vector_stores/elasticsearch.py +++ b/llama_index/vector_stores/elasticsearch.py @@ -412,7 +412,7 @@ class ElasticsearchStore(VectorStore): logger.warning(f"Could not find text {ref_doc_id} to delete") else: logger.debug(f"Deleted text {ref_doc_id} from index") - except Exception as e: + except Exception: logger.error(f"Error deleting text: {ref_doc_id}") raise diff --git a/llama_index/vector_stores/metal.py b/llama_index/vector_stores/metal.py index bf8dce693..7196ef123 100644 --- a/llama_index/vector_stores/metal.py +++ b/llama_index/vector_stores/metal.py @@ -39,7 +39,7 @@ class MetalVectorStore(VectorStore): "`metal_sdk` package not found, please run `pip install metal_sdk`" ) try: - import metal_sdk + import metal_sdk # noqa except ImportError: raise ImportError(import_err_msg) from metal_sdk.metal import Metal diff --git a/llama_index/vector_stores/milvus.py b/llama_index/vector_stores/milvus.py index 740877afc..d051eb708 100644 --- a/llama_index/vector_stores/milvus.py +++ b/llama_index/vector_stores/milvus.py @@ -99,7 +99,7 @@ class MilvusVectorStore(VectorStore): "`pymilvus` package not found, please run `pip install pymilvus`" ) try: - import pymilvus + import pymilvus # noqa except ImportError: raise ImportError(import_err_msg) diff --git a/llama_index/vector_stores/postgres.py b/llama_index/vector_stores/postgres.py index 3c23946d1..0621d5c24 100644 --- a/llama_index/vector_stores/postgres.py +++ b/llama_index/vector_stores/postgres.py @@ -132,11 +132,11 @@ class PGVectorStore(BasePydanticVectorStore): debug: bool = False, ) -> None: try: - import asyncpg - import pgvector - import psycopg2 + import asyncpg # noqa + import pgvector # noqa + import psycopg2 # noqa import sqlalchemy - import sqlalchemy.ext.asyncio + import sqlalchemy.ext.asyncio # noqa except ImportError: raise ImportError( "`sqlalchemy[asyncio]`, `pgvector`, `psycopg2-binary` and `asyncpg` " @@ -521,8 +521,6 @@ class PGVectorStore(BasePydanticVectorStore): async def aquery( self, query: VectorStoreQuery, **kwargs: Any ) -> VectorStoreQueryResult: - import sqlalchemy - self._initialize() if query.mode == VectorStoreQueryMode.HYBRID: results = await self._async_hybrid_query(query) diff --git a/llama_index/vector_stores/qdrant.py b/llama_index/vector_stores/qdrant.py index 5ee013291..471f61068 100644 --- a/llama_index/vector_stores/qdrant.py +++ b/llama_index/vector_stores/qdrant.py @@ -374,7 +374,7 @@ class QdrantVectorStore(BasePydanticVectorStore): Args: query (VectorStoreQuery): query """ - from qdrant_client.http.models import Filter, Payload + from qdrant_client.http.models import Filter query_embedding = cast(List[float], query.query_embedding) diff --git a/llama_index/vector_stores/rocksetdb.py b/llama_index/vector_stores/rocksetdb.py index c323d64ac..04c05edd1 100644 --- a/llama_index/vector_stores/rocksetdb.py +++ b/llama_index/vector_stores/rocksetdb.py @@ -4,7 +4,7 @@ from enum import Enum from os import getenv from time import sleep from types import ModuleType -from typing import Any, List, Optional, Type, TypeVar +from typing import Any, List, Type, TypeVar from llama_index.schema import BaseNode from llama_index.vector_stores.types import ( diff --git a/llama_index/vector_stores/tair.py b/llama_index/vector_stores/tair.py index 7eb150125..01cbffc52 100644 --- a/llama_index/vector_stores/tair.py +++ b/llama_index/vector_stores/tair.py @@ -89,7 +89,7 @@ class TairVectorStore(VectorStore): """ try: - from tair import Tair, tairvector + from tair import Tair, tairvector # noqa except ImportError: raise ValueError( "Could not import tair-py python package. " diff --git a/llama_index/vector_stores/tencentvectordb.py b/llama_index/vector_stores/tencentvectordb.py index 4b7c1ced0..a42cb72f1 100644 --- a/llama_index/vector_stores/tencentvectordb.py +++ b/llama_index/vector_stores/tencentvectordb.py @@ -8,7 +8,6 @@ from typing import Any, Dict, List, Optional from llama_index.schema import BaseNode, NodeRelationship, RelatedNodeInfo, TextNode from llama_index.vector_stores.types import ( - MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQueryResult, @@ -52,7 +51,7 @@ NOT_SUPPORT_METRIC_TYPE_ERROR = ( def _try_import() -> None: try: - import tcvectordb + import tcvectordb # noqa except ImportError: raise ImportError( "`tcvectordb` package not found, please run `pip install tcvectordb`" diff --git a/llama_index/vector_stores/timescalevector.py b/llama_index/vector_stores/timescalevector.py index ec90fdfc5..7c077afc6 100644 --- a/llama_index/vector_stores/timescalevector.py +++ b/llama_index/vector_stores/timescalevector.py @@ -34,7 +34,7 @@ class TimescaleVectorStore(VectorStore): time_partition_interval: Optional[timedelta] = None, ) -> None: try: - from timescale_vector import client + from timescale_vector import client # noqa except ImportError: raise ImportError("`timescale-vector` package should be pre installed") diff --git a/llama_index/vector_stores/weaviate.py b/llama_index/vector_stores/weaviate.py index 8f43b1641..803b550d6 100644 --- a/llama_index/vector_stores/weaviate.py +++ b/llama_index/vector_stores/weaviate.py @@ -91,7 +91,7 @@ class WeaviateVectorStore(BasePydanticVectorStore): ) -> None: """Initialize params.""" try: - import weaviate + import weaviate # noqa from weaviate import Client except ImportError: raise ImportError(import_err_msg) @@ -136,8 +136,8 @@ class WeaviateVectorStore(BasePydanticVectorStore): ) -> "WeaviateVectorStore": """Create WeaviateVectorStore from config.""" try: - import weaviate - from weaviate import AuthApiKey, Client + import weaviate # noqa + from weaviate import AuthApiKey, Client # noqa except ImportError: raise ImportError(import_err_msg) diff --git a/llama_index/vector_stores/weaviate_utils.py b/llama_index/vector_stores/weaviate_utils.py index ec77f8d0b..5e1d263bf 100644 --- a/llama_index/vector_stores/weaviate_utils.py +++ b/llama_index/vector_stores/weaviate_utils.py @@ -47,7 +47,7 @@ NODE_SCHEMA: List[Dict] = [ def validate_client(client: Any) -> None: """Validate client and import weaviate library.""" try: - import weaviate + import weaviate # noqa from weaviate import Client client = cast(Client, client) diff --git a/pyproject.toml b/pyproject.toml index dffd43a2b..5c72833ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -167,6 +167,7 @@ select = [ "D4", "E7", "EXE004", + "F401", "F504", "F541", "F632", diff --git a/tests/evaluation/test_base.py b/tests/evaluation/test_base.py index 884e1551c..d4ce1d3f8 100644 --- a/tests/evaluation/test_base.py +++ b/tests/evaluation/test_base.py @@ -2,7 +2,7 @@ from typing import Any, Optional, Sequence from llama_index.evaluation import BaseEvaluator from llama_index.evaluation.base import EvaluationResult -from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType +from llama_index.prompts.mixin import PromptDictType from llama_index.response.schema import NodeWithScore, Response from llama_index.schema import TextNode @@ -30,7 +30,7 @@ class MockEvaluator(BaseEvaluator): query: Optional[str] = None, response: Optional[str] = None, contexts: Optional[Sequence[str]] = None, - **kwargs: Any + **kwargs: Any, ) -> EvaluationResult: return EvaluationResult( query=query, diff --git a/tests/finetuning/test_base.py b/tests/finetuning/test_base.py index 2363de3cc..4c494c820 100644 --- a/tests/finetuning/test_base.py +++ b/tests/finetuning/test_base.py @@ -7,22 +7,16 @@ import pytest def test_torch_imports() -> None: """Test that torch is an optional dependency.""" # importing fine-tuning modules should be ok - from llama_index.finetuning import ( - EmbeddingAdapterFinetuneEngine, - OpenAIFinetuneEngine, - SentenceTransformersFinetuneEngine, - ) + from llama_index.finetuning import EmbeddingAdapterFinetuneEngine # noqa + from llama_index.finetuning import OpenAIFinetuneEngine # noqa + from llama_index.finetuning import SentenceTransformersFinetuneEngine # noqa # if torch isn't installed, then these should fail if pkgutil.find_loader("torch") is None: with pytest.raises(ModuleNotFoundError): from llama_index.embeddings.adapter_utils import LinearLayer - from llama_index.finetuning.embeddings.adapter_utils import ( - train_model, - ) + from llama_index.finetuning.embeddings.adapter_utils import train_model else: # else, importing these should be ok - from llama_index.embeddings.adapter_utils import LinearLayer - from llama_index.finetuning.embeddings.adapter_utils import ( - train_model, - ) + from llama_index.embeddings.adapter_utils import LinearLayer # noqa + from llama_index.finetuning.embeddings.adapter_utils import train_model # noqa diff --git a/tests/output_parsers/test_selection.py b/tests/output_parsers/test_selection.py index 748e360e1..7480f3f21 100644 --- a/tests/output_parsers/test_selection.py +++ b/tests/output_parsers/test_selection.py @@ -1,5 +1,3 @@ -import json.decoder - import pytest from llama_index.output_parsers.base import StructuredOutput from llama_index.output_parsers.selection import SelectionOutputParser diff --git a/tests/prompts/test_mixin.py b/tests/prompts/test_mixin.py index 4bc6cfec0..717ae6982 100644 --- a/tests/prompts/test_mixin.py +++ b/tests/prompts/test_mixin.py @@ -1,8 +1,7 @@ """Test prompt mixin.""" -import pytest -from llama_index.prompts.base import BasePromptTemplate, PromptTemplate +from llama_index.prompts.base import PromptTemplate from llama_index.prompts.mixin import PromptDictType, PromptMixin, PromptMixinType diff --git a/tests/vector_stores/test_cassandra.py b/tests/vector_stores/test_cassandra.py index 2a63c1185..23f24b539 100644 --- a/tests/vector_stores/test_cassandra.py +++ b/tests/vector_stores/test_cassandra.py @@ -8,7 +8,7 @@ from llama_index.vector_stores.cassandra import CassandraVectorStore from llama_index.vector_stores.types import VectorStoreQuery, VectorStoreQueryMode try: - import cassio + import cassio # noqa has_cassio = True except ImportError: @@ -20,7 +20,7 @@ class TestCassandraVectorStore(unittest.TestCase): def test_cassandra_create_and_crud(self) -> None: mock_db_session = MagicMock() try: - import cassio + import cassio # noqa except ModuleNotFoundError: # mock `cassio` if not installed mock_cassio = MagicMock() @@ -55,7 +55,7 @@ class TestCassandraVectorStore(unittest.TestCase): def test_cassandra_queries(self) -> None: mock_db_session = MagicMock() try: - import cassio + import cassio # noqa except ModuleNotFoundError: # mock `cassio` if not installed mock_cassio = MagicMock() diff --git a/tests/vector_stores/test_postgres.py b/tests/vector_stores/test_postgres.py index 6bdb0b46d..fcb0cf4f8 100644 --- a/tests/vector_stores/test_postgres.py +++ b/tests/vector_stores/test_postgres.py @@ -33,11 +33,11 @@ TEST_SCHEMA_NAME = "test" TEST_EMBED_DIM = 2 try: - import asyncpg - import pgvector + import asyncpg # noqa + import pgvector # noqa import psycopg2 import sqlalchemy - import sqlalchemy.ext.asyncio + import sqlalchemy.ext.asyncio # noqa # connection check conn__ = psycopg2.connect(**PARAMS) # type: ignore diff --git a/tests/vector_stores/test_tencentvectordb.py b/tests/vector_stores/test_tencentvectordb.py index f004f2768..b28eeb077 100644 --- a/tests/vector_stores/test_tencentvectordb.py +++ b/tests/vector_stores/test_tencentvectordb.py @@ -4,7 +4,7 @@ from typing import List import pytest try: - import tcvectordb + import tcvectordb # noqa: F401 tcvectordb_init = True except ImportError: -- GitLab