mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Name "db.Model" is not defined in Mypy but is defined in SQLAlchemy function from flask_sqlalchemy package in VSCode

Open lulunac27a opened this issue 4 months ago • 0 comments

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

lulunac27a avatar Oct 11 '24 02:10 lulunac27a