Open Vince-LD opened 3 months ago
Yes, I'm proposing something similar. Actually, my first implementation works really well in real conditions (used it at work this week). I'm going to try another implentation by using marshmallow-generic
but it would still require to modify the signature of marshmallow_dataclass.class_schema
to use this generic Schema
and a dataclass TypeVar
instead of type
and Schema
.
Hello,
This week, I've started to use marshmallow and marshmallow_dataclass at work for the first time and it's absolutely great. However, I was wondering if there was a reason not to use a generic schema to keep track of the wrapped dataclass when using
class_schema
factory.The basic idea is pretty simple:
Then we can create a dataclass and the corresponding schema:
I have created a first implementation of this proposal in this fork. I am not familiar with mypy (I use Pyright through Pylance) and really advanced typing so I don't know if this is the best way to achieve my goal. If this subject interests you I'd be glad to contribute :)
Cheers, Vincent
Edit: Sorry for the tag....