Skip to content

Commit e79545c

Browse files
author
maxime.c
committed
fix indentation
1 parent fc3888f commit e79545c

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

bin/fix_acceptance_tests_yml.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@
2121
from typing import Dict, Any
2222

2323

24+
class FixingListIndentationDumper(yaml.Dumper):
25+
"""
26+
The original indentation for list generates formatting issues on our side. So this dumper goes from:
27+
```
28+
tests:
29+
- config_path: secrets/config.json
30+
status: succeed
31+
```
32+
33+
...to:
34+
```
35+
tests:
36+
- config_path: secrets/config.json
37+
status: succeed
38+
```
39+
40+
"""
41+
def increase_indent(self, flow=False, indentless=False):
42+
return super(FixingListIndentationDumper, self).increase_indent(flow, False)
43+
44+
2445
class AlreadyUpdatedError(Exception):
2546
"""Exception raised when the YAML file has already been updated."""
2647
pass
@@ -51,7 +72,7 @@ def transform(file_path: Path) -> None:
5172

5273
# Write back to file with preserved formatting
5374
with open(file_path, 'w') as f:
54-
yaml.dump(data, f, default_flow_style=False, sort_keys=False, indent=2)
75+
yaml.dump(data, f, Dumper=FixingListIndentationDumper, default_flow_style=False, sort_keys=False)
5576

5677
print(f"Successfully transformed {file_path}")
5778

0 commit comments

Comments
 (0)