mypy
mypy copied to clipboard
Name "db.Model" is not defined in Mypy but is defined in SQLAlchemy function from flask_sqlalchemy package in VSCode
Bug Report
(A clear and concise description of what the bug is.)
To Reproduce
from flask import Flask, render_template, redirect, url_for
from flask_sqlalchemy import SQLAlchemy
import math
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///users.db"
db = SQLAlchemy(app)
class User(db.Model):
Expected Behavior No errors because db.Model is in the SQLAlchemy class of flask_sqlalchemy, so the official Python extensions shows (variable) db: SQLAlchemy when I highlight the error squiggle in VSCode.
Actual Behavior Name "db.Model" is not defined
Your Environment
- Mypy version used: 1.11.2
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini
(and other config files): - Python version used: 3.9