diff --git a/integrations/faiss/pyproject.toml b/integrations/faiss/pyproject.toml index dee32e978b..9041925881 100644 --- a/integrations/faiss/pyproject.toml +++ b/integrations/faiss/pyproject.toml @@ -89,6 +89,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -133,6 +134,8 @@ ignore = [ "ARG002", # Allow assertions "S101", + # Allow `Any` - used legitimately for dynamic types and SDK boundaries + "ANN401", ] exclude = ["example"] @@ -144,7 +147,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/faiss/src/haystack_integrations/components/retrievers/faiss/embedding_retriever.py b/integrations/faiss/src/haystack_integrations/components/retrievers/faiss/embedding_retriever.py index fde48d7bf1..7637e9091a 100644 --- a/integrations/faiss/src/haystack_integrations/components/retrievers/faiss/embedding_retriever.py +++ b/integrations/faiss/src/haystack_integrations/components/retrievers/faiss/embedding_retriever.py @@ -59,7 +59,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 `FAISSDocumentStore`. :param filters: Filters applied to the retrieved Documents at initialisation time. At runtime, these are merged diff --git a/integrations/faiss/src/haystack_integrations/document_stores/faiss/document_store.py b/integrations/faiss/src/haystack_integrations/document_stores/faiss/document_store.py index a51f6173cf..e0c82e2b74 100644 --- a/integrations/faiss/src/haystack_integrations/document_stores/faiss/document_store.py +++ b/integrations/faiss/src/haystack_integrations/document_stores/faiss/document_store.py @@ -34,7 +34,7 @@ def __init__( index_path: str | None = None, index_string: str = "Flat", embedding_dim: int = 768, - ): + ) -> None: """ Initializes the FAISSDocumentStore. @@ -61,7 +61,7 @@ def __init__( else: self._create_new_index() - def _create_new_index(self): + def _create_new_index(self) -> None: """Creates a new FAISS index.""" try: # We use IndexIDMap to support add_with_ids diff --git a/integrations/fastembed/pyproject.toml b/integrations/fastembed/pyproject.toml index 0ce009db79..01fad41085 100644 --- a/integrations/fastembed/pyproject.toml +++ b/integrations/fastembed/pyproject.toml @@ -79,6 +79,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -115,6 +116,8 @@ ignore = [ "S105", "S106", "S107", + # Allow `Any` - used legitimately for dynamic types and SDK boundaries + "ANN401", # Ignore complexity "C901", "PLR0911", @@ -131,7 +134,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"] # examples can contain "print" commands "examples/**/*" = ["T201", "E501"] diff --git a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py index cc70cabd56..1532c0e72b 100644 --- a/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py +++ b/integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/embedding_backend/fastembed_backend.py @@ -44,7 +44,7 @@ def __init__( cache_dir: str | None = None, threads: int | None = None, local_files_only: bool = False, - ): + ) -> None: self.model = TextEmbedding( model_name=model_name, cache_dir=cache_dir, threads=threads, local_files_only=local_files_only ) @@ -103,7 +103,7 @@ def __init__( threads: int | None = None, local_files_only: bool = False, model_kwargs: dict[str, Any] | None = None, - ): + ) -> None: model_kwargs = model_kwargs or {} self.model = SparseTextEmbedding( diff --git a/integrations/fastembed/src/haystack_integrations/components/rankers/fastembed/ranker.py b/integrations/fastembed/src/haystack_integrations/components/rankers/fastembed/ranker.py index 26878387f4..efb6ac89b3 100644 --- a/integrations/fastembed/src/haystack_integrations/components/rankers/fastembed/ranker.py +++ b/integrations/fastembed/src/haystack_integrations/components/rankers/fastembed/ranker.py @@ -46,7 +46,7 @@ def __init__( local_files_only: bool = False, meta_fields_to_embed: list[str] | None = None, meta_data_separator: str = "\n", - ): + ) -> None: """ Creates an instance of the 'FastembedRanker'. @@ -114,7 +114,7 @@ def from_dict(cls, data: dict[str, Any]) -> "FastembedRanker": """ return default_from_dict(cls, data) - def warm_up(self): + def warm_up(self) -> None: """ Initializes the component. """ diff --git a/integrations/firecrawl/pyproject.toml b/integrations/firecrawl/pyproject.toml index f72ef53535..4f98d541ca 100644 --- a/integrations/firecrawl/pyproject.toml +++ b/integrations/firecrawl/pyproject.toml @@ -88,6 +88,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -123,6 +124,8 @@ ignore = [ "S105", "S106", "S107", + # Allow `Any` - used legitimately for dynamic types and SDK boundaries + "ANN401", # Ignore complexity "C901", "PLR0911", @@ -143,7 +146,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"] [tool.coverage.run] source = ["haystack_integrations"] diff --git a/integrations/github/pyproject.toml b/integrations/github/pyproject.toml index 2b8bf9d2a9..19de81b37d 100644 --- a/integrations/github/pyproject.toml +++ b/integrations/github/pyproject.toml @@ -81,6 +81,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -121,6 +122,8 @@ ignore = [ # Misc "B008", "S101", + # Allow `Any` - used legitimately for dynamic types and SDK boundaries + "ANN401", ] [tool.ruff.lint.isort] @@ -131,7 +134,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"] # Ignore RUF001 for all files in the prompts directory "src/haystack_integrations/components/prompts/**/*" = ["RUF001"] diff --git a/integrations/github/src/haystack_integrations/components/connectors/github/file_editor.py b/integrations/github/src/haystack_integrations/components/connectors/github/file_editor.py index 9b72214dde..eb17606f2b 100644 --- a/integrations/github/src/haystack_integrations/components/connectors/github/file_editor.py +++ b/integrations/github/src/haystack_integrations/components/connectors/github/file_editor.py @@ -82,7 +82,7 @@ def __init__( repo: str | None = None, branch: str = "main", raise_on_failure: bool = True, - ): + ) -> None: """ Initialize the component. diff --git a/integrations/github/src/haystack_integrations/components/connectors/github/issue_commenter.py b/integrations/github/src/haystack_integrations/components/connectors/github/issue_commenter.py index 9f3eaca6ab..c422be8fbd 100644 --- a/integrations/github/src/haystack_integrations/components/connectors/github/issue_commenter.py +++ b/integrations/github/src/haystack_integrations/components/connectors/github/issue_commenter.py @@ -41,7 +41,7 @@ def __init__( github_token: Secret = Secret.from_env_var("GITHUB_TOKEN"), raise_on_failure: bool = True, retry_attempts: int = 2, - ): + ) -> None: """ Initialize the component. diff --git a/integrations/github/src/haystack_integrations/components/connectors/github/issue_viewer.py b/integrations/github/src/haystack_integrations/components/connectors/github/issue_viewer.py index 83e90c5edd..dd513ff2cf 100644 --- a/integrations/github/src/haystack_integrations/components/connectors/github/issue_viewer.py +++ b/integrations/github/src/haystack_integrations/components/connectors/github/issue_viewer.py @@ -40,7 +40,7 @@ def __init__( github_token: Secret | None = None, raise_on_failure: bool = True, retry_attempts: int = 2, - ): + ) -> None: """ Initialize the component. diff --git a/integrations/github/src/haystack_integrations/components/connectors/github/pr_creator.py b/integrations/github/src/haystack_integrations/components/connectors/github/pr_creator.py index 2c2e8d8eda..319d8cffe2 100644 --- a/integrations/github/src/haystack_integrations/components/connectors/github/pr_creator.py +++ b/integrations/github/src/haystack_integrations/components/connectors/github/pr_creator.py @@ -38,7 +38,12 @@ class GitHubPRCreator: ``` """ - def __init__(self, *, github_token: Secret = Secret.from_env_var("GITHUB_TOKEN"), raise_on_failure: bool = True): + def __init__( + self, + *, + github_token: Secret = Secret.from_env_var("GITHUB_TOKEN"), + raise_on_failure: bool = True, + ) -> None: """ Initialize the component. diff --git a/integrations/github/src/haystack_integrations/components/connectors/github/repo_forker.py b/integrations/github/src/haystack_integrations/components/connectors/github/repo_forker.py index 725a3e18b8..34af08d76f 100644 --- a/integrations/github/src/haystack_integrations/components/connectors/github/repo_forker.py +++ b/integrations/github/src/haystack_integrations/components/connectors/github/repo_forker.py @@ -48,7 +48,7 @@ def __init__( poll_interval: int = 2, auto_sync: bool = True, create_branch: bool = True, - ): + ) -> None: """ Initialize the component. diff --git a/integrations/github/src/haystack_integrations/components/connectors/github/repo_viewer.py b/integrations/github/src/haystack_integrations/components/connectors/github/repo_viewer.py index edf6a8a50e..0fcae77e25 100644 --- a/integrations/github/src/haystack_integrations/components/connectors/github/repo_viewer.py +++ b/integrations/github/src/haystack_integrations/components/connectors/github/repo_viewer.py @@ -76,7 +76,7 @@ def __init__( max_file_size: int = 1_000_000, # 1MB default limit repo: str | None = None, branch: str = "main", - ): + ) -> None: """ Initialize the component. diff --git a/integrations/github/src/haystack_integrations/tools/github/file_editor_tool.py b/integrations/github/src/haystack_integrations/tools/github/file_editor_tool.py index 3254c02deb..60181b1d2b 100644 --- a/integrations/github/src/haystack_integrations/tools/github/file_editor_tool.py +++ b/integrations/github/src/haystack_integrations/tools/github/file_editor_tool.py @@ -31,7 +31,7 @@ def __init__( outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None, inputs_from_state: dict[str, str] | None = None, outputs_to_state: dict[str, dict[str, str | Callable]] | None = None, - ): + ) -> None: """ Initialize the GitHub file editor tool. diff --git a/integrations/github/src/haystack_integrations/tools/github/issue_commenter_tool.py b/integrations/github/src/haystack_integrations/tools/github/issue_commenter_tool.py index eb89c67397..bec2387466 100644 --- a/integrations/github/src/haystack_integrations/tools/github/issue_commenter_tool.py +++ b/integrations/github/src/haystack_integrations/tools/github/issue_commenter_tool.py @@ -30,7 +30,7 @@ def __init__( outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None, inputs_from_state: dict[str, str] | None = None, outputs_to_state: dict[str, dict[str, str | Callable]] | None = None, - ): + ) -> None: """ Initialize the GitHub issue commenter tool. diff --git a/integrations/github/src/haystack_integrations/tools/github/issue_viewer_tool.py b/integrations/github/src/haystack_integrations/tools/github/issue_viewer_tool.py index 47326c7a71..b5bde3c734 100644 --- a/integrations/github/src/haystack_integrations/tools/github/issue_viewer_tool.py +++ b/integrations/github/src/haystack_integrations/tools/github/issue_viewer_tool.py @@ -30,7 +30,7 @@ def __init__( outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None, inputs_from_state: dict[str, str] | None = None, outputs_to_state: dict[str, dict[str, str | Callable]] | None = None, - ): + ) -> None: """ Initialize the GitHub issue viewer tool. diff --git a/integrations/github/src/haystack_integrations/tools/github/pr_creator_tool.py b/integrations/github/src/haystack_integrations/tools/github/pr_creator_tool.py index f076535146..208f799ce3 100644 --- a/integrations/github/src/haystack_integrations/tools/github/pr_creator_tool.py +++ b/integrations/github/src/haystack_integrations/tools/github/pr_creator_tool.py @@ -29,7 +29,7 @@ def __init__( outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None, inputs_from_state: dict[str, str] | None = None, outputs_to_state: dict[str, dict[str, str | Callable]] | None = None, - ): + ) -> None: """ Initialize the GitHub PR creator tool. diff --git a/integrations/github/src/haystack_integrations/tools/github/repo_forker_tool.py b/integrations/github/src/haystack_integrations/tools/github/repo_forker_tool.py index aade61ed32..4c5253dc2b 100644 --- a/integrations/github/src/haystack_integrations/tools/github/repo_forker_tool.py +++ b/integrations/github/src/haystack_integrations/tools/github/repo_forker_tool.py @@ -29,7 +29,7 @@ def __init__( outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None, inputs_from_state: dict[str, str] | None = None, outputs_to_state: dict[str, dict[str, str | Callable]] | None = None, - ): + ) -> None: """ Initialize the GitHub Repo Forker tool. diff --git a/integrations/github/src/haystack_integrations/tools/github/repo_viewer_tool.py b/integrations/github/src/haystack_integrations/tools/github/repo_viewer_tool.py index 91d40a0ab5..0380676775 100644 --- a/integrations/github/src/haystack_integrations/tools/github/repo_viewer_tool.py +++ b/integrations/github/src/haystack_integrations/tools/github/repo_viewer_tool.py @@ -32,7 +32,7 @@ def __init__( outputs_to_string: dict[str, str | Callable[[Any], str]] | None = None, inputs_from_state: dict[str, str] | None = None, outputs_to_state: dict[str, dict[str, str | Callable]] | None = None, - ): + ) -> None: """ Initialize the GitHub repository viewer tool. diff --git a/integrations/google_ai/pyproject.toml b/integrations/google_ai/pyproject.toml index 48031728f7..0c5275fb69 100644 --- a/integrations/google_ai/pyproject.toml +++ b/integrations/google_ai/pyproject.toml @@ -87,6 +87,7 @@ line-length = 120 [tool.ruff.lint] select = [ "A", + "ANN", "ARG", "B", "C", @@ -121,6 +122,8 @@ ignore = [ "S105", "S106", "S107", + # Allow `Any` - used legitimately for dynamic types and SDK boundaries + "ANN401", # Ignore complexity "C901", "PLR0911", @@ -141,7 +144,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"] [tool.coverage.run] source = ["haystack_integrations"] diff --git a/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/chat/gemini.py b/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/chat/gemini.py index 00b3a0d4d5..e0910c7444 100644 --- a/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/chat/gemini.py +++ b/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/chat/gemini.py @@ -151,7 +151,7 @@ def __init__( tools: Optional[list[Tool]] = None, tool_config: Optional[content_types.ToolConfigDict] = None, streaming_callback: Optional[StreamingCallbackT] = None, - ): + ) -> None: """ Initializes a `GoogleAIGeminiChatGenerator` instance. @@ -262,7 +262,7 @@ def run( streaming_callback: Optional[StreamingCallbackT] = None, *, tools: Optional[list[Tool]] = None, - ): + ) -> dict[str, list[ChatMessage]]: """ Generates text based on the provided messages. @@ -315,7 +315,7 @@ async def run_async( streaming_callback: Optional[StreamingCallbackT] = None, *, tools: Optional[list[Tool]] = None, - ): + ) -> dict[str, list[ChatMessage]]: """ Async version of the run method. Generates text based on the provided messages. diff --git a/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/gemini.py b/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/gemini.py index 3519053d88..089be60ad8 100644 --- a/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/gemini.py +++ b/integrations/google_ai/src/haystack_integrations/components/generators/google_ai/gemini.py @@ -62,7 +62,7 @@ class GoogleAIGeminiGenerator: ``` """ - def __new__(cls, *_, **kwargs): + def __new__(cls, *_: Any, **kwargs: Any) -> "GoogleAIGeminiGenerator": if "tools" in kwargs: msg = ( "GoogleAIGeminiGenerator does not support the `tools` parameter. " @@ -80,7 +80,7 @@ def __init__( generation_config: Optional[Union[GenerationConfig, dict[str, Any]]] = None, safety_settings: Optional[dict[HarmCategory, HarmBlockThreshold]] = None, streaming_callback: Optional[Callable[[StreamingChunk], None]] = None, - ): + ) -> None: """ Initializes a `GoogleAIGeminiGenerator` instance. @@ -185,7 +185,7 @@ def run( self, parts: Variadic[Union[str, ByteStream, Part]], streaming_callback: Optional[Callable[[StreamingChunk], None]] = None, - ): + ) -> dict[str, list[str]]: """ Generates text based on the given input parts.