I have been using marshmallow-dataclass to improve the typing of Python input and output, and overall this has been excellent.
However, it would be great to have some way to configure a custom subclass of the marshmallow Nested field to use for nested dataclass properties when converted to a Schema.
For most other types, I have been able to customise the field type using the TYPE_MAPPING property in the base_schema, but this doesn't seem to be possible for Nested schema fields created from object properties in the dataclass as it looks to me like it's hard-coded in field_for_schema, and anyway the call signature for Nested fields is different to other fields because it takes the schema as a positional argument.
Ideally, I'd like to be able to configure this as a property on the base_schema (similar to TYPE_MAPPING) so that it propagates automatically.
I'd be happy to submit a pull request if it would help.
I have been using
marshmallow-dataclass
to improve the typing of Python input and output, and overall this has been excellent.However, it would be great to have some way to configure a custom subclass of the marshmallow
Nested
field to use for nesteddataclass
properties when converted to aSchema
.For most other types, I have been able to customise the field type using the
TYPE_MAPPING
property in thebase_schema
, but this doesn't seem to be possible forNested
schema fields created from object properties in thedataclass
as it looks to me like it's hard-coded infield_for_schema
, and anyway the call signature forNested
fields is different to other fields because it takes the schema as a positional argument.Ideally, I'd like to be able to configure this as a property on the
base_schema
(similar toTYPE_MAPPING
) so that it propagates automatically.I'd be happy to submit a pull request if it would help.