2

I am running pytest in flask and getting following deprecation warning: the application is pretty simple using flask_jwt_extended for authentication.

\venv\lib\site-packages\flask_jwt_extended\view_decorators.py:11: DeprecationWarning: '_reque
st_ctx_stack' is deprecated and will be removed in Flask 2.3.
from flask import _request_ctx_stack

Currently it is not affecting my application but should I take any steps to remediate this ?

JayantSeth
  • 348
  • 1
  • 12
  • 1
    Checking the flask changelog lead to the following https://github.com/pallets/flask/pull/4682 I think in there should be a descritption on how to replace the deprecated context? – dosas Aug 14 '22 at 09:53

1 Answers1

0

the comment didn't point directly to the answer, at least for me. for me what works is documented here. data:: _request_ctx_stack is now data:: flask.globals.request_ctx. sample code now looks like

from flask.globals import request_ctx

def get_request_details():
    ctx = request_ctx  # previously was _request_ctx_stack.top
    return {
        'request': "{} {} {}".format(
            ctx.request.method,
            ctx.request.url,
            ctx.request.environ.get('SERVER_PROTOCOL')
    }

hope that helps.