marshmallow-code / marshmallow-code/marshmallow
[RFC] Merge child Schema Meta with inherited parent Meta
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 738
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 7
Description
@sloria [commented](https://github.com/marshmallow-code/marshmallow/pull/1432#issuecomment-544538187):
> Should we also "auto-inherit" `Meta` even when doing single inheritance?
>
> ```python
> 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the behavior discussed in PR #1432 and trace how Schema Meta options are currently handled for inherited schemas. The work is complete when the inheritance behavior is agreed, implemented if needed, and covered by tests for single-inheritance and existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100