{"id":7822,"library":"types-flask-migrate","title":"Typing Stubs for Flask-Migrate","description":"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.","status":"active","version":"4.1.0.20260408","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["types","typing","flask","flask-migrate","stubs","mypy"],"install":[{"cmd":"pip install types-flask-migrate","lang":"bash","label":"Install package"}],"dependencies":[],"imports":[{"note":"This is a runtime import from the actual Flask-Migrate library, for which types-flask-migrate provides stubs.","symbol":"Migrate","correct":"from flask_migrate import Migrate"},{"note":"Commonly used Flask-Migrate command functions.","symbol":"init","correct":"from flask_migrate import init"}],"quickstart":{"code":"import os\nfrom flask import Flask\nfrom flask_sqlalchemy import SQLAlchemy\nfrom flask_migrate import Migrate\n\n# Basic Flask application setup\napp = Flask(__name__)\napp.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', 'sqlite:///app.db')\napp.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False\ndb = SQLAlchemy(app)\n\n# Initialize Flask-Migrate\nmigrate = Migrate(app, db)\n\n# Define a simple model (for demonstration)\nclass User(db.Model):\n    id: int = db.Column(db.Integer, primary_key=True)\n    name: str = db.Column(db.String(128))\n\n# Example usage (not run at runtime, for type checking only)\n# def create_db_and_migrate():\n#     with app.app_context():\n#         db.create_all()\n#         # In a real app, you'd run 'flask db migrate' and 'flask db upgrade' via CLI\n\nprint('Flask-Migrate types loaded. Run `mypy your_app.py` to check types.')\n","lang":"python","description":"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."},"warnings":[{"fix":"Ensure `flask-migrate` and `types-flask-migrate` are up-to-date. If issues persist, check the `typeshed` GitHub issues for specific version compatibility notes.","message":"Type stubs (like `types-flask-migrate`) must match the version of the runtime library (`flask-migrate`) as closely as possible. Significant version mismatches can lead to incorrect type errors or missing type information.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install `types-flask-sqlalchemy` and `types-sqlalchemy` if your project uses them to achieve comprehensive type checking.","message":"`types-flask-migrate` provides stubs for `flask_migrate`, but it does not include stubs for `Flask-SQLAlchemy` or `SQLAlchemy` directly. You'll likely need `types-flask-sqlalchemy` and `types-sqlalchemy` for full type coverage.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If encountering `mypy` errors due to missing stubs for specific `flask-migrate` features, consider contributing to `typeshed` or using `# type: ignore` as a temporary workaround with a comment explaining why.","message":"Type stubs from typeshed are sometimes incomplete for very new features or less common use cases in the underlying library. While generally comprehensive, edge cases might lack full typing.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install types-flask-migrate`. Ensure your `mypy` configuration (if any) correctly points to your environment or `site-packages`.","cause":"The `types-flask-migrate` package is not installed, or `mypy` cannot find it.","error":"error: Library stubs not installed for \"flask_migrate\""},{"fix":"Verify that both `flask-migrate` and `types-flask-migrate` are up-to-date by running `pip install --upgrade flask-migrate types-flask-migrate`. Double-check the spelling and casing of the imported symbol.","cause":"This error typically indicates a version mismatch between `flask-migrate` and its type stubs (`types-flask-migrate`), or a typo in the imported symbol.","error":"error: Module 'flask_migrate' has no attribute 'Migrate' (or similar attribute error for other symbols)"},{"fix":"Install the actual `flask-migrate` library: `pip install flask-migrate`. `types-flask-migrate` only provides type hints, not the runtime code.","cause":"The runtime library `flask-migrate` is not installed in the environment where `mypy` is running, or it's not on the Python path.","error":"error: Cannot find module named 'flask_migrate'"}]}