Skip to content

Commit ceb597f

Browse files
fix(compat): compat with pydantic<2.8.0 when using additional fields
1 parent c6f06b9 commit ceb597f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/contextual/types/agents/query_response.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,17 @@ class RetrievalContentCtxlMetadata(BaseModel):
4949
section_title: Optional[str] = None
5050
"""Title of the section."""
5151

52-
__pydantic_extra__: Dict[str, object] = FieldInfo(init=False) # pyright: ignore[reportIncompatibleVariableOverride]
5352
if TYPE_CHECKING:
53+
# Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a
54+
# value to this field, so for compatibility we avoid doing it at runtime.
55+
__pydantic_extra__: Dict[str, object] = FieldInfo(init=False) # pyright: ignore[reportIncompatibleVariableOverride]
56+
5457
# Stub to indicate that arbitrary properties are accepted.
5558
# To access properties that are not valid identifiers you can use `getattr`, e.g.
5659
# `getattr(obj, '$type')`
5760
def __getattr__(self, attr: str) -> object: ...
61+
else:
62+
__pydantic_extra__: Dict[str, object]
5863

5964

6065
class RetrievalContentCustomMetadataConfig(BaseModel):

0 commit comments

Comments
 (0)