Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/flask/globals.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from __future__ import annotations
3import typing as t
4from contextvars import ContextVar
6from werkzeug.local import LocalProxy
8if t.TYPE_CHECKING: # pragma: no cover
9 from .app import Flask
10 from .ctx import _AppCtxGlobals
11 from .ctx import AppContext
12 from .ctx import RequestContext
13 from .sessions import SessionMixin
14 from .wrappers import Request
17_no_app_msg = """\
18Working outside of application context.
20This typically means that you attempted to use functionality that needed
21the current application. To solve this, set up an application context
22with app.app_context(). See the documentation for more information.\
23"""
24_cv_app: ContextVar[AppContext] = ContextVar("flask.app_ctx")
25app_ctx: AppContext = LocalProxy( # type: ignore[assignment]
26 _cv_app, unbound_message=_no_app_msg
27)
28current_app: Flask = LocalProxy( # type: ignore[assignment]
29 _cv_app, "app", unbound_message=_no_app_msg
30)
31g: _AppCtxGlobals = LocalProxy( # type: ignore[assignment]
32 _cv_app, "g", unbound_message=_no_app_msg
33)
35_no_req_msg = """\
36Working outside of request context.
38This typically means that you attempted to use functionality that needed
39an active HTTP request. Consult the documentation on testing for
40information about how to avoid this problem.\
41"""
42_cv_request: ContextVar[RequestContext] = ContextVar("flask.request_ctx")
43request_ctx: RequestContext = LocalProxy( # type: ignore[assignment]
44 _cv_request, unbound_message=_no_req_msg
45)
46request: Request = LocalProxy( # type: ignore[assignment]
47 _cv_request, "request", unbound_message=_no_req_msg
48)
49session: SessionMixin = LocalProxy( # type: ignore[assignment]
50 _cv_request, "session", unbound_message=_no_req_msg
51)