1414from collections import Counter
1515from collections .abc import AsyncIterator , Callable , Sequence
1616from enum import StrEnum , auto
17- from typing import TYPE_CHECKING , Any , ClassVar
17+ from typing import TYPE_CHECKING , Any , ClassVar , cast
1818
1919import anyio
2020from pydantic import BaseModel , JsonValue
@@ -120,9 +120,7 @@ def __init__(
120120 self ,
121121 fields : Sequence [str ] | None = None ,
122122 index_name : str = "pqa_index" ,
123- index_directory : str | os .PathLike = IndexSettings .model_fields [
124- "index_directory"
125- ].default ,
123+ index_directory : str | os .PathLike | None = None ,
126124 storage : SearchDocumentStorage = SearchDocumentStorage .PICKLE_COMPRESSED ,
127125 ):
128126 if fields is None :
@@ -133,6 +131,11 @@ def __init__(
133131 f"{ self .REQUIRED_FIELDS } must be included in search index fields."
134132 )
135133 self .index_name = index_name
134+ if index_directory is None : # Pull from settings
135+ index_directory = cast (
136+ Callable [[], str | os .PathLike ],
137+ IndexSettings .model_fields ["index_directory" ].default_factory ,
138+ )()
136139 self ._index_directory = index_directory
137140 self ._schema : Schema | None = None
138141 self ._index : Index | None = None
0 commit comments