Allow modifying `_native_to_marshmallow`
See original GitHub issueThis 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:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
Yes, I will try to create a PR for this.
Implemented in 7794dd985168ec5d83c47c222e09d00516012628.