bayesline.api.parse_stored#
- bayesline.api.parse_stored(settings_type: type[T], raw_json: Mapping[str, Any]) T#
Migrate and validate persisted raw JSON into a Settings instance.
This is the single entry point for turning stored settings JSON back into a typed object. It (1) applies the schema-version migration chain via
migrate_raw_json, then (2) validates under a load context that drops any keys the current model no longer declares.Step (2) is what lets a field be removed from a
Settingssubclass without writing a migration: old rows that still carry the dropped field load cleanly, while the model keepsextra="forbid"so that constructing a setting with an unknown field still raises. The dropping is performed bySettings’ load-time validator, which pydantic re-applies at every nesting level, so embedded child settings (e.g. a calendar nested inside a universe) get the same tolerance as the top-level object. Renames and restructures still need an explicit migration — silently dropping the key here would lose the value.Parameters#
- settings_typetype[T]
The Settings subclass to validate into.
- raw_jsonMapping[str, Any]
The stored JSON, possibly from an older schema and/or carrying fields the current model no longer declares.
Returns#
- T
The validated settings instance.