Skip to content

[RFC] Merge child Schema Meta with inherited parent Meta #1969

Description

@lafrech

@sloria commented:

Should we also "auto-inherit" Meta even when doing single inheritance?

class MyBaseSchema(Schema):
    class Meta:
        render_module = ujson

class ArtistSchema(MyBaseSchema):
    class Meta:  # implicitly inherits MyBaseSchema.Meta
        ordered = True

My apps generally define a base schema and it is a PITA to have to explicitly inherit BaseSchema.Meta. Plus I generally forget to do it as I wrongly assume Meta is inherited already. I just got hit by this again.

Which behaviour is the most intuitive is arguable. Current behaviour of not merging might be the most Pythonic. But since those are not really classes but merely a place to store attributes, we're free to do what we think is the most sensible and useful.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions