-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Adds a configuration option to allow mixed alias/unaliased field name use when deserializing #175
Conversation
deserializing, and the requisite test and docs updates.
Hello @matthew-chambers-pushly! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2023-11-14 15:16:43 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something that was on my radar! Thank you for bringing it in. However, there are some things worth paying attention to.
I think that loose_deserialization
is too broad name for this feature. I'm sure there is a more accurate name for it. How about allow_deserialization_not_by_alias
?
…`allow_deserialization_not_by_alias`
…lization_not_by_alias` enabled using the field name or alias in the load.
368af37
to
ad3bbd8
Compare
Those mypy failures seem to be a regression introduced by |
I fixed it in master. Please, update your branch. |
I made some tweaks to tests and docs before the merge. Thank you for your contribution! |
Thank you for the library, we've shown the testing and coverage as an example to younger devs. |
Problem statement:
Our company uses mashumaro extensively and have several interconnected services that use the same shared data structures; however, in some places it is useful for the serialized payloads to be human readable and in other places having the keys be "minified" using aliases is more important. To prevent needing to duplicate the dataclasses around the codebase, we use a combination of dialects and the
by_alias=
option to control how the data is serialized, but when the data is deserialized in the current mashumaro build the fieldnames must match the alias.Changes:
Adds an option called
loose_deserialization
to the BaseConfig to allow for mixed aliased/unaliased usage during deserialization.