Skip to content

Commit 4b58496

Browse files
authored
Fix mypy error (#351)
1 parent 0153c86 commit 4b58496

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/flask_marshmallow/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ def init_app(self, app: "Flask"):
134134
# If using Flask-SQLAlchemy, attach db.session to SQLAlchemySchema
135135
if has_sqla and "sqlalchemy" in app.extensions:
136136
db = app.extensions["sqlalchemy"]
137-
self.SQLAlchemySchema.OPTIONS_CLASS.session = db.session
138-
self.SQLAlchemyAutoSchema.OPTIONS_CLASS.session = db.session
137+
SQLAlchemySchemaOpts = typing.cast(
138+
sqla.SQLAlchemySchemaOpts, self.SQLAlchemySchema.OPTIONS_CLASS
139+
)
140+
SQLAlchemySchemaOpts.session = db.session
141+
SQLAlchemyAutoSchemaOpts = typing.cast(
142+
sqla.SQLAlchemyAutoSchemaOpts, self.SQLAlchemySchema.OPTIONS_CLASS
143+
)
144+
SQLAlchemyAutoSchemaOpts.session = db.session
139145
app.extensions[EXTENSION_NAME] = self

0 commit comments

Comments
 (0)