Typing Stubs for Flask-Migrate

4.1.0.20260408 · active · verified Thu Apr 16

This library provides static type checking stubs for Flask-Migrate, enabling tools like MyPy to verify type correctness in applications using Flask-Migrate. It is part of the Python typeshed project, which maintains a collection of high-quality type hints for various Python packages. Updates are released regularly to keep pace with changes in the runtime libraries they type-check.

Common errors

Warnings

Install

Imports

Quickstart

To use `types-flask-migrate`, install it alongside `flask-migrate` and `mypy`. The stubs provide type hints for your code that uses `flask-migrate`. There is no direct runtime import or usage of `types-flask-migrate` itself; it's consumed by type checkers. The example demonstrates a minimal Flask-Migrate setup that `mypy` would then analyze.

import os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate

# Basic Flask application setup
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', 'sqlite:///app.db')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)

# Initialize Flask-Migrate
migrate = Migrate(app, db)

# Define a simple model (for demonstration)
class User(db.Model):
    id: int = db.Column(db.Integer, primary_key=True)
    name: str = db.Column(db.String(128))

# Example usage (not run at runtime, for type checking only)
# def create_db_and_migrate():
#     with app.app_context():
#         db.create_all()
#         # In a real app, you'd run 'flask db migrate' and 'flask db upgrade' via CLI

print('Flask-Migrate types loaded. Run `mypy your_app.py` to check types.')

view raw JSON →