question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`exclude` in Meta breaks with marshmallow 3

See original GitHub issue

We have a pattern where we exclude some relations from the marshmallow schema like this:

class CustomerSchema(MyBaseSchema):
    class Meta(MyBaseSchema.Meta):
        model = Customer
        exclude = ('orders',)

Where Customer is a sqlalchemy model and orders is a relation from another table.

This works fine with marshmallow 2.x, but with marshmallow 3, an exception is thrown in the instantiation of CustomerSchema because marshmallow-sqlalchemy did not create the orders field, and so orders doesn’t exist to be excluded.

See also https://github.com/marshmallow-code/marshmallow/issues/877

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
sloriacommented, Jul 18, 2018

Yeah, dependent builds would be a nice feature in Travis. Shame that it’s not on the roadmap.

Nice work finding that test @deckar01 .

I won’t have time to look into this bug this week. @deckar01 or @yaheath would you be up for sending a PR?

0reactions
sloriacommented, Jul 20, 2018

The bugfix is released in 0.14.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrading to Newer Releases — marshmallow 3.19.0 ...
The marshmallow 3.x series supports Python >= 3.5. ... Int() class Meta: # Pass EXCLUDE as Meta option to keep marshmallow 2 behavior...
Read more >
Inheriting "exclude" meta parameter from super schema ...
I've found a solution that does work. from marshmallow import fields from marshmallow.schema import Schema class AncestorSchema(Schema): a = ...
Read more >
marshmallow - Read the Docs
You can also exclude fields by passing in the exclude parameter. ... The class Meta paradigm allows you to specify which attributes you...
Read more >
Python marshmallow Explained [Practical Examples]
In this tutorial, we will learn about the Python marshmallow library in detail. We will learn about marshmallow schema, form validation, and marshmallow...
Read more >
python-marshmallow-3.5.1-bp152.1.4 - SUSE Package Hub -
Fix bug where nested fields in Meta.exclude would not work on multiple ... for functions in ``marshmallow.utils`` that are removed in marshmallow 3....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found