diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a973508ad8..5375c94d75 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: black-jupyter - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.289 + rev: v0.0.290 hooks: - id: ruff diff --git a/haystack/nodes/other/join_docs.py b/haystack/nodes/other/join_docs.py index 27761535ce..4185873a7c 100644 --- a/haystack/nodes/other/join_docs.py +++ b/haystack/nodes/other/join_docs.py @@ -82,7 +82,7 @@ def run_accumulated(self, inputs: List[dict], top_k_join: Optional[int] = None): "score would be `-infinity`." ) else: - sorted_docs = [(k, v) for k, v in scores_map.items()] + sorted_docs = list(scores_map.items()) if not top_k_join: top_k_join = self.top_k_join diff --git a/haystack/nodes/retriever/sparse.py b/haystack/nodes/retriever/sparse.py index 61f7b0c8d0..c32dddf0a6 100644 --- a/haystack/nodes/retriever/sparse.py +++ b/haystack/nodes/retriever/sparse.py @@ -457,10 +457,7 @@ def _get_all_paragraphs(self, document_store: BaseDocumentStore, index: Optional def _calc_scores(self, queries: List[str], index: str) -> List[Dict[int, float]]: question_vector = self.vectorizer.transform(queries) doc_scores_per_query = self.tfidf_matrices[index].dot(question_vector.T).T.toarray() - doc_scores_per_query = [ - [(doc_idx, doc_score) for doc_idx, doc_score in enumerate(doc_scores)] - for doc_scores in doc_scores_per_query - ] + doc_scores_per_query = [list(enumerate(doc_scores)) for doc_scores in doc_scores_per_query] indices_and_scores: List[Dict] = [ OrderedDict(sorted(query_idx_scores, key=lambda tup: tup[1], reverse=True)) for query_idx_scores in doc_scores_per_query