You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am able to use marshmallow_dataclass perfectly when using with dataclasses.dataclass
However, I want to use it with attrs module instead - use the converters/validators functionalities.
It works well most of the time. However, I am facing problems when I use marshmallow_dataclass + attrs with inheritance.
Scenario 2 seems to be ok for my requirements. But I am not sure what weird stuff might happen by enabling both dataclasses and attrs together. If you are aware of possible problems I might get into, please let me know.
Sadly, given the output of the print (only c and d), my guess is that marshmallow-dataclass simply doesn't support attrs. All attributes are accessible at __attrs_attrs__ (or preferably via attrs.fields()) but it seems to only know about the fields that are defined within the body using type annotations.
I suspect it would be rather trivial for marshmallow-dataclass to support attrs if they cared for it, but it's nothing we can do anything about here at attrs.
I am able to use
marshmallow_dataclass
perfectly when using withdataclasses.dataclass
However, I want to use it with
attrs
module instead - use the converters/validators functionalities.It works well most of the time. However, I am facing problems when I use
marshmallow_dataclass
+attrs
with inheritance.Sample code is given below.
B = ClsB.Schema().load({'a': 123, 'b': 'bb', 'c': 4, 'd': "123"})
marshmallow.exceptions.ValidationError: {'a': ['Unknown field.'], 'b': ['Unknown field.']}
Questions:
dataclasses
andattrs
together. If you are aware of possible problems I might get into, please let me know.I have raised this query with
marshmallow_dataclass
as well.lovasoa/marshmallow_dataclass#236
I hope the first question is answered by
marshmallow_dataclass
team and second by theattrs
team.The text was updated successfully, but these errors were encountered: