Skip to content

VariableReference

🛈 DocStrings

Represents a variable reference in YAML.

Source code in src/configz/yaml_tools/constructors/variable.py
class VariableReference:
    """Represents a variable reference in YAML."""

    def __init__(self, name: str) -> None:
        self.name = name

    def resolve(self, variables: Mapping[str, Any]) -> Any:
        """Resolve variable value."""
        if self.name not in variables:
            msg = f"Missing variable: {self.name}"
            raise KeyError(msg)
        return variables[self.name]

resolve

resolve(variables: Mapping[str, Any]) -> Any

Resolve variable value.

Source code in src/configz/yaml_tools/constructors/variable.py
def resolve(self, variables: Mapping[str, Any]) -> Any:
    """Resolve variable value."""
    if self.name not in variables:
        msg = f"Missing variable: {self.name}"
        raise KeyError(msg)
    return variables[self.name]

:fa-brands-github: Show source on GitHub