Open
Description
Pylance / Pyright reports a type error when instantiating a Model subclass with parameters:
Expected no arguments to "User" constructor
Minimal example:
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import BigInteger, String
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
class Base(DeclarativeBase):
pass
db = SQLAlchemy(model_class=Base)
class User(db.Model):
__tablename__ = "users"
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
username: Mapped[str] = mapped_column(String(255), unique=True, nullable=False)
def test():
user = User(username="x")
print(user)
I expected there to be no type errors, since this operation is supported within SQLAlchemy.
Environment:
- Python version: 3.10.13
- Flask-SQLAlchemy version: 3.1.1
- SQLAlchemy version: 2.0.18
Metadata
Metadata
Assignees
Labels
No labels