Settings

Qualified name: algan.settings.abstract\_settings.Settings

class Settings[source]

Bases: object

Base 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 imported SETTINGS once. Assigning a field routes through set(), 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_mutable

as_preset

clone

override

Temporarily override a mutable section and restore it reliably.

set

Validate and apply settings.

to_dict

Attributes

is_preset

override(**kwargs)[source]

Temporarily override a mutable section and restore it reliably.

set(source=None, **kwargs)[source]

Validate and apply settings.

source may 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.