{"id":5202,"library":"dynamic-yaml","title":"Dynamic YAML","description":"Dynamic-yaml (version 2.0.0) is a Python library that enhances standard YAML with self-referential and dynamic string resolution capabilities, allowing YAML entries to reference other parts of the configuration tree using Python's string formatting syntax. It is actively maintained with releases driven by feature development, with the latest major version released on April 9, 2024.","status":"active","version":"2.0.0","language":"en","source_language":"en","source_url":"https://github.com/childsish/dynamic-yaml","tags":["yaml","configuration","dynamic","self-referential"],"install":[{"cmd":"pip install dynamic-yaml","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for underlying YAML parsing and manipulation.","package":"PyYAML","optional":false}],"imports":[{"note":"Main class for working with dynamic YAML objects.","symbol":"DynamicYaml","correct":"from dynamic_yaml import DynamicYaml"},{"note":"Function to load YAML content with dynamic resolution.","symbol":"load","correct":"from dynamic_yaml import load"}],"quickstart":{"code":"import os\nimport yaml\nfrom dynamic_yaml import DynamicYaml, load\n\n# Simulate a YAML file content\nyaml_content = \"\"\"\nproject_name: hello-world\ndirs:\n  home: /home/user\n  venv: \"{dirs.home}/venvs/{project_name}\"\n  bin: \"{dirs.venv}/bin\"\noutput: \"{dirs.venv}/output-{parameters.parameter1}\"\nparameters:\n  parameter1: test_value\n\"\"\"\n\n# Load the YAML content, enabling dynamic resolution\nconfig = load(yaml_content)\n\n# Access resolved values using attribute access\nprint(f\"Project Name: {config.project_name}\")\nprint(f\"Virtual Environment Path: {config.dirs.venv}\")\nprint(f\"Output Path: {config.output}\")\n\n# Demonstrate changing a parameter and re-resolving (dynamic update)\nconfig.parameters.parameter1 = \"new_test\"\nprint(f\"Updated Output Path after parameter change: {config.output}\")","lang":"python","description":"Demonstrates loading a YAML string with self-referential keys and accessing the dynamically resolved values. It also shows how updating a referenced parameter automatically re-resolves dependent values, a feature introduced in v1.1.0."},"warnings":[{"fix":"Enclose any literal strings that contain curly braces with single or double quotes (e.g., `my_literal: '{not_a_variable}'`).","message":"String scalars containing curly braces (`{`, `}`) must be explicitly quoted if they are not intended for dynamic resolution. Without quotes, `dynamic-yaml` might attempt to resolve them, or standard YAML parsing might interpret them as mapping objects, leading to unexpected behavior.","severity":"gotcha","affected_versions":"All"},{"fix":"Use `config['key_name']` for keys that might clash with standard dictionary methods or attributes.","message":"When accessing keys that share names with built-in dictionary attributes (e.g., 'items', 'keys', 'values'), attribute access (`config.items`) will not work as expected. These values must be accessed using item notation (`config['items']`).","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}