Skip to content

Commit 2a0688c

Browse files
julian-rischclaude
andauthored
chore: add ANN type annotations to google_genai, hanlp, jina, langfuse, lara (#2990)
Enable ruff ANN ruleset (excluding ANN401) for five integrations and fix all resulting violations by adding missing return type annotations. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7ac47c2 commit 2a0688c

15 files changed

Lines changed: 35 additions & 19 deletions

File tree

integrations/google_genai/pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ line-length = 120
9191
[tool.ruff.lint]
9292
select = [
9393
"A",
94+
"ANN",
9495
"ARG",
9596
"B",
9697
"C",
@@ -137,6 +138,8 @@ ignore = [
137138
"ARG005",
138139
# Allow function call argument defaults e.g. `Secret.from_env_var`
139140
"B008",
141+
# Allow `Any` - used legitimately for dynamic types and SDK boundaries
142+
"ANN401",
140143
]
141144

142145
[tool.ruff.lint.isort]
@@ -147,7 +150,7 @@ ban-relative-imports = "parents"
147150

148151
[tool.ruff.lint.per-file-ignores]
149152
# Tests can use magic values, assertions, and relative imports
150-
"tests/**/*" = ["PLR2004", "S101", "TID252"]
153+
"tests/**/*" = ["PLR2004", "S101", "TID252", "ANN"]
151154
# Examples can use print statements
152155
"examples/**/*" = ["T201"]
153156

integrations/google_genai/src/haystack_integrations/components/generators/google_genai/chat/chat_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def __init__(
203203
tools: ToolsType | None = None,
204204
timeout: float | None = None,
205205
max_retries: int | None = None,
206-
):
206+
) -> None:
207207
"""
208208
Initialize a GoogleGenAIChatGenerator instance.
209209

integrations/hanlp/pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ line-length = 120
9696
[tool.ruff.lint]
9797
select = [
9898
"A",
99+
"ANN",
99100
"ARG",
100101
"B",
101102
"C",
@@ -139,6 +140,8 @@ ignore = [
139140
"ARG005",
140141
"RUF001",
141142
"RUF002",
143+
# Allow `Any` - used legitimately for dynamic types and SDK boundaries
144+
"ANN401",
142145
]
143146

144147
[tool.ruff.lint.isort]
@@ -149,7 +152,7 @@ ban-relative-imports = "parents"
149152

150153
[tool.ruff.lint.per-file-ignores]
151154
# Tests can use magic values, assertions, and relative imports
152-
"tests/**/*" = ["PLR2004", "S101", "TID252"]
155+
"tests/**/*" = ["PLR2004", "S101", "TID252", "ANN"]
153156

154157
[tool.coverage.run]
155158
source = ["haystack_integrations"]

integrations/jina/pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ line-length = 120
8484
[tool.ruff.lint]
8585
select = [
8686
"A",
87+
"ANN",
8788
"ARG",
8889
"B",
8990
"C",
@@ -121,6 +122,8 @@ ignore = [
121122
"PLR0912",
122123
"PLR0913",
123124
"PLR0915",
125+
# Allow `Any` - used legitimately for dynamic types and SDK boundaries
126+
"ANN401",
124127
]
125128

126129
[tool.ruff.lint.isort]
@@ -131,7 +134,7 @@ ban-relative-imports = "parents"
131134

132135
[tool.ruff.lint.per-file-ignores]
133136
# Tests can use magic values, assertions, and relative imports
134-
"tests/**/*" = ["PLR2004", "S101", "TID252"]
137+
"tests/**/*" = ["PLR2004", "S101", "TID252", "ANN"]
135138
# examples can contain "print" commands
136139
"examples/**/*" = ["T201"]
137140

integrations/jina/src/haystack_integrations/components/connectors/jina/reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(
4545
mode: JinaReaderMode | str,
4646
api_key: Secret = Secret.from_env_var("JINA_API_KEY"), # noqa: B008
4747
json_response: bool = True,
48-
):
48+
) -> None:
4949
"""
5050
Initialize a JinaReader instance.
5151

integrations/jina/src/haystack_integrations/components/connectors/jina/reader_mode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class JinaReaderMode(Enum):
1919
SEARCH = "search"
2020
GROUND = "ground"
2121

22-
def __str__(self):
22+
def __str__(self) -> str:
2323
return self.value
2424

2525
@classmethod

integrations/jina/src/haystack_integrations/components/embedders/jina/document_embedder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(
4949
task: str | None = None,
5050
dimensions: int | None = None,
5151
late_chunking: bool | None = None,
52-
):
52+
) -> None:
5353
"""
5454
Create a JinaDocumentEmbedder component.
5555

integrations/jina/src/haystack_integrations/components/embedders/jina/document_image_embedder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
embedding_dimension: int | None = None,
6363
image_size: tuple[int, int] | None = None,
6464
batch_size: int = 5,
65-
):
65+
) -> None:
6666
"""
6767
Create a JinaDocumentImageEmbedder component.
6868

integrations/jina/src/haystack_integrations/components/embedders/jina/text_embedder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(
4242
task: str | None = None,
4343
dimensions: int | None = None,
4444
late_chunking: bool | None = None,
45-
):
45+
) -> None:
4646
"""
4747
Create a JinaTextEmbedder component.
4848

integrations/jina/src/haystack_integrations/components/rankers/jina/ranker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(
3636
api_key: Secret = Secret.from_env_var("JINA_API_KEY"), # noqa: B008,
3737
top_k: int | None = None,
3838
score_threshold: float | None = None,
39-
):
39+
) -> None:
4040
"""
4141
Creates an instance of JinaRanker.
4242
@@ -110,7 +110,7 @@ def run(
110110
documents: list[Document],
111111
top_k: int | None = None,
112112
score_threshold: float | None = None,
113-
):
113+
) -> dict[str, list[Document]]:
114114
"""
115115
Returns a list of Documents ranked by their similarity to the given query.
116116

0 commit comments

Comments
 (0)