-1

I am using yaml.dump to write out my yaml files from aggregated data.

This yaml file is then fed to a 3rd party tool that uses yamllint to check the file before processing the data.

I have two problems. The first I've found an amazing solution that I don't quite understand here
python yaml.dump bad indentation

It blows my mind that what appears to be the most popular yaml python module and the most generic linter are not compatible, but at least there was an easy solution.

The other problem is just a warning, but I'd like to fix it.
1:1 warning missing document start "---" (document-start)

I figure there is probably a fairly easy way to add "---" to the dumper, but I haven't found an example and I don't fully understand how the indentation solution works so I am not sure how to modify it to print out the document start.

I can of course just modify the file after the fact, but that's a very unsatisfying solution

JDWK
  • 51
  • 5
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jan 30 '22 at 05:33

1 Answers1

3

Ok I just had to read through the PyYaml documentation. There is just an argument to pyyaml.dump to tell it to print the document start.

yaml.dump(data, stream, explicit_start=True)

There is also explicit_end as well.

Tom Aarsen
  • 1,170
  • 2
  • 20
JDWK
  • 51
  • 5