44
55# ruff: noqa: FBT001 Boolean-typed positional argument in function definition
66
7- from typing import Any , Optional , Union
7+ from typing import Any
88
99from haystack import component , default_from_dict , default_to_dict , logging
1010from haystack .dataclasses import Document
@@ -28,13 +28,13 @@ def __init__(
2828 self ,
2929 * ,
3030 document_store : OpenSearchDocumentStore ,
31- filters : Optional [ dict [str , Any ]] = None ,
32- fuzziness : Union [ int , str ] = "AUTO" ,
31+ filters : dict [str , Any ] | None = None ,
32+ fuzziness : int | str = "AUTO" ,
3333 top_k : int = 10 ,
3434 scale_score : bool = False ,
3535 all_terms_must_match : bool = False ,
36- filter_policy : Union [ str , FilterPolicy ] = FilterPolicy .REPLACE ,
37- custom_query : Optional [ dict [str , Any ]] = None ,
36+ filter_policy : str | FilterPolicy = FilterPolicy .REPLACE ,
37+ custom_query : dict [str , Any ] | None = None ,
3838 raise_on_failure : bool = True ,
3939 ):
4040 """
@@ -158,12 +158,12 @@ def _prepare_bm25_args(
158158 self ,
159159 * ,
160160 query : str ,
161- filters : Optional [ dict [str , Any ]] ,
162- all_terms_must_match : Optional [ bool ] ,
163- top_k : Optional [ int ] ,
164- fuzziness : Optional [ Union [ str , int ]] ,
165- scale_score : Optional [ bool ] ,
166- custom_query : Optional [ dict [str , Any ]] ,
161+ filters : dict [str , Any ] | None ,
162+ all_terms_must_match : bool | None ,
163+ top_k : int | None ,
164+ fuzziness : str | int | None ,
165+ scale_score : bool | None ,
166+ custom_query : dict [str , Any ] | None ,
167167 ) -> dict [str , Any ]:
168168 filters = apply_filter_policy (self ._filter_policy , self ._filters , filters )
169169
@@ -194,13 +194,13 @@ def _prepare_bm25_args(
194194 def run (
195195 self ,
196196 query : str ,
197- filters : Optional [ dict [str , Any ]] = None ,
198- all_terms_must_match : Optional [ bool ] = None ,
199- top_k : Optional [ int ] = None ,
200- fuzziness : Optional [ Union [ int , str ]] = None ,
201- scale_score : Optional [ bool ] = None ,
202- custom_query : Optional [ dict [str , Any ]] = None ,
203- document_store : Optional [ OpenSearchDocumentStore ] = None ,
197+ filters : dict [str , Any ] | None = None ,
198+ all_terms_must_match : bool | None = None ,
199+ top_k : int | None = None ,
200+ fuzziness : int | str | None = None ,
201+ scale_score : bool | None = None ,
202+ custom_query : dict [str , Any ] | None = None ,
203+ document_store : OpenSearchDocumentStore | None = None ,
204204 ) -> dict [str , list [Document ]]:
205205 """
206206 Retrieve documents using BM25 retrieval.
@@ -294,13 +294,13 @@ def run(
294294 async def run_async ( # pylint: disable=too-many-positional-arguments
295295 self ,
296296 query : str ,
297- filters : Optional [ dict [str , Any ]] = None ,
298- all_terms_must_match : Optional [ bool ] = None ,
299- top_k : Optional [ int ] = None ,
300- fuzziness : Optional [ Union [ int , str ]] = None ,
301- scale_score : Optional [ bool ] = None ,
302- custom_query : Optional [ dict [str , Any ]] = None ,
303- document_store : Optional [ OpenSearchDocumentStore ] = None ,
297+ filters : dict [str , Any ] | None = None ,
298+ all_terms_must_match : bool | None = None ,
299+ top_k : int | None = None ,
300+ fuzziness : int | str | None = None ,
301+ scale_score : bool | None = None ,
302+ custom_query : dict [str , Any ] | None = None ,
303+ document_store : OpenSearchDocumentStore | None = None ,
304304 ) -> dict [str , list [Document ]]:
305305 """
306306 Asynchronously retrieve documents using BM25 retrieval.
0 commit comments