Skip to content

Commit

Permalink
Merge pull request #249 from woutervanoorschot/247-solve-deprecation-…
Browse files Browse the repository at this point in the history
…flask-sqlalchemy-3

Solve deprecation flask sqlalchemy 3
  • Loading branch information
sirosen authored Feb 6, 2023
2 parents 13f6739 + 0997e9d commit fcd91d1
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ repos:
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py36-plus]
args: [--py37-plus]
- repo: https://github.com/python/black
rev: 22.1.0
rev: 22.3.0
hooks:
- id: black
language_version: python3
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear==22.1.11]
additional_dependencies: [flake8-bugbear==22.1.11, importlib-metadata==4.12.0]
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies: [black==22.1.0]
additional_dependencies: [black==22.3.0]
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
toxenvs:
- lint

- py36-marshmallow3
- py37-marshmallow3
- py38-marshmallow3
- py39-marshmallow3
- py310-marshmallow3

- py39-lowest
- py39-marshmallowdev
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

EXTRAS_REQUIRE = {
"sqlalchemy": [
"flask-sqlalchemy",
"flask-sqlalchemy>=3.0.0",
"marshmallow-sqlalchemy>=0.24.0",
],
"docs": ["marshmallow-sqlalchemy>=0.13.0", "Sphinx==3.5.4", "sphinx-issues==1.2.0"],
"docs": ["marshmallow-sqlalchemy>=0.13.0", "Sphinx==4.5.0", "sphinx-issues==3.0.1"],
"lint": [
"flake8==3.9.2",
"flake8-bugbear==20.11.1",
Expand Down Expand Up @@ -59,7 +59,7 @@ def read(fname):
license="MIT",
zip_safe=False,
keywords="flask-marshmallow",
python_requires=">=3.6",
python_requires=">=3.7",
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
Expand Down
2 changes: 1 addition & 1 deletion src/flask_marshmallow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def init_app(self, app):

# If using Flask-SQLAlchemy, attach db.session to SQLAlchemySchema
if has_sqla and "sqlalchemy" in app.extensions:
db = app.extensions["sqlalchemy"].db
db = app.extensions["sqlalchemy"]
if self.SQLAlchemySchema:
self.SQLAlchemySchema.OPTIONS_CLASS.session = db.session
if self.SQLAlchemyAutoSchema:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

from flask import Flask, url_for
from werkzeug.wrappers import BaseResponse
from werkzeug.wrappers import Response

from flask_marshmallow import Marshmallow
from tests.markers import flask_1_req
Expand Down Expand Up @@ -29,7 +29,7 @@ def test_schema(app, schemas, mockauthor):
def test_jsonify_instance(app, schemas, mockauthor):
s = schemas.AuthorSchema()
resp = s.jsonify(mockauthor)
assert isinstance(resp, BaseResponse)
assert isinstance(resp, Response)
assert resp.content_type == "application/json"
obj = json.loads(resp.get_data(as_text=True))
assert isinstance(obj, dict)
Expand All @@ -39,7 +39,7 @@ def test_jsonify_instance(app, schemas, mockauthor):
def test_jsonify_collection(app, schemas, mockauthorlist):
s = schemas.AuthorSchema()
resp = s.jsonify(mockauthorlist, many=True)
assert isinstance(resp, BaseResponse)
assert isinstance(resp, Response)
assert resp.content_type == "application/json"
obj = json.loads(resp.get_data(as_text=True))
assert isinstance(obj, list)
Expand All @@ -49,7 +49,7 @@ def test_jsonify_collection(app, schemas, mockauthorlist):
def test_jsonify_collection_via_schema_attr(app, schemas, mockauthorlist):
s = schemas.AuthorSchema(many=True)
resp = s.jsonify(mockauthorlist)
assert isinstance(resp, BaseResponse)
assert isinstance(resp, Response)
assert resp.content_type == "application/json"
obj = json.loads(resp.get_data(as_text=True))
assert isinstance(obj, list)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_sqla.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from flask import Flask, url_for
from flask_sqlalchemy import SQLAlchemy
from werkzeug.wrappers import BaseResponse
from werkzeug.wrappers import Response

from flask_marshmallow import Marshmallow
from flask_marshmallow.sqla import HyperlinkRelated
Expand Down Expand Up @@ -130,7 +130,7 @@ class Meta:
assert book_result["author_id"] == book.author_id

resp = author_schema.jsonify(author)
assert isinstance(resp, BaseResponse)
assert isinstance(resp, Response)

@requires_sqlalchemyschema
def test_can_declare_sqla_auto_schemas(self, extma, models, db):
Expand Down Expand Up @@ -168,7 +168,7 @@ class Meta:
assert book_result["author_id"] == book.author_id

resp = author_schema.jsonify(author)
assert isinstance(resp, BaseResponse)
assert isinstance(resp, Response)

@requires_sqlalchemyschema
def test_hyperlink_related_field(self, extma, models, db, extapp):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist=
lint
py{36,37,38,39}-marshmallow3
py{37,38,39,310}-marshmallow3
py39-lowest
py39-marshmallowdev
docs
Expand Down

0 comments on commit fcd91d1

Please sign in to comment.