pyyaml icon indicating copy to clipboard operation
pyyaml copied to clipboard

Disable Aliases/Anchors

Open engnadeau opened this issue 8 years ago • 4 comments

Expected Behaviour

  • Ability to disable generated aliases and anchors (AA) in yaml.dump()

Use Case

  • Tool for generating default yaml config file for an application
  • Users of the generated config file should not need to know how AA work

Actual Behaviour

  • No option to disable AA

Current Workaround

class NoAliasDumper(yaml.Dumper):
    def ignore_aliases(self, data):
        return True

yaml.dump(x, Dumper=NoAliasDumper)

Potential Solution

  • Add a flag to yaml.dump() that switches the functionality of ignore_aliases()

engnadeau avatar Nov 27 '17 17:11 engnadeau

Update on this? Should really just be a nice clean option.

I'm still doing the (imo dirty) line: yaml.Dumper.ignore_aliases = lambda *args: True from this SO post.

vincerubinetti avatar Dec 01 '22 04:12 vincerubinetti

bump

black-snow avatar Aug 04 '24 18:08 black-snow

rebump

hyunlee1o avatar Nov 27 '24 11:11 hyunlee1o

ba-ba-bump!

sammy-hughes avatar Mar 22 '25 04:03 sammy-hughes