mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore: Adds indent to YAML sequence by default for better visual readability
Both are valid YAML, just with indent, it's more visually friend to see the data structure hierarchy. Before ``` items: - item1 - item2 - item3 ``` After ``` items: - item1 - item2 - item3 ``` PiperOrigin-RevId: 806117290
This commit is contained in:
committed by
Copybara-Service
parent
f73ae6e101
commit
91528890db
@@ -43,9 +43,16 @@ def dump_pydantic_to_yaml(
|
||||
file_path = Path(file_path)
|
||||
file_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Create a custom dumper class
|
||||
class _MultilineDumper(yaml.SafeDumper):
|
||||
pass
|
||||
|
||||
def increase_indent(self, flow=False, indentless=False):
|
||||
"""Override to force consistent indentation for sequences in mappings.
|
||||
|
||||
By default, PyYAML uses indentless=True for sequences that are values
|
||||
in mappings, creating flush-left alignment. This override forces proper
|
||||
indentation for all sequences regardless of context.
|
||||
"""
|
||||
return super(_MultilineDumper, self).increase_indent(flow, False)
|
||||
|
||||
def multiline_str_representer(dumper, data):
|
||||
if '\n' in data:
|
||||
|
||||
Reference in New Issue
Block a user