-
-
Notifications
You must be signed in to change notification settings - Fork 900
Closed as not planned
Description
mypy currently does not correctly handle inheritance from a class attribute with a model - db.Model
:
error: Name "db.Model" is not defined [name-defined]
According on the related bugreport, this issue will not be resolved anytime soon.
So, there is working workaround:
import typing as t
from flask_sqlalchemy import SQLAlchemy
from flask_sqlalchemy.model import Model as BaseModel
db = SQLAlchemy()
if t.TYPE_CHECKING:
class Model(BaseModel):
pass
else:
Model = db.Model
class MyModel(Model):
pass
It will be useful if this workaround will be mentioned in documentation.
I can make changes to the documentation myself if I get the approval.
Metadata
Metadata
Assignees
Labels
No labels