Flask Type Stubs

1.1.6 · maintenance · verified Fri Apr 10

types-flask is a PEP 561 type stub package providing static type information for the Flask web framework. It allows type-checking tools like MyPy, PyCharm, and Pyright to analyze code that uses Flask, catching potential type-related errors before runtime. The current version is 1.1.6. It is part of the `typeshed` project, which generally releases updates as needed to align with changes in the runtime libraries it provides stubs for, although its primary function for Flask versions 2.0 and newer has been superseded by Flask's native type annotations.

Warnings

Install

Imports

Quickstart

This minimal Flask application demonstrates basic routing. If you are using Flask version prior to 2.0, `types-flask` would provide type checking for this code. For Flask 2.0 and newer, Flask includes its own type annotations, rendering `types-flask` unnecessary.

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world() -> str:
    return 'Hello, World!'

# To run (if Flask < 2.0 and types-flask is needed):
# FLASK_APP=app.py FLASK_ENV=development mypy app.py
# FLASK_APP=app.py flask run

view raw JSON →