Settings¶
Qualified name: algan.settings.abstract\_settings.Settings
- class Settings[source]¶
Bases:
objectBase class for validated settings sections and immutable presets.
Normal settings sections are mutable:
set()validates a complete replacement value and then updates the existing object in place. This keeps section identity stable for code that importedSETTINGSonce. Assigning a field routes throughset(), so the two spellings validate and normalize identically.Presets use the same concrete classes but are marked immutable. Calling
set()on a preset returns another preset and leaves the original untouched. Direct assignment to a preset field is rejected.Methods
as_mutableas_presetcloneTemporarily override a mutable section and restore it reliably.
Validate and apply settings.
to_dictAttributes
is_preset- set(source=None, **kwargs)[source]¶
Validate and apply settings.
sourcemay be another instance of the same settings class. Its fields are copied first, then any keyword overrides are applied. Mutable sections are changed in place and returned. Presets return a new immutable copy.Every field is validated – the replacement is built by re-running the section’s own construction – but only the fields whose value actually changed are written back, so an unrelated field keeps its identity.
Keywords may use a field’s alias; naming one field by two spellings in the same call is an error rather than a silent last-one-wins.