Skip to main content

detect_settings

Identifies the configuration format used in the provided settings and returns a Settings object, ensuring compatibility between old and new setting names. It validates that configuration keys are not inconsistently mixed and applies necessary transformations or defaults based on the detected format.

def detect_settings(
conf: dict,
preconf: dict = None,
ignore_keys: set = None,
prefix: str = None,
all_keys: set = None,
old_keys: set = None
) - > Settings

Identifies and normalizes configuration settings by detecting whether the input uses legacy or modern naming conventions. It validates that settings are not inconsistently mixed and returns a unified Settings object with appropriate mappings and defaults.

Parameters

NameTypeDescription
confdictThe primary configuration dictionary containing user-defined settings.
preconfdict = NoneAn optional dictionary of initial configuration values to be merged and normalized.
ignore_keysset = NoneA collection of keys to exclude from the detection and validation process.
prefixstr = NoneA string prefix used to filter settings; if provided, the function defaults to modern naming conventions.
all_keysset = NoneThe set of valid modern setting keys to check against.
old_keysset = NoneThe set of legacy setting keys used for backward compatibility detection.

Returns

TypeDescription
SettingsA Settings object containing the merged configuration, default values, and bidirectional translation maps between old and new setting keys.