Skip to content

Commit 6906dad

Browse files
pgjonessentrivana
andauthored
Support Quart 0.19 onwards (#2403)
* Support Quart 0.19 onwards Quart 0.19 is based on Flask and hence no longer has a Scaffold class, instead Flask's should be used. --------- Co-authored-by: Ivana Kellyerova <[email protected]>
1 parent 0452535 commit 6906dad

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

sentry_sdk/integrations/quart.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
request,
3939
websocket,
4040
)
41-
from quart.scaffold import Scaffold # type: ignore
4241
from quart.signals import ( # type: ignore
4342
got_background_exception,
4443
got_request_exception,
@@ -49,6 +48,12 @@
4948
from quart.utils import is_coroutine_function # type: ignore
5049
except ImportError:
5150
raise DidNotEnable("Quart is not installed")
51+
else:
52+
# Quart 0.19 is based on Flask and hence no longer has a Scaffold
53+
try:
54+
from quart.scaffold import Scaffold # type: ignore
55+
except ImportError:
56+
from flask.sansio.scaffold import Scaffold # type: ignore
5257

5358
TRANSACTION_STYLE_VALUES = ("endpoint", "url")
5459

tests/integrations/quart/test_quart.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
@pytest_asyncio.fixture
3333
async def app():
3434
app = Quart(__name__)
35-
app.debug = True
36-
app.config["TESTING"] = True
35+
app.debug = False
36+
app.config["TESTING"] = False
3737
app.secret_key = "haha"
3838

3939
auth_manager.init_app(app)
@@ -123,22 +123,15 @@ async def test_transaction_style(
123123

124124

125125
@pytest.mark.asyncio
126-
@pytest.mark.parametrize("debug", (True, False))
127-
@pytest.mark.parametrize("testing", (True, False))
128126
async def test_errors(
129127
sentry_init,
130128
capture_exceptions,
131129
capture_events,
132130
app,
133-
debug,
134-
testing,
135131
integration_enabled_params,
136132
):
137133
sentry_init(debug=True, **integration_enabled_params)
138134

139-
app.debug = debug
140-
app.testing = testing
141-
142135
@app.route("/")
143136
async def index():
144137
1 / 0
@@ -323,9 +316,6 @@ def foo():
323316
async def test_500(sentry_init, capture_events, app):
324317
sentry_init(integrations=[quart_sentry.QuartIntegration()])
325318

326-
app.debug = False
327-
app.testing = False
328-
329319
@app.route("/")
330320
async def index():
331321
1 / 0
@@ -349,9 +339,6 @@ async def error_handler(err):
349339
async def test_error_in_errorhandler(sentry_init, capture_events, app):
350340
sentry_init(integrations=[quart_sentry.QuartIntegration()])
351341

352-
app.debug = False
353-
app.testing = False
354-
355342
@app.route("/")
356343
async def index():
357344
raise ValueError()

tox.ini

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ envlist =
134134

135135
# Quart
136136
{py3.7,py3.8,py3.9,py3.10,py3.11}-quart-v{0.16,0.17,0.18}
137+
{py3.8,py3.9,py3.10,py3.11}-quart-v{0.19}
137138

138139
# Redis
139140
{py2.7,py3.7,py3.8,py3.9,py3.10,py3.11}-redis
@@ -403,14 +404,17 @@ deps =
403404
# Quart
404405
quart: quart-auth
405406
quart: pytest-asyncio
406-
quart: werkzeug<3.0.0
407407
quart-v0.16: blinker<1.6
408408
quart-v0.16: jinja2<3.1.0
409409
quart-v0.16: Werkzeug<2.1.0
410-
quart-v0.17: blinker<1.6
411410
quart-v0.16: quart>=0.16.1,<0.17.0
411+
quart-v0.17: Werkzeug<3.0.0
412+
quart-v0.17: blinker<1.6
412413
quart-v0.17: quart>=0.17.0,<0.18.0
414+
quart-v0.18: Werkzeug<3.0.0
413415
quart-v0.18: quart>=0.18.0,<0.19.0
416+
quart-v0.19: Werkzeug>=3.0.0
417+
quart-v0.19: quart>=0.19.0,<0.20.0
414418

415419
# Requests
416420
requests: requests>=2.0

0 commit comments

Comments
 (0)