Framework for Python

Workflow

settings_write()

Write project settings.

With section, only that section of the active environment is replaced. When the section is stored in a split file under settings/, the values are merged into that file instead, under the section key the file wraps its content in. The values may include that key ({"git": {...}}) or leave it out. Without section, the whole file is replaced, wrapped in a default: environment.

Comments in a rewritten file are not kept.

Usage

settings_write(
    values: Mapping[str, Any],
    settings_file: str | Path | None = None,
    section: str | None = None,
) -> None

Arguments

Name Type Default Description
values required Mapping[str, Any]

The settings to write. Without section, a mapping without a default key is wrapped in one.

settings_file str | Path | None None

The settings file. Default: the settings.yml or config.yml found from the current directory, else settings.yml in the current directory.

section str | None None

The top-level section to replace, such as "directories", in the active environment (active_environment()), or at the top level of a flat file with no environments. Default: replace the whole file.

Raises

  • SettingsError: When section is given and the settings file or its split file does not exist.