Module

config.origin_tracker

Origin tracking for config introspection.

Tracks which file contributed each configuration key for debugging and thebengal config show --origincommand.

Classes

ConfigWithOrigin
Configuration with origin tracking. Tracks which file (or source) contributed each configuration k…
6

Configuration with origin tracking.

Tracks which file (or source) contributed each configuration key for introspection and debugging.

Methods 3

merge
Merge config and track origin.
2 None
def merge(self, other: dict[str, Any], origin: str) -> None

Merge config and track origin.

Parameters 2
other dict[str, Any]

Config dict to merge in

origin str

Source identifier (e.g., "_default/site.yaml")

show_with_origin
Format config with origin annotations.
1 str
def show_with_origin(self, indent: int = 0) -> str

Format config with origin annotations.

Parameters 1
indent int

Starting indentation level

Returns

str

Formatted string with origins as comments

get_origin
Get origin for a specific key path.
1 str | None
def get_origin(self, key_path: str) -> str | None

Get origin for a specific key path.

Parameters 1
key_path str

Dot-separated key path (e.g., "site.title")

Returns

str | None

Origin string, or None if not found

Internal Methods 3
__init__
Initialize empty config with origin tracking.
0 None
def __init__(self) -> None

Initialize empty config with origin tracking.

_merge_recursive
Recursively merge and track origins.
4 None
def _merge_recursive(self, base: dict[str, Any], override: dict[str, Any], origin: str, path: list[str]) -> None

Recursively merge and track origins.

Parameters 4
base dict[str, Any]

Base dict (mutated)

override dict[str, Any]

Override dict

origin str

Source identifier

path list[str]

Current key path (for tracking)

_format_recursive
Recursively format config with origins.
4 None
def _format_recursive(self, config: dict[str, Any], lines: list[str], path: list[str], indent: int) -> None

Recursively format config with origins.

Parameters 4
config dict[str, Any]

Config dict

lines list[str]

Output lines (appended to)

path list[str]

Current key path

indent int

Current indentation level