nicetoolbox.configs.placeholders.resolve_placeholders

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

Recursively find and resolve placeholders in input data with corresponding values. Placeholders should be formatted as <var> strings inside data structure fields. If placeholders key isn’t inside dict or can’t be resolved from local context, it will rise resolution error.

Parameters:
  • input – The data structure to be processed. Only strings, lists, dicts and pydantics.BaseModel are processed. Other input is returned as is.

  • placeholders (dict[str, PLACEHOLDERS_TYPE]) – A dictionary containing the placeholder values.

  • unreachable (set, optional) – Set of placeholder names that are allowed to remain unresolved (e.g., runtime placeholders resolved later).

Returns:

The copy of processed data structure with placeholders replaced.

Raises:
  • ValueError – If dict-level placeholders cannot be resolved (circular dependencies or missing placeholders that are not in unreachable set).

  • KeyError – If there’s a field name collision between input dict and placeholders dict when processing inputs.