Skip to content

Flask-SQLAlchemy and Mypy #1389

Closed Answered by davidism
tungol asked this question in Q&A
Discussion options

You must be logged in to vote

Your idea, as with the others, is not correct. from flask_sqlalchemy.model import Model is not a SQLAlchemy declarative base class, it's the plain Python base class, so you're not getting any of SQLAlchemy's type checking support. Defining __init__(specific, args, names) defeats the entire purpose of SQLAlchemy's **kwargs support and requires doing so for every model individually.

Flask-SQLAlchemy-Lite is available to transition to. It manages engine config and sessions, but otherwise is plain SQLAlchemy, meaning all typing works.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by davidism
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants