error: Incompatible types in assignment (expression has type "Type[Any]", variable has type "DefaultMeta") [assignment]
error: Variable "application.models.BaseModel" is not valid as a type [valid-type]
Previously it worked when it was declared like this
from sqlalchemy.ext.declarative import DeclarativeMeta
BaseModel: DeclarativeMeta = db.Model
But after packages update I'm seeing that error again. I've read from here that DeclarativeMeta was moved to sqlalchemy.orm
, but when tried
from sqlalchemy.orm import DeclarativeMeta
BaseModel: DeclarativeMeta = db.Model
I can still see the error. I've also noticed that sometimes flask_sqlalchemy
is used
from flask_sqlalchemy.model import DefaultMeta
BaseModel: DefaultMeta = db.Model
but that makes no difference I'm still seeing that mypy error.
Current version of packages is this:
mypy │ 1.1.1
SQLAlchemy │ 2.0.6
Flask-SQLAlchemy │ 3.0.3
Does somebody know how write this so mypy is happy? I can always make mypy ignore it, but I somehow want to have this right.
# type: ignore[assignment]
– Tucky