Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register and process yaml tags when tags are set #81

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sirno
Copy link

@sirno sirno commented Feb 24, 2023

Hi

I just went through the mildly painful process of trying to input data that includes local tags i.e. !TagName.

Anyway the way that dataclass_wizard handles the loading and dumping of such types is unfortunately not compatible with something like serde_yaml.

I adjusted __init_subclass__ to register custom loaders on yaml.SafeLoader and custom representers on yaml.SafeDumper to handle these cases. Obviously this is not quite clean, because these adjustments are now needed for the serialization and the encoder and decoder arguments should not be exposed in this case.

Also with this change attributes that are local class instances need these classes to be subclasses of YAMLWizard

It works for me. I will use it on my fork. If you want to adjust this to cleanly implement this into the meta class madness consider this a feature request.

Cheers

P.S. Thanks for maintaining this library! i use it a lot. and love it. <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant