marshmallow-code / marshmallow-code/flask-smorest

type annotations would improve Example docs and reduce confusion

Open
#279 1 comment 0 reactions 0 assignees View on GitHub
documentation enhancement
Dominant language
Python
Stars
717
Forks
77
Avg merge
7h 49m
Merged PRs (30d)
3

Description

I suggest adding type-annotations to these examples to clarify what's happening

[We have this example:
](https://flask-smorest.readthedocs.io/en/latest/quickstart.html)@blp.arguments(PetSchema)
@blp.response(201, PetSchema)
def post(self, new_data):
"""Add a new pet"""
item = Pet.create(**new_data)
return item

If "PetSchema" know's how to encode and decode it's respective model/dataclass, then I would expect "new_data" to be a PetModel ... but this code makes it clear that it's only a dictionary

Type annotations would clear this up for newbies and I'd also like clear examples that show how to make PetSchema smart enough to pass a dataclass (object with useful methods) into the handler

Contributor guide

Open the contributing guide

Research direction

Start with the Quickstart example linked in the issue and inspect how its PetSchema and handler are documented. Clarify the type of new_data with annotations and add an example showing how PetSchema can pass a dataclass to the handler; done means the examples accurately explain dictionary versus model-like data for newcomers.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
api, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.