From e60f8a686419878d70c76d99b05d69c3ad89306f Mon Sep 17 00:00:00 2001 From: Julian Risch Date: Thu, 19 Mar 2026 17:43:37 +0100 Subject: [PATCH 1/2] chore: add ANN type annotations to stackit, togetherai, unstructured, valkey, watsonx, weave, weaviate Co-Authored-By: Claude Sonnet 4.6 --- integrations/stackit/pyproject.toml | 4 +++- .../components/embedders/stackit/document_embedder.py | 2 +- .../components/embedders/stackit/text_embedder.py | 2 +- .../components/generators/stackit/chat/chat_generator.py | 2 +- integrations/togetherai/pyproject.toml | 5 ++++- .../components/generators/togetherai/chat/chat_generator.py | 2 +- .../components/generators/togetherai/generator.py | 2 +- integrations/unstructured/pyproject.toml | 4 +++- .../components/converters/unstructured/converter.py | 2 +- integrations/valkey/pyproject.toml | 6 ++++-- .../components/retrievers/valkey/embedding_retriever.py | 2 +- .../document_stores/valkey/document_store.py | 2 +- integrations/watsonx/pyproject.toml | 5 ++++- .../components/embedders/watsonx/document_embedder.py | 2 +- .../components/embedders/watsonx/text_embedder.py | 2 +- integrations/weave/pyproject.toml | 5 ++++- integrations/weaviate/pyproject.toml | 4 +++- .../components/retrievers/weaviate/bm25_retriever.py | 2 +- .../components/retrievers/weaviate/embedding_retriever.py | 2 +- .../components/retrievers/weaviate/hybrid_retriever.py | 2 +- .../haystack_integrations/document_stores/weaviate/auth.py | 6 ++++-- .../document_stores/weaviate/document_store.py | 6 +++--- 22 files changed, 45 insertions(+), 26 deletions(-) diff --git a/integrations/stackit/pyproject.toml b/integrations/stackit/pyproject.toml index 523130a1d2..161d3e8ac1 100644 --- a/integrations/stackit/pyproject.toml +++ b/integrations/stackit/pyproject.toml @@ -79,6 +79,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -105,6 +106,7 @@ select = [ ] ignore = [ # Allow non-abstract empty methods in abstract base classes + "ANN401", "B027", # Ignore checks for possible passwords "S105", @@ -129,7 +131,7 @@ ban-relative-imports = "parents" [tool.ruff.lint.per-file-ignores] # Tests can use magic values, assertions, and relative imports -"tests/**/*" = ["PLR2004", "S101", "TID252"] +"tests/**/*" = ["ANN", "PLR2004", "S101", "TID252"] [tool.coverage.run] source = ["haystack_integrations"] diff --git a/integrations/stackit/src/haystack_integrations/components/embedders/stackit/document_embedder.py b/integrations/stackit/src/haystack_integrations/components/embedders/stackit/document_embedder.py index 9c7a012b4a..18fc4c45f8 100644 --- a/integrations/stackit/src/haystack_integrations/components/embedders/stackit/document_embedder.py +++ b/integrations/stackit/src/haystack_integrations/components/embedders/stackit/document_embedder.py @@ -53,7 +53,7 @@ def __init__( timeout: float | None = None, max_retries: int | None = None, http_client_kwargs: dict[str, Any] | None = None, - ): + ) -> None: """ Creates a STACKITDocumentEmbedder component. diff --git a/integrations/stackit/src/haystack_integrations/components/embedders/stackit/text_embedder.py b/integrations/stackit/src/haystack_integrations/components/embedders/stackit/text_embedder.py index 578c20f5f8..39e0cd2286 100644 --- a/integrations/stackit/src/haystack_integrations/components/embedders/stackit/text_embedder.py +++ b/integrations/stackit/src/haystack_integrations/components/embedders/stackit/text_embedder.py @@ -42,7 +42,7 @@ def __init__( timeout: float | None = None, max_retries: int | None = None, http_client_kwargs: dict[str, Any] | None = None, - ): + ) -> None: """ Creates a STACKITTextEmbedder component. diff --git a/integrations/stackit/src/haystack_integrations/components/generators/stackit/chat/chat_generator.py b/integrations/stackit/src/haystack_integrations/components/generators/stackit/chat/chat_generator.py index d062e8fd06..57d53f2279 100644 --- a/integrations/stackit/src/haystack_integrations/components/generators/stackit/chat/chat_generator.py +++ b/integrations/stackit/src/haystack_integrations/components/generators/stackit/chat/chat_generator.py @@ -62,7 +62,7 @@ def __init__( timeout: float | None = None, max_retries: int | None = None, http_client_kwargs: dict[str, Any] | None = None, - ): + ) -> None: """ Creates an instance of STACKITChatGenerator class. diff --git a/integrations/togetherai/pyproject.toml b/integrations/togetherai/pyproject.toml index c1fc6a3ec9..588d5846aa 100644 --- a/integrations/togetherai/pyproject.toml +++ b/integrations/togetherai/pyproject.toml @@ -86,6 +86,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -112,6 +113,7 @@ select = [ ] ignore = [ # Allow non-abstract empty methods in abstract base classes + "ANN401", "B027", # Ignore checks for possible passwords "S105", @@ -133,7 +135,8 @@ ban-relative-imports = "parents" [tool.ruff.lint.per-file-ignores] # Tests can use magic values, assertions, and relative imports -"tests/**/*" = ["PLR2004", "S101", "TID252"] +"examples/**/*" = ["ANN"] +"tests/**/*" = ["ANN", "PLR2004", "S101", "TID252"] # Examples can print their output "examples/**" = ["T201"] diff --git a/integrations/togetherai/src/haystack_integrations/components/generators/togetherai/chat/chat_generator.py b/integrations/togetherai/src/haystack_integrations/components/generators/togetherai/chat/chat_generator.py index 7c8675d29b..14da13c2ff 100644 --- a/integrations/togetherai/src/haystack_integrations/components/generators/togetherai/chat/chat_generator.py +++ b/integrations/togetherai/src/haystack_integrations/components/generators/togetherai/chat/chat_generator.py @@ -70,7 +70,7 @@ def __init__( timeout: float | None = None, max_retries: int | None = None, http_client_kwargs: dict[str, Any] | None = None, - ): + ) -> None: """ Creates an instance of TogetherAIChatGenerator. Unless specified otherwise, the default model is `meta-llama/Llama-3.3-70B-Instruct-Turbo`. diff --git a/integrations/togetherai/src/haystack_integrations/components/generators/togetherai/generator.py b/integrations/togetherai/src/haystack_integrations/components/generators/togetherai/generator.py index fa286b907a..c0935e604d 100644 --- a/integrations/togetherai/src/haystack_integrations/components/generators/togetherai/generator.py +++ b/integrations/togetherai/src/haystack_integrations/components/generators/togetherai/generator.py @@ -41,7 +41,7 @@ def __init__( generation_kwargs: dict[str, Any] | None = None, timeout: float | None = None, max_retries: int | None = None, - ): + ) -> None: """ Initialize the TogetherAIGenerator. diff --git a/integrations/unstructured/pyproject.toml b/integrations/unstructured/pyproject.toml index 66794ede3b..bb9de26a76 100644 --- a/integrations/unstructured/pyproject.toml +++ b/integrations/unstructured/pyproject.toml @@ -86,6 +86,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -113,6 +114,7 @@ select = [ ] ignore = [ # Allow non-abstract empty methods in abstract base classes + "ANN401", "B027", # Allow boolean positional values in function calls, like `dict.get(... True)` "FBT003", @@ -136,7 +138,7 @@ ban-relative-imports = "parents" [tool.ruff.lint.per-file-ignores] # Tests can use magic values, assertions, and relative imports -"tests/**/*" = ["PLR2004", "S101", "TID252"] +"tests/**/*" = ["ANN", "PLR2004", "S101", "TID252"] [tool.coverage.run] source = ["haystack_integrations"] diff --git a/integrations/unstructured/src/haystack_integrations/components/converters/unstructured/converter.py b/integrations/unstructured/src/haystack_integrations/components/converters/unstructured/converter.py index 1f46298cd8..2fadd8406c 100644 --- a/integrations/unstructured/src/haystack_integrations/components/converters/unstructured/converter.py +++ b/integrations/unstructured/src/haystack_integrations/components/converters/unstructured/converter.py @@ -54,7 +54,7 @@ def __init__( separator: str = "\n\n", unstructured_kwargs: dict[str, Any] | None = None, progress_bar: bool = True, # noqa: FBT001, FBT002 - ): + ) -> None: """ :param api_url: URL of the Unstructured API. Defaults to the URL of the hosted version. If you run the API locally, specify the URL of your local API (e.g. `"http://localhost:8000/general/v0/general"`). diff --git a/integrations/valkey/pyproject.toml b/integrations/valkey/pyproject.toml index 257feee878..1de63fc5f6 100644 --- a/integrations/valkey/pyproject.toml +++ b/integrations/valkey/pyproject.toml @@ -84,6 +84,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -111,6 +112,7 @@ select = [ ] ignore = [ # Allow non-abstract empty methods in abstract base classes + "ANN401", "B027", # Allow boolean positional values in function calls, like `dict.get(... True)` "FBT003", @@ -143,8 +145,8 @@ ban-relative-imports = "parents" [tool.ruff.lint.per-file-ignores] # Tests can use magic values, assertions, and relative imports -"tests/**/*" = ["PLR2004", "S101", "TID252"] -"examples/**/*" = ["T201"] +"examples/**/*" = ["ANN", "T201"] +"tests/**/*" = ["ANN", "PLR2004", "S101", "TID252"] [tool.coverage.run] source = ["haystack_integrations"] diff --git a/integrations/valkey/src/haystack_integrations/components/retrievers/valkey/embedding_retriever.py b/integrations/valkey/src/haystack_integrations/components/retrievers/valkey/embedding_retriever.py index 0bca18f8d4..5461c82ed9 100644 --- a/integrations/valkey/src/haystack_integrations/components/retrievers/valkey/embedding_retriever.py +++ b/integrations/valkey/src/haystack_integrations/components/retrievers/valkey/embedding_retriever.py @@ -66,7 +66,7 @@ def __init__( filters: dict[str, Any] | None = None, top_k: int = 10, filter_policy: str | FilterPolicy = FilterPolicy.REPLACE, - ): + ) -> None: """ :param document_store: The Valkey Document Store. :param filters: Filters applied to the retrieved Documents. diff --git a/integrations/valkey/src/haystack_integrations/document_stores/valkey/document_store.py b/integrations/valkey/src/haystack_integrations/document_stores/valkey/document_store.py index 1caad0353c..46fb642076 100644 --- a/integrations/valkey/src/haystack_integrations/document_stores/valkey/document_store.py +++ b/integrations/valkey/src/haystack_integrations/document_stores/valkey/document_store.py @@ -159,7 +159,7 @@ def __init__( distance_metric: Literal["l2", "cosine", "ip"] = "cosine", embedding_dim: int = 768, metadata_fields: dict[str, type[str] | type[int]] | None = None, - ): + ) -> None: """ Creates a new ValkeyDocumentStore instance. diff --git a/integrations/watsonx/pyproject.toml b/integrations/watsonx/pyproject.toml index a0771eeb8f..618624ef9a 100644 --- a/integrations/watsonx/pyproject.toml +++ b/integrations/watsonx/pyproject.toml @@ -89,6 +89,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -116,6 +117,7 @@ select = [ ignore = [ "T201", # print statements # Allow non-abstract empty methods in abstract base classes + "ANN401", "B027", # Ignore checks for possible passwords "S105", @@ -145,7 +147,8 @@ ban-relative-imports = "parents" [tool.ruff.lint.per-file-ignores] # Tests can use magic values, assertions, and relative imports -"tests/**/*" = ["PLR2004", "S101", "TID252"] +"examples/**/*" = ["ANN"] +"tests/**/*" = ["ANN", "PLR2004", "S101", "TID252"] [tool.coverage.run] source = ["haystack_integrations"] diff --git a/integrations/watsonx/src/haystack_integrations/components/embedders/watsonx/document_embedder.py b/integrations/watsonx/src/haystack_integrations/components/embedders/watsonx/document_embedder.py index 626cea26ed..9274dbf15f 100644 --- a/integrations/watsonx/src/haystack_integrations/components/embedders/watsonx/document_embedder.py +++ b/integrations/watsonx/src/haystack_integrations/components/embedders/watsonx/document_embedder.py @@ -59,7 +59,7 @@ def __init__( max_retries: int | None = None, meta_fields_to_embed: list[str] | None = None, embedding_separator: str = "\n", - ): + ) -> None: """ Creates a WatsonxDocumentEmbedder component. diff --git a/integrations/watsonx/src/haystack_integrations/components/embedders/watsonx/text_embedder.py b/integrations/watsonx/src/haystack_integrations/components/embedders/watsonx/text_embedder.py index 2477337509..225f4b1395 100644 --- a/integrations/watsonx/src/haystack_integrations/components/embedders/watsonx/text_embedder.py +++ b/integrations/watsonx/src/haystack_integrations/components/embedders/watsonx/text_embedder.py @@ -51,7 +51,7 @@ def __init__( suffix: str = "", timeout: float | None = None, max_retries: int | None = None, - ): + ) -> None: """ Creates an WatsonxTextEmbedder component. diff --git a/integrations/weave/pyproject.toml b/integrations/weave/pyproject.toml index 2582cc18d6..94947de0ca 100644 --- a/integrations/weave/pyproject.toml +++ b/integrations/weave/pyproject.toml @@ -78,6 +78,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -105,6 +106,7 @@ select = [ ] ignore = [ # Allow non-abstract empty methods in abstract base classes + "ANN401", "B027", # Allow boolean positional values in function calls, like `dict.get(... True)` "FBT003", @@ -128,7 +130,8 @@ ban-relative-imports = "parents" [tool.ruff.lint.per-file-ignores] # Tests can use magic values, assertions, and relative imports -"tests/**/*" = ["PLR2004", "S101", "TID252"] +"example/**/*" = ["ANN"] +"tests/**/*" = ["ANN", "PLR2004", "S101", "TID252"] [tool.coverage.run] source = ["haystack_integrations"] diff --git a/integrations/weaviate/pyproject.toml b/integrations/weaviate/pyproject.toml index 56085abdec..73b97ec4f0 100644 --- a/integrations/weaviate/pyproject.toml +++ b/integrations/weaviate/pyproject.toml @@ -85,6 +85,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -112,6 +113,7 @@ select = [ ] ignore = [ # Allow non-abstract empty methods in abstract base classes + "ANN401", "B027", # Allow boolean positional values in function calls, like `dict.get(... True)` "FBT003", @@ -135,7 +137,7 @@ ban-relative-imports = "parents" [tool.ruff.lint.per-file-ignores] # Tests can use magic values, assertions, and relative imports -"tests/**/*" = ["PLR2004", "S101", "TID252"] +"tests/**/*" = ["ANN", "PLR2004", "S101", "TID252"] [tool.coverage.run] source = ["haystack_integrations"] diff --git a/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/bm25_retriever.py b/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/bm25_retriever.py index 41b535c528..576cb7c8a4 100644 --- a/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/bm25_retriever.py +++ b/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/bm25_retriever.py @@ -38,7 +38,7 @@ def __init__( filters: dict[str, Any] | None = None, top_k: int = 10, filter_policy: str | FilterPolicy = FilterPolicy.REPLACE, - ): + ) -> None: """ Create a new instance of WeaviateBM25Retriever. diff --git a/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/embedding_retriever.py b/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/embedding_retriever.py index c8c82aeb09..d6640a9449 100644 --- a/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/embedding_retriever.py +++ b/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/embedding_retriever.py @@ -26,7 +26,7 @@ def __init__( distance: float | None = None, certainty: float | None = None, filter_policy: str | FilterPolicy = FilterPolicy.REPLACE, - ): + ) -> None: """ Creates a new instance of WeaviateEmbeddingRetriever. diff --git a/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/hybrid_retriever.py b/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/hybrid_retriever.py index 93c1e849a1..20769fba43 100644 --- a/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/hybrid_retriever.py +++ b/integrations/weaviate/src/haystack_integrations/components/retrievers/weaviate/hybrid_retriever.py @@ -26,7 +26,7 @@ def __init__( alpha: float = 0.7, max_vector_distance: float | None = None, filter_policy: str | FilterPolicy = FilterPolicy.REPLACE, - ): + ) -> None: """ Creates a new instance of WeaviateHybridRetriever. diff --git a/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/auth.py b/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/auth.py index 20880a8c01..356fcc2115 100644 --- a/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/auth.py +++ b/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/auth.py @@ -26,7 +26,7 @@ class SupportedAuthTypes(Enum): CLIENT_CREDENTIALS = "client_credentials" CLIENT_PASSWORD = "client_password" - def __str__(self): + def __str__(self) -> str: return self.value @staticmethod @@ -87,7 +87,9 @@ def _from_dict(cls, data: dict[str, Any]) -> "AuthCredentials": """ @abstractmethod - def resolve_value(self): + def resolve_value( + self, + ) -> WeaviateAuthApiKey | WeaviateAuthBearerToken | WeaviateAuthClientCredentials | WeaviateAuthClientPassword: """ Resolves all the secrets in the auth credentials object and returns the corresponding Weaviate object. All subclasses must implement this method. diff --git a/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/document_store.py b/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/document_store.py index 9a740e3d66..c116b270ad 100644 --- a/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/document_store.py +++ b/integrations/weaviate/src/haystack_integrations/document_stores/weaviate/document_store.py @@ -173,7 +173,7 @@ def __init__( } self._clean_connection_settings() - def _clean_connection_settings(self): + def _clean_connection_settings(self) -> None: # Set the class if not set _class_name = self._collection_settings.get("class", "Default") _class_name = _class_name[0].upper() + _class_name[1:] @@ -184,7 +184,7 @@ def _clean_connection_settings(self): ) @property - def client(self): + def client(self) -> weaviate.WeaviateClient: if self._client: return self._client @@ -228,7 +228,7 @@ def client(self): return self._client @property - async def async_client(self): + async def async_client(self) -> weaviate.WeaviateAsyncClient: if self._async_client: return self._async_client From b384a59277d3b0162f7c55763c411b21b0d82f80 Mon Sep 17 00:00:00 2001 From: Julian Risch Date: Thu, 19 Mar 2026 19:20:02 +0100 Subject: [PATCH 2/2] chore: add opening sentence to __init__ docstrings in unstructured and valkey Co-Authored-By: Claude Sonnet 4.6 --- .../components/converters/unstructured/converter.py | 2 ++ .../components/retrievers/valkey/embedding_retriever.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/integrations/unstructured/src/haystack_integrations/components/converters/unstructured/converter.py b/integrations/unstructured/src/haystack_integrations/components/converters/unstructured/converter.py index 2fadd8406c..d1b1e16f9b 100644 --- a/integrations/unstructured/src/haystack_integrations/components/converters/unstructured/converter.py +++ b/integrations/unstructured/src/haystack_integrations/components/converters/unstructured/converter.py @@ -56,6 +56,8 @@ def __init__( progress_bar: bool = True, # noqa: FBT001, FBT002 ) -> None: """ + Create an `UnstructuredFileConverter` instance. + :param api_url: URL of the Unstructured API. Defaults to the URL of the hosted version. If you run the API locally, specify the URL of your local API (e.g. `"http://localhost:8000/general/v0/general"`). :param api_key: API key for the Unstructured API. diff --git a/integrations/valkey/src/haystack_integrations/components/retrievers/valkey/embedding_retriever.py b/integrations/valkey/src/haystack_integrations/components/retrievers/valkey/embedding_retriever.py index 5461c82ed9..1399514082 100644 --- a/integrations/valkey/src/haystack_integrations/components/retrievers/valkey/embedding_retriever.py +++ b/integrations/valkey/src/haystack_integrations/components/retrievers/valkey/embedding_retriever.py @@ -68,6 +68,8 @@ def __init__( filter_policy: str | FilterPolicy = FilterPolicy.REPLACE, ) -> None: """ + Create a `ValkeyEmbeddingRetriever` instance. + :param document_store: The Valkey Document Store. :param filters: Filters applied to the retrieved Documents. :param top_k: Maximum number of Documents to return.