Skip to content

Commit 0efdd04

Browse files
toondaeytrygveu
andauthored
Update cognite/extractorutils/unstable/configuration/loaders.py
Co-authored-by: Trygve Utstumo <trygveu@users.noreply.github.com>
1 parent 99bbf53 commit 0efdd04

File tree

1 file changed

+7
-1
lines changed
  • cognite/extractorutils/unstable/configuration

1 file changed

+7
-1
lines changed

cognite/extractorutils/unstable/configuration/loaders.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,13 @@ def load_dict(data: dict, schema: type[_T], context: dict[str, Any] | None = Non
169169
Args:
170170
data: A dictionary containing the configuration data.
171171
schema: The schema class to parse the configuration into.
172-
context: Optional context to pass to the schema during validation.
172+
context: Optional Pydantic validation context: forwarded to
173+
``schema.model_validate(..., context=...)`` and exposed to validators as
174+
``ValidationInfo.context``. Pydantic reuses one dict for the entire validation
175+
run, so validators can add or change keys to pass data to validators that run
176+
later (for example a model validator stashing derived data for nested field
177+
validators). The dict you pass in is therefore mutated in place; pass a fresh
178+
dict if you need the original object unchanged after load.
173179
174180
Returns:
175181
An instance of the schema populated with the configuration data.

0 commit comments

Comments
 (0)