Preserve formatting if yml already exists
Closed this issue · 2 comments
Running dbt-invoke comes at the price of loosing formatting.
Currently, dbt-invoke properties
squashes and unindents
- name: X
- name: Y
to
- name: X
- name: Y
Or re-formats lists (e.g. in tests) from
values: ["A", "B"]
to
values:
- "A"
- "B"
Hence there are three options:
- either people have to switch to formatting - compact and rich with hyphens (which is less readable and navigable)
- or we have to redo formatting after every
dbt-invoke properties
(Nope out!=) - limit the use of
dbt-invoke properties
only to freshly-generated models and update variables list manually (my current approach=/)
Request:
To preserve formatting for pieces of documentation are already written in yml
(PS: how can I contribute?)
This would be a nice option if we can make it work. I would also like to keep the option to reformat to some basic default formatting like we have now. We use that at Dashlane to make sure our property files are formatted consistently.
It looks like the ruamel.yaml package can handle "round-trip" yaml formatting with a few limitations. We currently use PyYAML which does not handle "round-trip" formatting as far as I know.
My first idea would be to alter the parse_yaml
and write_yaml
functions in _utils.py to take that into account. I think we would want to control this behavior by accepting a new command line argument in properties.py, but I am open to other thoughts.
I'm glad you would like to contribute! I think the best way go about that process is to:
- Open up an issue like you did here
- Discuss and agree on a design
- Create a fork to implement the design
- Add test(s) if the changes are not covered by an existing test
- Make sure all tests are passing
- Update README.md
- Update the version number
- Submit a pull request
What are your thoughts on of all that?
The recently merged PR #20 (thanks @ciklista) has addressed the preservation of:
- comments
- list formatting
values: ["A", "B"]
- empty lines between items
- name: X - name: Y
It has not addressed custom indentation schemes. I'll close this issue because a standalone issue (#23) has been created for custom indentation.