Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lulunac27a opened this issue Oct 11, 2024 · 0 comments
Labels
bug mypy got something wrong

Comments

@lulunac27a
Copy link

lulunac27a commented Oct 11, 2024

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 lulunac27a added the bug mypy got something wrong label Oct 11, 2024
@lulunac27a lulunac27a changed the title Name "db.Model" is not defined but is defined in SQLAlchemy function from flask_sqlalchemy Name "db.Model" is not defined in Mypy but is defined in SQLAlchemy function from flask_sqlalchemy package Oct 11, 2024
@lulunac27a lulunac27a changed the title Name "db.Model" is not defined in Mypy but is defined in SQLAlchemy function from flask_sqlalchemy package Name "db.Model" is not defined in Mypy but is defined in SQLAlchemy function from flask_sqlalchemy package in VSCode Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant