File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ Unreleased
2929 - ``add_etags `` is renamed to ``etag ``.
3030 - ``filename `` is renamed to ``path ``.
3131
32+ - The ``RequestContext.g `` property is deprecated. Use ``g `` directly
33+ or ``AppContext.g `` instead. :issue: `3898 `
3234- ``copy_current_request_context `` can decorate async functions.
3335 :pr: `4303 `
3436
Original file line number Diff line number Diff line change @@ -332,11 +332,29 @@ def __init__(
332332 self ._after_request_functions : t .List [AfterRequestCallable ] = []
333333
334334 @property
335- def g (self ) -> AppContext :
335+ def g (self ) -> _AppCtxGlobals :
336+ import warnings
337+
338+ warnings .warn (
339+ "Accessing 'g' on the request context is deprecated and"
340+ " will be removed in Flask 2.2. Access `g` directly or from"
341+ "the application context instead." ,
342+ DeprecationWarning ,
343+ stacklevel = 2 ,
344+ )
336345 return _app_ctx_stack .top .g
337346
338347 @g .setter
339- def g (self , value : AppContext ) -> None :
348+ def g (self , value : _AppCtxGlobals ) -> None :
349+ import warnings
350+
351+ warnings .warn (
352+ "Setting 'g' on the request context is deprecated and"
353+ " will be removed in Flask 2.2. Set it on the application"
354+ " context instead." ,
355+ DeprecationWarning ,
356+ stacklevel = 2 ,
357+ )
340358 _app_ctx_stack .top .g = value
341359
342360 def copy (self ) -> "RequestContext" :
You can’t perform that action at this time.
0 commit comments