Commit edb8e106

stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
2025-09-24 18:05:32
fix(compat): compat with `pydantic<2.8.0` when using additional fields
1 parent 9c4b995
Changed files (2)
src/openai/types/evals/runs/output_item_list_response.py
@@ -27,12 +27,17 @@ class Result(BaseModel):
     type: Optional[str] = None
     """The grader type (for example, "string-check-grader")."""
 
-    __pydantic_extra__: Dict[str, object] = FieldInfo(init=False)  # pyright: ignore[reportIncompatibleVariableOverride]
     if TYPE_CHECKING:
+        # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a
+        # value to this field, so for compatibility we avoid doing it at runtime.
+        __pydantic_extra__: Dict[str, object] = FieldInfo(init=False)  # pyright: ignore[reportIncompatibleVariableOverride]
+
         # Stub to indicate that arbitrary properties are accepted.
         # To access properties that are not valid identifiers you can use `getattr`, e.g.
         # `getattr(obj, '$type')`
         def __getattr__(self, attr: str) -> object: ...
+    else:
+        __pydantic_extra__: Dict[str, object]
 
 
 class SampleInput(BaseModel):
src/openai/types/evals/runs/output_item_retrieve_response.py
@@ -27,12 +27,17 @@ class Result(BaseModel):
     type: Optional[str] = None
     """The grader type (for example, "string-check-grader")."""
 
-    __pydantic_extra__: Dict[str, object] = FieldInfo(init=False)  # pyright: ignore[reportIncompatibleVariableOverride]
     if TYPE_CHECKING:
+        # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a
+        # value to this field, so for compatibility we avoid doing it at runtime.
+        __pydantic_extra__: Dict[str, object] = FieldInfo(init=False)  # pyright: ignore[reportIncompatibleVariableOverride]
+
         # Stub to indicate that arbitrary properties are accepted.
         # To access properties that are not valid identifiers you can use `getattr`, e.g.
         # `getattr(obj, '$type')`
         def __getattr__(self, attr: str) -> object: ...
+    else:
+        __pydantic_extra__: Dict[str, object]
 
 
 class SampleInput(BaseModel):