Skip to content

Commit 4d1adb4

Browse files
julian-rischclaude
andauthored
chore: enforce ruff docstring rules (D102/D103/D205/D209/D213/D417/D419) in integrations 11-20 (#3009)
Adds D102, D103, D205, D209, D213, D417, D419 ruff rules to pyproject.toml for: deepeval, elasticsearch, faiss, fastembed, firecrawl, github, google_genai, hanlp, jina, kreuzberg. Fixes all resulting docstring violations. Part of #2947 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0fde410 commit 4d1adb4

File tree

27 files changed

+127
-29
lines changed

27 files changed

+127
-29
lines changed

integrations/deepeval/pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ select = [
8787
"ARG",
8888
"B",
8989
"C",
90+
"D102", # Missing docstring in public method
91+
"D103", # Missing docstring in public function
92+
"D205", # 1 blank line required between summary line and description
93+
"D209", # Closing triple quotes go to new line
94+
"D213", # summary lines must be positioned on the second physical line of the docstring
95+
"D417", # Missing argument descriptions in the docstring
96+
"D419", # Docstring is empty
9097
"DTZ",
9198
"E",
9299
"EM",
@@ -142,7 +149,7 @@ ban-relative-imports = "all"
142149

143150
[tool.ruff.lint.per-file-ignores]
144151
# Tests can use magic values, assertions, and relative imports
145-
"tests/**/*" = ["PLR2004", "S101", "TID252", "ANN"]
152+
"tests/**/*" = ["D", "PLR2004", "S101", "TID252", "ANN"]
146153

147154
[tool.coverage.run]
148155
source = ["haystack_integrations"]

integrations/deepeval/src/haystack_integrations/components/evaluators/deepeval/evaluator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
@component
2020
class DeepEvalEvaluator:
2121
"""
22-
A component that uses the [DeepEval framework](https://docs.confident-ai.com/docs/evaluation-introduction)
23-
to evaluate inputs against a specific metric. Supported metrics are defined by `DeepEvalMetric`.
22+
A component that uses DeepEval to evaluate inputs against a specific metric.
23+
24+
Uses the [DeepEval framework](https://docs.confident-ai.com/docs/evaluation-introduction).
25+
Supported metrics are defined by `DeepEvalMetric`.
2426
2527
Usage example:
2628
```python

integrations/elasticsearch/pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ select = [
9090
"ARG",
9191
"B",
9292
"C",
93+
"D102", # Missing docstring in public method
94+
"D103", # Missing docstring in public function
95+
"D205", # 1 blank line required between summary line and description
96+
"D209", # Closing triple quotes go to new line
97+
"D213", # summary lines must be positioned on the second physical line of the docstring
98+
"D417", # Missing argument descriptions in the docstring
99+
"D419", # Docstring is empty
93100
"DTZ",
94101
"E",
95102
"EM",
@@ -139,7 +146,7 @@ ban-relative-imports = "parents"
139146

140147
[tool.ruff.lint.per-file-ignores]
141148
# Tests can use magic values, assertions, relative imports, and don't need type annotations
142-
"tests/**/*" = ["PLR2004", "S101", "TID252", "ANN"]
149+
"tests/**/*" = ["D", "PLR2004", "S101", "TID252", "ANN"]
143150

144151
[tool.coverage.run]
145152
source = ["haystack_integrations"]

integrations/elasticsearch/src/haystack_integrations/components/retrievers/elasticsearch/bm25_retriever.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
@component
1515
class ElasticsearchBM25Retriever:
1616
"""
17-
ElasticsearchBM25Retriever retrieves documents from the ElasticsearchDocumentStore using BM25 algorithm to find the
18-
most similar documents to a user's query.
17+
Retrieves documents from ElasticsearchDocumentStore using the BM25 algorithm.
18+
19+
Finds the most similar documents to a user's query.
1920
2021
This retriever is only compatible with ElasticsearchDocumentStore.
2122

integrations/elasticsearch/src/haystack_integrations/document_stores/elasticsearch/document_store.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050

5151
class ElasticsearchDocumentStore:
5252
"""
53-
An ElasticsearchDocumentStore instance that works with Elastic Cloud or your own
54-
Elasticsearch cluster.
53+
An ElasticsearchDocumentStore instance that works with Elastic Cloud or your own Elasticsearch cluster.
5554
5655
Usage example (Elastic Cloud):
5756
```python
@@ -309,6 +308,7 @@ def count_documents(self) -> int:
309308
async def count_documents_async(self) -> int:
310309
"""
311310
Asynchronously returns how many documents are present in the document store.
311+
312312
:returns: Number of documents in the document store.
313313
"""
314314
self._ensure_initialized()
@@ -407,7 +407,9 @@ async def filter_documents_async(self, filters: dict[str, Any] | None = None) ->
407407
def _deserialize_document(hit: dict[str, Any]) -> Document:
408408
"""
409409
Creates a `Document` from the search hit provided.
410+
410411
This is mostly useful in self.filter_documents().
412+
411413
:param hit: A search hit from Elasticsearch.
412414
:returns: `Document` created from the search hit.
413415
"""
@@ -1136,8 +1138,7 @@ def _extract_distinct_counts_from_aggregations(
11361138

11371139
def count_unique_metadata_by_filter(self, filters: dict[str, Any], metadata_fields: list[str]) -> dict[str, int]:
11381140
"""
1139-
Returns the number of unique values for each specified metadata field of the documents
1140-
that match the provided filters.
1141+
Returns the number of unique values for each specified metadata field that match the provided filters.
11411142
11421143
:param filters: The filters to apply to count documents.
11431144
For filter syntax, see [Haystack metadata filtering](https://docs.haystack.deepset.ai/docs/metadata-filtering)
@@ -1180,8 +1181,7 @@ async def count_unique_metadata_by_filter_async(
11801181
self, filters: dict[str, Any], metadata_fields: list[str]
11811182
) -> dict[str, int]:
11821183
"""
1183-
Asynchronously returns the number of unique values for each specified metadata field of the documents
1184-
that match the provided filters.
1184+
Asynchronously returns unique value counts for each specified metadata field matching the provided filters.
11851185
11861186
:param filters: The filters to apply to count documents.
11871187
For filter syntax, see [Haystack metadata filtering](https://docs.haystack.deepset.ai/docs/metadata-filtering)
@@ -1352,6 +1352,7 @@ def get_metadata_field_unique_values(
13521352
) -> tuple[list[str], dict[str, Any] | None]:
13531353
"""
13541354
Returns unique values for a metadata field, optionally filtered by a search term in the content.
1355+
13551356
Uses composite aggregations for proper pagination beyond 10k results.
13561357
13571358
See: https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-composite-aggregation
@@ -1418,6 +1419,7 @@ async def get_metadata_field_unique_values_async(
14181419
) -> tuple[list[str], dict[str, Any] | None]:
14191420
"""
14201421
Asynchronously returns unique values for a metadata field, optionally filtered by a search term in the content.
1422+
14211423
Uses composite aggregations for proper pagination beyond 10k results.
14221424
14231425
See: https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-composite-aggregation

integrations/faiss/pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ select = [
9595
"ARG",
9696
"B",
9797
"C",
98+
"D102", # Missing docstring in public method
99+
"D103", # Missing docstring in public function
100+
"D205", # 1 blank line required between summary line and description
101+
"D209", # Closing triple quotes go to new line
102+
"D213", # summary lines must be positioned on the second physical line of the docstring
103+
"D417", # Missing argument descriptions in the docstring
104+
"D419", # Docstring is empty
98105
"DTZ",
99106
"E",
100107
"EM",
@@ -149,7 +156,7 @@ ban-relative-imports = "parents"
149156

150157
[tool.ruff.lint.per-file-ignores]
151158
# Tests can use magic values, assertions, and relative imports
152-
"tests/**/*" = ["PLR2004", "S101", "TID252", "ANN"]
159+
"tests/**/*" = ["D", "PLR2004", "S101", "TID252", "ANN"]
153160
"example/**/*" = ["T201"]
154161

155162
[tool.coverage.run]

integrations/faiss/src/haystack_integrations/components/retrievers/faiss/embedding_retriever.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def __init__(
6161
filter_policy: str | FilterPolicy = FilterPolicy.REPLACE,
6262
) -> None:
6363
"""
64+
Initialize FAISSEmbeddingRetriever.
65+
6466
:param document_store: An instance of `FAISSDocumentStore`.
6567
:param filters: Filters applied to the retrieved Documents at initialisation time. At runtime, these are merged
6668
with any runtime filters according to the `filter_policy`.

integrations/fastembed/pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ select = [
8383
"ARG",
8484
"B",
8585
"C",
86+
"D102", # Missing docstring in public method
87+
"D103", # Missing docstring in public function
88+
"D205", # 1 blank line required between summary line and description
89+
"D209", # Closing triple quotes go to new line
90+
"D213", # summary lines must be positioned on the second physical line of the docstring
91+
"D417", # Missing argument descriptions in the docstring
92+
"D419", # Docstring is empty
8693
"DTZ",
8794
"E",
8895
"EM",
@@ -134,7 +141,7 @@ ban-relative-imports = "parents"
134141

135142
[tool.ruff.lint.per-file-ignores]
136143
# Tests can use magic values, assertions, and relative imports
137-
"tests/**/*" = ["PLR2004", "S101", "TID252", "ANN"]
144+
"tests/**/*" = ["D", "PLR2004", "S101", "TID252", "ANN"]
138145
# examples can contain "print" commands
139146
"examples/**/*" = ["T201", "E501"]
140147

integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_document_embedder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class FastembedDocumentEmbedder:
1515
"""
1616
FastembedDocumentEmbedder computes Document embeddings using Fastembed embedding models.
17+
1718
The embedding of each Document is stored in the `embedding` field of the Document.
1819
1920
Usage example:
@@ -110,6 +111,7 @@ def __init__(
110111
def to_dict(self) -> dict[str, Any]:
111112
"""
112113
Serializes the component to a dictionary.
114+
113115
:returns:
114116
Dictionary with serialized data.
115117
"""

integrations/fastembed/src/haystack_integrations/components/embedders/fastembed/fastembed_sparse_document_embedder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def __init__(
106106
def to_dict(self) -> dict[str, Any]:
107107
"""
108108
Serializes the component to a dictionary.
109+
109110
:returns:
110111
Dictionary with serialized data.
111112
"""

0 commit comments

Comments
 (0)