Skip to content

Commit 21284ca

Browse files
Use typed default_factory for SearchState list fields
Align the retrieval-rag SearchState list defaults with the codebase's Field(default_factory=...) idiom (PR #220 review). Use the typed default_factory=list[int] rather than a bare default_factory=list, since the bare form infers list[Unknown] and trips strict pyright's reportUnknownVariableType on a list[int] field.
1 parent a84e6f4 commit 21284ca

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

examples/retrieval-rag/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
from collections.abc import Mapping, Sequence
6363
from typing import Any
6464

65+
from pydantic import Field
66+
6567
from openarmature.graph import (
6668
END,
6769
CompiledGraph,
@@ -185,10 +187,12 @@ def _cosine(a: Sequence[float], b: Sequence[float]) -> float:
185187
class SearchState(State):
186188
query: str
187189
# Corpus indices of the cosine-retrieved candidates, best-first.
188-
candidate_indices: list[int] = []
190+
# (default_factory takes the typed list[int] so it stays clean under
191+
# strict typing, where a bare default_factory=list infers list[Unknown].)
192+
candidate_indices: list[int] = Field(default_factory=list[int])
189193
# Corpus indices after reranking, best-first (a reordered, trimmed
190194
# subset of candidate_indices).
191-
ranked_indices: list[int] = []
195+
ranked_indices: list[int] = Field(default_factory=list[int])
192196
answer: str | None = None
193197

194198

0 commit comments

Comments
 (0)