Skip to content

Commit abfd099

Browse files
committed
formatting
1 parent cb71551 commit abfd099

2 files changed

Lines changed: 36 additions & 36 deletions

File tree

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

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -135,26 +135,26 @@ class ValkeyDocumentStore(DocumentStore):
135135
_DUMMY_VALUE = -10.0
136136

137137
def __init__(
138-
self,
139-
# Connection configuration
140-
nodes_list: list[tuple[str, int]] | None = None,
141-
*,
142-
cluster_mode: bool = False,
143-
# Security and authentication configuration
144-
use_tls: bool = False,
145-
username: Secret | None = Secret.from_env_var("VALKEY_USERNAME", strict=False), # noqa: B008
146-
password: Secret | None = Secret.from_env_var("VALKEY_PASSWORD", strict=False), # noqa: B008
147-
# Client timeout and retry configuration
148-
request_timeout: int = 500,
149-
retry_attempts: int = 3,
150-
retry_base_delay_ms: int = 1000,
151-
retry_exponent_base: int = 2,
152-
# Document store operation configuration
153-
batch_size: int = 100,
154-
# Index and vector configuration
155-
index_name: str = "haystack_document",
156-
distance_metric: Literal["l2", "cosine", "ip"] = "cosine",
157-
embedding_dim: int = 768,
138+
self,
139+
# Connection configuration
140+
nodes_list: list[tuple[str, int]] | None = None,
141+
*,
142+
cluster_mode: bool = False,
143+
# Security and authentication configuration
144+
use_tls: bool = False,
145+
username: Secret | None = Secret.from_env_var("VALKEY_USERNAME", strict=False), # noqa: B008
146+
password: Secret | None = Secret.from_env_var("VALKEY_PASSWORD", strict=False), # noqa: B008
147+
# Client timeout and retry configuration
148+
request_timeout: int = 500,
149+
retry_attempts: int = 3,
150+
retry_base_delay_ms: int = 1000,
151+
retry_exponent_base: int = 2,
152+
# Document store operation configuration
153+
batch_size: int = 100,
154+
# Index and vector configuration
155+
index_name: str = "haystack_document",
156+
distance_metric: Literal["l2", "cosine", "ip"] = "cosine",
157+
embedding_dim: int = 768,
158158
):
159159
self._index_name = index_name
160160
self._distance_metric = self._parse_metric(distance_metric)
@@ -605,7 +605,7 @@ def write_documents(self, documents: list[Document], policy: DuplicatePolicy = D
605605
return written_count
606606

607607
async def write_documents_async(
608-
self, documents: list[Document], policy: DuplicatePolicy = DuplicatePolicy.NONE
608+
self, documents: list[Document], policy: DuplicatePolicy = DuplicatePolicy.NONE
609609
) -> int:
610610
"""
611611
Asynchronously write documents to the document store.
@@ -658,7 +658,7 @@ def write_single_doc(doc: Document) -> Any:
658658

659659
written_count = 0
660660
for i in range(0, len(documents), self._batch_size):
661-
batch = documents[i: i + self._batch_size]
661+
batch = documents[i : i + self._batch_size]
662662
try:
663663
await asyncio.gather(*[write_single_doc(doc) for doc in batch])
664664
written_count += len(batch)
@@ -807,12 +807,12 @@ async def delete_all_documents_async(self) -> None:
807807
raise ValkeyDocumentStoreError(msg) from e
808808

809809
def _embedding_retrieval(
810-
self,
811-
embedding: list[float],
812-
filters: dict[str, Any] | None = None,
813-
limit: int = 10,
814-
*,
815-
with_embedding: bool = True,
810+
self,
811+
embedding: list[float],
812+
filters: dict[str, Any] | None = None,
813+
limit: int = 10,
814+
*,
815+
with_embedding: bool = True,
816816
) -> list[Document]:
817817
"""
818818
Retrieve documents using vector similarity.
@@ -882,12 +882,12 @@ def _embedding_retrieval(
882882
raise ValkeyDocumentStoreError(msg) from e
883883

884884
async def _embedding_retrieval_async(
885-
self,
886-
embedding: list[float],
887-
filters: dict[str, Any] | None = None,
888-
limit: int = 10,
889-
*,
890-
with_embedding: bool = True,
885+
self,
886+
embedding: list[float],
887+
filters: dict[str, Any] | None = None,
888+
limit: int = 10,
889+
*,
890+
with_embedding: bool = True,
891891
) -> list[Document]:
892892
"""
893893
Asynchronously retrieve documents using vector similarity.
@@ -1027,7 +1027,7 @@ def _parse_documents_from_ft(raw: Any, *, with_embedding: bool) -> list[Document
10271027

10281028
@staticmethod
10291029
def _build_search_query_and_options(
1030-
embedding: list[float], filters: dict[str, Any] | None, limit: int, *, with_embedding: bool
1030+
embedding: list[float], filters: dict[str, Any] | None, limit: int, *, with_embedding: bool
10311031
) -> tuple[str, FtSearchOptions]:
10321032
# Validate and normalize filters
10331033
if filters:

integrations/valkey/tests/test_document_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ def test_to_float32_bytes(self):
613613
assert len(result) == len(vec) * 4
614614

615615
# Verify correct values by unpacking
616-
unpacked = [struct.unpack("<f", result[i: i + 4])[0] for i in range(0, len(result), 4)]
616+
unpacked = [struct.unpack("<f", result[i : i + 4])[0] for i in range(0, len(result), 4)]
617617
assert unpacked == pytest.approx(vec, rel=1e-6)
618618

619619
def test_verify_node_list_valid(self):

0 commit comments

Comments
 (0)