Fatal1ty / mashumaro

Fast and well tested serialization library
Apache License 2.0
758 stars 45 forks source link

Adds a configuration option to allow mixed alias/unaliased field name use when deserializing #175

Closed matthew-chambers-pushly closed 10 months ago

matthew-chambers-pushly commented 10 months ago

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.

pep8speaks commented 10 months ago

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! :beers:

Comment last updated at 2023-11-14 15:16:43 UTC
matthew-chambers-pushly commented 10 months ago

Those mypy failures seem to be a regression introduced by mypy 1.7.

Fatal1ty commented 10 months ago

Those mypy failures seem to be a regression introduced by mypy 1.7.

I fixed it in master. Please, update your branch.

Fatal1ty commented 10 months ago

@matthew-chambers-pushly

I made some tweaks to tests and docs before the merge. Thank you for your contribution!

matthew-chambers-pushly commented 10 months ago

@matthew-chambers-pushly

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.