marshmallow-code / marshmallow-code/marshmallow
Meta Decorator
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 738
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 7
Description
## Motivation
I often have lots of small schemas containing unique `Meta` classes with only a few attributes. The `Meta` class sometimes requires more lines than the schema definition and makes a file containing multiple schemas harder to read. This is especially true when using `marshmallow-jsonapi` due to `type_`.
## Proposal
Provide a `meta` decorator that will inject its kwargs into a `Meta` class for the class it is wrapping.
## Example
Before:
```py
class TestSchema(Schema):
foo = fields.String()
bar = fields.String()
class Meta:
type_ = 'tests'
ordered = True
```
After:
```py
@meta(type_='tests', ordered=True)
class TestSchema(Schema):
foo = fields.String()
bar = fields.String()
```
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
Start by reviewing how Schema classes handle their nested Meta class and compare that behavior with the proposed @meta(type_='tests', ordered=True) usage. Confirm how decorator arguments should become Meta attributes, including the marshmallow-jsonapi type_ case. Done means the decorator works for the shown schema pattern and preserves the existing Meta behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100