pyyaml: dump set without null values

29 Views Asked by At

By default, pyyaml seems to dump sets like this:

test_set: !!set
  member_a: null
  member_b: null

However, I would prefer it to do this instead:

test_set: !!set {'member_a', 'member_b'}

which is valid according to this or this guide. What pyyaml currently does is not mentioned in the guides.

How can I achieve that? Is there an option?

I also checked with ruamel, but it seems to do the same as pyyaml here. Also it lacks the sort_keys=False option which I need.

0

There are 0 best solutions below