Skip to content

Children schema doesn't get parent init values #86

Open
@jgourinda

Description

@jgourinda

When using a parent schema the initialization value do get passed to the actual children schema.
Use case: I want to be able to bypass the classic post_load make_object when I init a partial schema.

    @post_load
    def make_object(self, data: Dict) -> object:
        if self.__model__ is None or self.partial:
            return data
        return self.__model__(**data)

The problem is that if a use a parent OneOfSchema the final schema is instantiated withou any init parameters. See here and here in marshmallowoneofschema/marshmallow_oneofschema/one_of_schema.py

schema = type_schema if isinstance(type_schema, Schema) else type_schema()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions