From 7bc10323cf17403ff25a651c111110930630b7dc Mon Sep 17 00:00:00 2001 From: Julian Risch Date: Tue, 17 Mar 2026 20:13:48 +0100 Subject: [PATCH 1/2] chore: add missing -> None return type annotations to chroma __init__ methods Add the missing `-> None` return type annotation to `__init__` in ChromaDocumentStore, ChromaQueryTextRetriever, and ChromaEmbeddingRetriever. Co-Authored-By: Claude Sonnet 4.6 --- .../components/retrievers/chroma/retriever.py | 4 ++-- .../document_stores/chroma/document_store.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/retriever.py b/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/retriever.py index 430f324a25..ea822b93f1 100644 --- a/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/retriever.py +++ b/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/retriever.py @@ -51,7 +51,7 @@ def __init__( filters: dict[str, Any] | None = None, top_k: int = 10, filter_policy: str | FilterPolicy = FilterPolicy.REPLACE, - ): + ) -> None: """ :param document_store: an instance of `ChromaDocumentStore`. :param filters: filters to narrow down the search space. @@ -164,7 +164,7 @@ def __init__( filters: dict[str, Any] | None = None, top_k: int = 10, filter_policy: str | FilterPolicy = FilterPolicy.REPLACE, - ): + ) -> None: """ :param document_store: an instance of `ChromaDocumentStore`. :param filters: filters to narrow down the search space. diff --git a/integrations/chroma/src/haystack_integrations/document_stores/chroma/document_store.py b/integrations/chroma/src/haystack_integrations/document_stores/chroma/document_store.py index 63caae0292..0fef40cdef 100644 --- a/integrations/chroma/src/haystack_integrations/document_stores/chroma/document_store.py +++ b/integrations/chroma/src/haystack_integrations/document_stores/chroma/document_store.py @@ -45,7 +45,7 @@ def __init__( metadata: dict | None = None, client_settings: dict[str, Any] | None = None, **embedding_function_params: Any, - ): + ) -> None: """ Creates a new ChromaDocumentStore instance. It is meant to be connected to a Chroma collection. From e3b1e022c88652d619eff1765789bfe2a95eb9cc Mon Sep 17 00:00:00 2001 From: Julian Risch Date: Tue, 17 Mar 2026 21:06:46 +0100 Subject: [PATCH 2/2] chore: enable ANN ruff ruleset for chroma integration Co-Authored-By: Claude Sonnet 4.6 --- integrations/chroma/pyproject.toml | 5 ++++- .../document_stores/chroma/document_store.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/integrations/chroma/pyproject.toml b/integrations/chroma/pyproject.toml index e6d1fbe562..b027eb4547 100644 --- a/integrations/chroma/pyproject.toml +++ b/integrations/chroma/pyproject.toml @@ -83,6 +83,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -111,6 +112,8 @@ select = [ ignore = [ # Allow non-abstract empty methods in abstract base classes "B027", + # Allow `Any` - used legitimately for **kwargs and dynamic metadata values + "ANN401", # Allow boolean positional values in function calls, like `dict.get(... True)` "FBT003", # Ignore checks for possible passwords @@ -138,7 +141,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/**/*" = ["PLR2004", "S101", "TID252", "ANN"] "example/**/*" = ["T201"] [tool.coverage.run] diff --git a/integrations/chroma/src/haystack_integrations/document_stores/chroma/document_store.py b/integrations/chroma/src/haystack_integrations/document_stores/chroma/document_store.py index 0fef40cdef..37bccb0afb 100644 --- a/integrations/chroma/src/haystack_integrations/document_stores/chroma/document_store.py +++ b/integrations/chroma/src/haystack_integrations/document_stores/chroma/document_store.py @@ -102,7 +102,7 @@ def __init__( self._collection: chromadb.Collection | None = None self._async_collection: AsyncCollection | None = None - def _ensure_initialized(self): + def _ensure_initialized(self) -> None: if not self._collection: # Create the client instance if self._persist_path and (self._host or self._port is not None): @@ -160,7 +160,7 @@ def _ensure_initialized(self): embedding_function=self._embedding_func, ) - async def _ensure_initialized_async(self): + async def _ensure_initialized_async(self) -> None: if not self._async_collection: if self._host is None or self._port is None: error_message = ( @@ -341,7 +341,7 @@ def _compute_field_min_max( for meta in metadatas: if meta and field_name in meta: val = meta.get(field_name) - if isinstance(val, (str, int, float)): + if isinstance(val, str | int | float): values.append(val) if not values: