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/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..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 @@ -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. @@ -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: