Skip to content

toml

TOML configuration file generator.

Generates TOML configuration files from Pydantic settings models.

Classes:

Classes

TomlGeneratorSettings pydantic-model

Bases: BaseModel

Configuration for TOML generator.

Show JSON schema:
JSON
{
  "description": "Configuration for TOML generator.\n\nGenerator name: `toml`.",
  "properties": {
    "paths": {
      "description": "Output file paths",
      "items": {
        "format": "path",
        "type": "string"
      },
      "title": "Paths",
      "type": "array"
    },
    "include_comments": {
      "default": true,
      "description": "Include field descriptions as comments",
      "title": "Include Comments",
      "type": "boolean"
    }
  },
  "title": "TomlGeneratorSettings",
  "type": "object"
}

Fields:

Attributes

paths pydantic-field
Python
paths: list[Path]

Output file paths

include_comments pydantic-field
Python
include_comments: bool = True

Include field descriptions as comments

TomlGenerator

Bases: AbstractGenerator

Generate TOML configuration files.

Methods:

Functions

generate_single
Python
generate_single(settings_info: SettingsInfoModel, level: int = 1) -> str

Generate TOML format configuration.

Parameters:

  • settings_info (SettingsInfoModel) –

    Settings information model

  • level (int, default: 1 ) –

    Nesting level, by default 1

Returns:

  • str

    Generated TOML content

_format_value
Python
_format_value(field: FieldInfoModel) -> str

Format field value for TOML.

Parameters:

  • field (FieldInfoModel) –

    Field information

Returns:

  • str

    Formatted value

_parse_value
Python
_parse_value(field: FieldInfoModel) -> Any

Parse field value to appropriate Python type.

Parameters:

  • field (FieldInfoModel) –

    Field information

Returns:

  • Any

    Parsed value

Functions