python / python/typeshed

Flask-SQLAlchemy-Lite support for flask-migrate

Open
#12,121 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stubs: improvement
Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

Flask-SQLAlchemy-Lite was just released which is intended to be a replacement for Flask-SQLAlchemy.
https://flask-sqlalchemy-lite.readthedocs.io/en/stable/

With that there is then a type conflict with flask_migrate:
https://github.com/python/typeshed/blob/main/stubs/Flask-Migrate/flask_migrate/__init__.pyi#L52

It expects flask_sqlalchemy.extension.SQLAlchemy, but flask_sqlalchemy_lite._extension.SQLAlchemy is now a compatible alternative

I'm pretty new to python so I'm not sure what the best approach to allow the flask_migrate typings to allow both.

Would it work to:

# ...
from flask_sqlalchemy import SQLAlchemy
from flask_sqlalchemy_lite import SQLAlchemy as SQLAlchemyLite
# ...
class Migrate:
    configure_callbacks: list[_ConfigureCallback]
    db: SQLAlchemy | SQLAlchemyLite | None
    # ...

Or is there a better approach?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Flask-Migrate stub at stubs/Flask-Migrate/flask_migrate/init.pyi, especially the SQLAlchemy type around line 52, and review the linked Flask-SQLAlchemy-Lite documentation. Determine a typing approach that accepts both SQLAlchemy implementations without introducing an import or compatibility conflict; done means the stub accurately supports either integration.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python, sqlalchemy
Domain
backend, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.