Skip to content

Commit 8e5178e

Browse files
committed
Increase indent on yaml
1 parent a24ffb8 commit 8e5178e

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

examples/document.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
MyBook:
2-
title: My life in Python
3-
sections:
4-
Abstract:
5-
paragraphs:
6-
- contents: Blah blah blah
7-
- contents: Blah2
8-
Chapter 1:
9-
paragraphs:
10-
- contents: More...
2+
title: My life in Python
3+
sections:
4+
Abstract:
5+
paragraphs:
6+
- contents: Blah blah blah
7+
- contents: Blah2
8+
Chapter 1:
9+
paragraphs:
10+
- contents: More...

src/modelspec/base_types.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def print_v(text: str):
7373
# This handles things like tuples as lists.
7474
yaml_converter = make_yaml_converter()
7575

76+
7677
# A simple converter that handles only value expressions.
7778
value_expr_converter = cattr.Converter()
7879

@@ -164,7 +165,9 @@ def to_yaml(self, include_metadata: bool = True) -> str:
164165
Returns:
165166
A YAML string representation of the object.
166167
"""
167-
return yaml.dump(yaml_converter.unstructure(self.to_dict()), sort_keys=False)
168+
return yaml.dump(
169+
yaml_converter.unstructure(self.to_dict()), sort_keys=False, indent=4
170+
)
168171

169172
def to_yaml_file(self, filename: str, include_metadata: bool = True) -> str:
170173
"""Convert modelspec format to yaml format
@@ -184,7 +187,10 @@ def to_yaml_file(self, filename: str, include_metadata: bool = True) -> str:
184187

185188
# We need to setup another
186189
yaml.dump(
187-
yaml_converter.unstructure(self.to_dict()), outfile, sort_keys=False
190+
yaml_converter.unstructure(self.to_dict()),
191+
outfile,
192+
sort_keys=False,
193+
indent=4,
188194
)
189195

190196
return filename

0 commit comments

Comments
 (0)