nicetoolbox.configs.placeholders.resolve_placeholders_dict_mut

nicetoolbox.configs.placeholders.resolve_placeholders_dict_mut(input: dict[str, Union[str, int, float, bool]], placeholders: dict[str, Union[str, int, float, bool]], unreachable: set[str] | None = None, max_iterations: int = 5) dict[str, Any][source]

Resolve placeholders in a dict using both provided context and self-references. Iteratively resolves <var> placeholders in string values using: 1. Provided placeholders dict 2. Other string values within the same dict (self-reference)

Input placeholders dictionary will be mutated with new local placeholders.

Resolution continues until no changes occur or max_iterations is reached. Non-string values (numbers, lists, nested dicts) are returned unchanged. Function expects to resolve all known placeholders or raise an error.

Parameters:
  • input (dict[str, PLACEHOLDERS_TYPE]) – Dict containing string values to resolve.

  • placeholders (dict[str, Any]) – Context dict for resolution. Will be mutated to include resolved string values from input.

  • unreachable (Optional[set[str]]) – Placeholder names that are allowed to remain unresolved (e.g., runtime placeholders resolved later).

  • max_iterations (int) – Maximum resolution passes to handle chained dependencies.

Returns:

Dict with all resolvable placeholders replaced.

Raises:
  • ValueError – If unresolved placeholders remain that are not in unreachable (indicates typos or circular dependencies).

  • KeyError – If placeholders and input dicts have names collision (including non-string fields names)