Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set partial default in Meta class #2103

Open
npalmius opened this issue Feb 17, 2023 · 2 comments
Open

Add ability to set partial default in Meta class #2103

npalmius opened this issue Feb 17, 2023 · 2 comments

Comments

@npalmius
Copy link

It doesn't seem to be possible to configure a default partial property in the Meta class. Is there a reason for this?

It would be nice to be able to follow a pattern as follows:

class InsertSchema(Schema):
    class Meta:
        unknown = EXCLUDE

    id = fields.UUID(required=False)
    name = fields.Str(required=True)
    description = fields.Str(required=True)

class UpdateSchema(InsertSchema):
    class Meta(InsertSchema.Meta):
        exclude = ["id"]
        partial = True

The exclude in Meta works as expected, but the partial does not. I'm also using flask_smorest, so of course I can define this at the request level, e.g.

@blueprint.arguments(UpdateSchema(partial=True))

but it would be nice to be able to define it at the class-level, especially if the partial configuration is more complex and perhaps the schema is used in multiple places.

@zedrdave
Copy link

Also interested in this feature.

Particularly since it is not possible to use MySchema and MySchema(partial=True) without getting a naming collision with flask-sqlalchemy.

@lafrech
Copy link
Member

lafrech commented Sep 10, 2023

I guess partial was meant to be an instance parameter, but I see no objection to making it a class parameter.

Is someone willing to investigate and contribute the change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants