Home / File/ typing.py — flask Source File

typing.py — flask Source File

Architecture documentation for typing.py, a python file in the flask codebase. 5 imports, 15 dependents.

File python ApplicationCore Scaffolding 5 imports 15 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  d3e9218c_bf0a_48f5_15c9_90795af6f3ac["typing.py"]
  35e18c72_5163_709e_ecef_3bb55bc800bb["collections.abc"]
  d3e9218c_bf0a_48f5_15c9_90795af6f3ac --> 35e18c72_5163_709e_ecef_3bb55bc800bb
  d3e9218c_bf0a_48f5_15c9_90795af6f3ac["typing.py"]
  d3e9218c_bf0a_48f5_15c9_90795af6f3ac --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  1ad2da66_ce90_c861_6017_4d5488b4867a["_typeshed.wsgi"]
  d3e9218c_bf0a_48f5_15c9_90795af6f3ac --> 1ad2da66_ce90_c861_6017_4d5488b4867a
  ae30ebb5_dd77_01f7_0e7b_30adb2f3df4e["werkzeug.datastructures"]
  d3e9218c_bf0a_48f5_15c9_90795af6f3ac --> ae30ebb5_dd77_01f7_0e7b_30adb2f3df4e
  151410f6_1bb7_5cc2_b5a2_1bc32b945b6e["werkzeug.sansio.response"]
  d3e9218c_bf0a_48f5_15c9_90795af6f3ac --> 151410f6_1bb7_5cc2_b5a2_1bc32b945b6e
  9612cfdd_2178_92c0_2ed7_16ebb0c72901["app.py"]
  9612cfdd_2178_92c0_2ed7_16ebb0c72901 --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  ebbad164_1651_bd83_3f3b_106e2ce78240["blueprints.py"]
  ebbad164_1651_bd83_3f3b_106e2ce78240 --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  a96499c3_f8a9_e782_f156_1c1ee4a86c69["cli.py"]
  a96499c3_f8a9_e782_f156_1c1ee4a86c69 --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  2e858a02_7725_54fd_8d55_a9c969ab89bf["config.py"]
  2e858a02_7725_54fd_8d55_a9c969ab89bf --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  49f8280b_d7dc_110c_b848_8e7e56bfb19b["ctx.py"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  7fa0faba_d854_797c_b6bd_20820e905793["debughelpers.py"]
  7fa0faba_d854_797c_b6bd_20820e905793 --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  9cff5a62_7dbb_7b80_cf3c_128a7a2fda28["globals.py"]
  9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  881f9803_28d6_7d77_c8d7_1098b41ccf84["helpers.py"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  3bd07725_f871_e2d4_476f_62e7d3f6e96a["logging.py"]
  3bd07725_f871_e2d4_476f_62e7d3f6e96a --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  f793a407_79ea_667a_f29e_29bbf57c781f["sessions.py"]
  f793a407_79ea_667a_f29e_29bbf57c781f --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  style d3e9218c_bf0a_48f5_15c9_90795af6f3ac fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import collections.abc as cabc
import typing as t

if t.TYPE_CHECKING:  # pragma: no cover
    from _typeshed.wsgi import WSGIApplication  # noqa: F401
    from werkzeug.datastructures import Headers  # noqa: F401
    from werkzeug.sansio.response import Response  # noqa: F401

# The possible types that are directly convertible or are a Response object.
ResponseValue = t.Union[
    "Response",
    str,
    bytes,
    list[t.Any],
    # Only dict is actually accepted, but Mapping allows for TypedDict.
    t.Mapping[str, t.Any],
    t.Iterator[str],
    t.Iterator[bytes],
    cabc.AsyncIterable[str],  # for Quart, until App is generic.
    cabc.AsyncIterable[bytes],
]

# the possible types for an individual HTTP header
HeaderValue = str | list[str] | tuple[str, ...]

# the possible types for HTTP headers
HeadersValue = t.Union[
    "Headers",
    t.Mapping[str, HeaderValue],
    t.Sequence[tuple[str, HeaderValue]],
]

# The possible types returned by a route function.
ResponseReturnValue = t.Union[
    ResponseValue,
    tuple[ResponseValue, HeadersValue],
    tuple[ResponseValue, int],
    tuple[ResponseValue, int, HeadersValue],
    "WSGIApplication",
]

# Allow any subclass of werkzeug.Response, such as the one from Flask,
# as a callback argument. Using werkzeug.Response directly makes a
# callback annotated with flask.Response fail type checking.
ResponseClass = t.TypeVar("ResponseClass", bound="Response")

AppOrBlueprintKey = str | None  # The App key is None, whereas blueprints are named
AfterRequestCallable = (
    t.Callable[[ResponseClass], ResponseClass]
    | t.Callable[[ResponseClass], t.Awaitable[ResponseClass]]
)
BeforeFirstRequestCallable = t.Callable[[], None] | t.Callable[[], t.Awaitable[None]]
BeforeRequestCallable = (
    t.Callable[[], ResponseReturnValue | None]
    | t.Callable[[], t.Awaitable[ResponseReturnValue | None]]
)
ShellContextProcessorCallable = t.Callable[[], dict[str, t.Any]]
TeardownCallable = (
    t.Callable[[BaseException | None], None]
    | t.Callable[[BaseException | None], t.Awaitable[None]]
)
TemplateContextProcessorCallable = (
    t.Callable[[], dict[str, t.Any]] | t.Callable[[], t.Awaitable[dict[str, t.Any]]]
)
TemplateFilterCallable = t.Callable[..., t.Any]
TemplateGlobalCallable = t.Callable[..., t.Any]
TemplateTestCallable = t.Callable[..., bool]
URLDefaultCallable = t.Callable[[str, dict[str, t.Any]], None]
URLValuePreprocessorCallable = t.Callable[[str | None, dict[str, t.Any] | None], None]

# This should take Exception, but that either breaks typing the argument
# with a specific exception, or decorating multiple times with different
# exceptions (and using a union type on the argument).
# https://github.com/pallets/flask/issues/4095
# https://github.com/pallets/flask/issues/4295
# https://github.com/pallets/flask/issues/4297
ErrorHandlerCallable = (
    t.Callable[[t.Any], ResponseReturnValue]
    | t.Callable[[t.Any], t.Awaitable[ResponseReturnValue]]
)

RouteCallable = (
    t.Callable[..., ResponseReturnValue]
    | t.Callable[..., t.Awaitable[ResponseReturnValue]]
)

Subdomains

Functions

Dependencies

  • _typeshed.wsgi
  • collections.abc
  • typing.py
  • werkzeug.datastructures
  • werkzeug.sansio.response

Frequently Asked Questions

What does typing.py do?
typing.py is a source file in the flask codebase, written in python. It belongs to the ApplicationCore domain, Scaffolding subdomain.
What functions are defined in typing.py?
typing.py defines 1 function(s): _typeshed.
What does typing.py depend on?
typing.py imports 5 module(s): _typeshed.wsgi, collections.abc, typing.py, werkzeug.datastructures, werkzeug.sansio.response.
What files import typing.py?
typing.py is imported by 15 file(s): app.py, blueprints.py, cli.py, config.py, ctx.py, debughelpers.py, globals.py, helpers.py, and 7 more.
Where is typing.py in the architecture?
typing.py is located at src/flask/typing.py (domain: ApplicationCore, subdomain: Scaffolding, directory: src/flask).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free