diff --git a/libs/colbert/ragstack_colbert/cassandra_database.py b/libs/colbert/ragstack_colbert/cassandra_database.py index e26b116e4..607a0c312 100644 --- a/libs/colbert/ragstack_colbert/cassandra_database.py +++ b/libs/colbert/ragstack_colbert/cassandra_database.py @@ -435,4 +435,3 @@ def close(self) -> None: """ Cleans up any open resources. """ - pass diff --git a/libs/colbert/ragstack_colbert/colbert_retriever.py b/libs/colbert/ragstack_colbert/colbert_retriever.py index 889174f8f..cbf47b7b7 100644 --- a/libs/colbert/ragstack_colbert/colbert_retriever.py +++ b/libs/colbert/ragstack_colbert/colbert_retriever.py @@ -166,7 +166,6 @@ def close(self) -> None: """ Closes any open resources held by the retriever. """ - pass async def _query_relevant_chunks( self, query_embedding: Embedding, top_k: int diff --git a/libs/e2e-tests/e2e_tests/langchain/test_astra.py b/libs/e2e-tests/e2e_tests/langchain/test_astra.py index 0fdc662c0..0d93d1b7b 100644 --- a/libs/e2e-tests/e2e_tests/langchain/test_astra.py +++ b/libs/e2e-tests/e2e_tests/langchain/test_astra.py @@ -81,7 +81,6 @@ def test_wrong_connection_parameters(vectorstore: AstraDBVectorStore): pytest.fail("Should have thrown exception") except ConnectError as e: print("Error:", e) - pass # This is expected to be a valid endpoint, # because we want to test an AUTHENTICATION error diff --git a/libs/e2e-tests/e2e_tests/langchain/test_unstructured.py b/libs/e2e-tests/e2e_tests/langchain/test_unstructured.py index 2db094d6f..27e52a33e 100644 --- a/libs/e2e-tests/e2e_tests/langchain/test_unstructured.py +++ b/libs/e2e-tests/e2e_tests/langchain/test_unstructured.py @@ -1,3 +1,5 @@ +from typing import TYPE_CHECKING + import pytest from langchain.text_splitter import TokenTextSplitter from langchain_community.document_loaders import UnstructuredAPIFileLoader @@ -15,9 +17,9 @@ ) from e2e_tests.langchain.rag_application import BASIC_QA_PROMPT from e2e_tests.test_utils import get_local_resource_path -from e2e_tests.test_utils.vector_store_handler import ( - VectorStoreTestContext, -) + +if TYPE_CHECKING: + from e2e_tests.test_utils.vector_store_handler import VectorStoreTestContext @pytest.mark.parametrize("vector_store", ["cassandra", "astra_db"]) diff --git a/libs/e2e-tests/e2e_tests/llama_index/test_astra.py b/libs/e2e-tests/e2e_tests/llama_index/test_astra.py index bc7dadcd6..81a8dcf31 100644 --- a/libs/e2e-tests/e2e_tests/llama_index/test_astra.py +++ b/libs/e2e-tests/e2e_tests/llama_index/test_astra.py @@ -106,7 +106,6 @@ def test_wrong_connection_parameters(environment: Environment): pytest.fail("Should have thrown exception") except ConnectError as e: print("Error:", e) - pass # This is expected to be a valid endpoint, # because we want to test an AUTHENTICATION error diff --git a/libs/e2e-tests/e2e_tests/llama_index/test_compatibility_rag.py b/libs/e2e-tests/e2e_tests/llama_index/test_compatibility_rag.py index 628796bf5..e80314122 100644 --- a/libs/e2e-tests/e2e_tests/llama_index/test_compatibility_rag.py +++ b/libs/e2e-tests/e2e_tests/llama_index/test_compatibility_rag.py @@ -1,4 +1,5 @@ import logging +from typing import TYPE_CHECKING import pytest from langchain.embeddings import HuggingFaceInferenceAPIEmbeddings @@ -27,9 +28,9 @@ set_current_test_info, ) from e2e_tests.test_utils import get_local_resource_path -from e2e_tests.test_utils.vector_store_handler import ( - VectorStoreTestContext, -) + +if TYPE_CHECKING: + from e2e_tests.test_utils.vector_store_handler import VectorStoreTestContext def _openai_llm(**kwargs) -> OpenAI: diff --git a/libs/e2e-tests/e2e_tests/llama_index/test_llama_parse.py b/libs/e2e-tests/e2e_tests/llama_index/test_llama_parse.py index de7e33e79..2b3abfd9c 100644 --- a/libs/e2e-tests/e2e_tests/llama_index/test_llama_parse.py +++ b/libs/e2e-tests/e2e_tests/llama_index/test_llama_parse.py @@ -6,6 +6,8 @@ pytest.skip("llama_parse is not supported, skipping tests", allow_module_level=True) +from typing import TYPE_CHECKING + from llama_index.core import ServiceContext, StorageContext, VectorStoreIndex from llama_index.embeddings.openai import OpenAIEmbedding from llama_index.llms.openai import OpenAI @@ -15,9 +17,9 @@ set_current_test_info, ) from e2e_tests.test_utils import get_local_resource_path -from e2e_tests.test_utils.vector_store_handler import ( - VectorStoreTestContext, -) + +if TYPE_CHECKING: + from e2e_tests.test_utils.vector_store_handler import VectorStoreTestContext @pytest.fixture diff --git a/libs/knowledge-store/ragstack_knowledge_store/graph_store.py b/libs/knowledge-store/ragstack_knowledge_store/graph_store.py index f3ee83908..c54e41158 100644 --- a/libs/knowledge-store/ragstack_knowledge_store/graph_store.py +++ b/libs/knowledge-store/ragstack_knowledge_store/graph_store.py @@ -416,7 +416,7 @@ def mmr_traversal_search( # Select the best item, K times. depths = {id: 0 for id in helper.candidate_ids()} visited_tags = set() - for _ in range(0, k): + for _ in range(k): selected_id = helper.pop_best() if selected_id is None: diff --git a/libs/langchain/ragstack_langchain/colbert/colbert_retriever.py b/libs/langchain/ragstack_langchain/colbert/colbert_retriever.py index 156568377..53d8d7b7b 100644 --- a/libs/langchain/ragstack_langchain/colbert/colbert_retriever.py +++ b/libs/langchain/ragstack_langchain/colbert/colbert_retriever.py @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Tuple +from typing import TYPE_CHECKING, Any, List, Optional, Tuple from langchain_core.callbacks.manager import ( AsyncCallbackManagerForRetrieverRun, @@ -6,9 +6,11 @@ ) from langchain_core.documents import Document from langchain_core.retrievers import BaseRetriever -from ragstack_colbert import Chunk from ragstack_colbert.base_retriever import BaseRetriever as ColbertBaseRetriever +if TYPE_CHECKING: + from ragstack_colbert import Chunk + class ColbertRetriever(BaseRetriever): """Chain for langchain retrieve using ColBERT vector store. diff --git a/libs/langchain/ragstack_langchain/graph_store/base.py b/libs/langchain/ragstack_langchain/graph_store/base.py index 4a3248b36..08dca322b 100644 --- a/libs/langchain/ragstack_langchain/graph_store/base.py +++ b/libs/langchain/ragstack_langchain/graph_store/base.py @@ -2,6 +2,7 @@ from abc import abstractmethod from typing import ( + TYPE_CHECKING, Any, AsyncIterable, ClassVar, @@ -13,10 +14,6 @@ Set, ) -from langchain_core.callbacks import ( - AsyncCallbackManagerForRetrieverRun, - CallbackManagerForRetrieverRun, -) from langchain_core.documents import Document from langchain_core.load import Serializable from langchain_core.pydantic_v1 import Field @@ -25,6 +22,12 @@ from ragstack_langchain.graph_store.links import METADATA_LINKS_KEY, Link +if TYPE_CHECKING: + from langchain_core.callbacks import ( + AsyncCallbackManagerForRetrieverRun, + CallbackManagerForRetrieverRun, + ) + def _has_next(iterator: Iterator) -> bool: """Checks if the iterator has more elements. diff --git a/libs/langchain/ragstack_langchain/graph_store/extractors/link_extractor.py b/libs/langchain/ragstack_langchain/graph_store/extractors/link_extractor.py index d5158dd6c..c875f613c 100644 --- a/libs/langchain/ragstack_langchain/graph_store/extractors/link_extractor.py +++ b/libs/langchain/ragstack_langchain/graph_store/extractors/link_extractor.py @@ -1,9 +1,10 @@ from __future__ import annotations from abc import ABC, abstractmethod -from typing import Generic, Iterable, Set, TypeVar +from typing import TYPE_CHECKING, Generic, Iterable, Set, TypeVar -from ragstack_langchain.graph_store.links import Link +if TYPE_CHECKING: + from ragstack_langchain.graph_store.links import Link InputT = TypeVar("InputT") diff --git a/libs/llamaindex/ragstack_llamaindex/colbert/colbert_retriever.py b/libs/llamaindex/ragstack_llamaindex/colbert/colbert_retriever.py index 26c1b4372..799711ee4 100644 --- a/libs/llamaindex/ragstack_llamaindex/colbert/colbert_retriever.py +++ b/libs/llamaindex/ragstack_llamaindex/colbert/colbert_retriever.py @@ -1,12 +1,14 @@ -from typing import Any, List, Optional, Tuple +from typing import TYPE_CHECKING, Any, List, Optional, Tuple from llama_index.core.callbacks.base import CallbackManager from llama_index.core.constants import DEFAULT_SIMILARITY_TOP_K from llama_index.core.retrievers import BaseRetriever from llama_index.core.schema import NodeWithScore, QueryBundle, TextNode -from ragstack_colbert import Chunk from ragstack_colbert.base_retriever import BaseRetriever as ColbertBaseRetriever +if TYPE_CHECKING: + from ragstack_colbert import Chunk + class ColbertRetriever(BaseRetriever): """ColBERT vector store retriever. diff --git a/libs/ragulate/ragstack_ragulate/analysis.py b/libs/ragulate/ragstack_ragulate/analysis.py index b8765b2d9..ff841ab02 100644 --- a/libs/ragulate/ragstack_ragulate/analysis.py +++ b/libs/ragulate/ragstack_ragulate/analysis.py @@ -252,4 +252,4 @@ def compare(self, recipes: List[str], output: str): elif output == "histogram-grid": self.output_histograms_by_dataset(df=df, metrics=metrics) else: - raise ValueError() + raise ValueError diff --git a/libs/ragulate/ragstack_ragulate/pipelines/base_pipeline.py b/libs/ragulate/ragstack_ragulate/pipelines/base_pipeline.py index c5ac11892..bf4941b31 100644 --- a/libs/ragulate/ragstack_ragulate/pipelines/base_pipeline.py +++ b/libs/ragulate/ragstack_ragulate/pipelines/base_pipeline.py @@ -59,7 +59,6 @@ class BasePipeline(ABC): @abstractmethod def pipeline_type(self): """type of pipeline (ingest, query, cleanup)""" - pass @property @abstractmethod diff --git a/pyproject.toml b/pyproject.toml index 6933bb2d5..eb758fcba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,6 +59,9 @@ extend-include = ["*.ipynb"] [tool.ruff.lint] ignore = [ + "COM812", # Messes with the formatter + "ERA", # Do we want to activate (no commented code) ? + "ISC001", # Messes with the formatter "PERF203", # Incorrect detection "TRY003", # A bit too strict ? ] @@ -67,20 +70,34 @@ select = [ "ASYNC", "B", "C4", + "COM", + "DTZ", "E", + "EXE", "F", "FLY", "FURB", "I", + "ICN", + "INT", + "ISC", + "LOG", "N", "NPY", "PERF", + "PIE", "PGH", + "Q", + "RSE", "RUF", "SIM", + "SLOT", + "T10", + "TCH", "TRY", "UP", "W", + "YTT", ] [tool.ruff.lint.per-file-ignores] diff --git a/scripts/ci-common-env.sh b/scripts/ci-common-env.sh old mode 100644 new mode 100755 diff --git a/scripts/format-example-notebooks.py b/scripts/format-example-notebooks.py index 01808c345..f1bb5f1ec 100755 --- a/scripts/format-example-notebooks.py +++ b/scripts/format-example-notebooks.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import json import os diff --git a/scripts/generate-changelog.py b/scripts/generate-changelog.py index ddb9db58a..8ee104c4f 100755 --- a/scripts/generate-changelog.py +++ b/scripts/generate-changelog.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + try: import requests except ImportError: diff --git a/scripts/generate-testspace-report.py b/scripts/generate-testspace-report.py old mode 100644 new mode 100755 index 27689d75d..427feb493 --- a/scripts/generate-testspace-report.py +++ b/scripts/generate-testspace-report.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import json import os.path import sys diff --git a/scripts/parse-snyk-report.py b/scripts/parse-snyk-report.py old mode 100644 new mode 100755 index 112ce8b7c..dc807426e --- a/scripts/parse-snyk-report.py +++ b/scripts/parse-snyk-report.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import json import sys