question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow modifying `_native_to_marshmallow`

See original GitHub issue

This is a follow-up to #16, which was closed after introducing NewType. As explained in the following, the NewType-solution is not possible in my case, so I’d like to ask you to reconsider adding a way to make _native_to_marshmallow mutable. From the implementation it looks pretty simple to replace _native_to_marshmallow by a dynamic look-up to Marshmallow’s Schema.TYPE_MAPPING. Then I could modify the latter and marshmallow_dataclass would pick up the changes.

I would like to “register” a fixed Marshmallow field that should be used whenever a type appears in a dataclass that is converted via marshmallow_dataclass:

@dataclass
class Schema:
    color: Color

should be equivalent to

@dataclass
class Schema:
    color: Color = field(metadata={  ... some lengthy definitions here ... })

Unfortunately, I cannot replace “Color” by a NewType, because it is defined in a lower-level library. I would like to avoid having two very similar types, one from the library, and another one for use in schemas.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
MartinAltmayercommented, Mar 8, 2020

Yes, I will try to create a PR for this.

0reactions
MartinAltmayercommented, Mar 19, 2020

Implemented in 7794dd985168ec5d83c47c222e09d00516012628.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Reference — marshmallow 2.21.0 documentation
Serialize an object to native Python data types according to this Schema's fields. Parameters. obj – The object to serialize. many (bool) –...
Read more >
Android custom permissions - Marshmallow - Stack Overflow
As of Android Marshmallow (6.0 - API 23) an application needs to request permission from the user, to use its own custom permission....
Read more >
Toasted Marshmallow & Vanilla - Native Deodorant
Toasty sweet with a vanilla kick, this mouthwatering scent will have you craving s’mo.
Read more >
Marshmallow Permissions in the Simulator and Native Code
permissions system we added two features to the simulator and the AndroidNativeUtil class. Simulate Permission Prompts. You can simulate ...
Read more >
How to Manage App Permissions on Marshmallow or Higher ...
Android 6.0 Marshmallow added a new permissions system that can make ... if you change your mind about giving a certain app permission...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found