Skip to content

Improving Flask stubs - #3003

Merged
JelleZijlstra merged 5 commits into
python:masterfrom
s-kovacevic:flask-route-stubs
Jul 4, 2019
Merged

JelleZijlstra merged 5 commits into
python:masterfrom
s-kovacevic:flask-route-stubs

Conversation

@s-kovacevic

Copy link
Copy Markdown
Contributor

Recently I started using typing in a flask application but since most of the stubs are generated, it didn't help much. I'm trying to improve stubs starting from what is used the most (view functions, render_template, jsonify etc).

Before I spend more time on this I'd like to get some feedback.

With this change, view functions are properly type checked, for example:

@core.route('/index', methods=['GET'])
def index() -> Union[str, Response]:
    content = os.getenv('content')
    if content is not None:
        return content
    return redirect('/bye')

Here is the reference that covers most of the changes for easier review:
https://github.com/pallets/flask/blob/master/flask/app.py#L1992

@JelleZijlstra JelleZijlstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

Comment thread third_party/2and3/flask/app.pyi Resolved
Comment thread third_party/2and3/flask/blueprints.pyi Resolved
Comment thread third_party/2and3/flask/templating.pyi Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants