pyyaml
pyyaml copied to clipboard
Loader dumper objects api
Depends on #561
One thing which is not clear from the example is an important design question: The current PR looks into the instance based constructors (if it is an instance), and if it doesn't find the tag there, it goes on to search in the class based constructors. Meaning, doing
l1 = yaml.SafeLoader()
yaml.add_constructor('!dice', dice_constructor, Loader=yaml.SafeLoader)
will still result in finding a constructor for !dice
when using l1
My proposal would be to only lookup in one or the other - either instance or class based. After all we want to get away from the class based global-like thing, and any new stuff would only be supported by the instance API.
One thing which is not clear from the example is an important design question: The current PR looks into the instance based constructors (if it is an instance), and if it doesn't find the tag there, it goes on to search in the class based constructors. Meaning, doing
l1 = yaml.SafeLoader() yaml.add_constructor('!dice', dice_constructor, Loader=yaml.SafeLoader)
will still result in finding a constructor for
!dice
when usingl1
My proposal would be to only lookup in one or the other - either instance or class based. After all we want to get away from the class based global-like thing, and any new stuff would only be supported by the instance API.
Good point but your instance needs to at least copy over the default class constructors. iow, integers still need to work.
I still have a lot to finish up on this PR. Should have something reviewable by Monday.
Good point but your instance needs to at least copy over the default class constructors.
of course.
iow, integers still need to work.
integers?