You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6KB

  1. import typing as t
  2. if t.TYPE_CHECKING:
  3. from _typeshed.wsgi import WSGIApplication # noqa: F401
  4. from werkzeug.datastructures import Headers # noqa: F401
  5. from .wrappers import Response # noqa: F401
  6. # The possible types that are directly convertible or are a Response object.
  7. ResponseValue = t.Union[
  8. "Response",
  9. t.AnyStr,
  10. t.Dict[str, t.Any], # any jsonify-able dict
  11. t.Generator[t.AnyStr, None, None],
  12. ]
  13. StatusCode = int
  14. # the possible types for an individual HTTP header
  15. HeaderName = str
  16. HeaderValue = t.Union[str, t.List[str], t.Tuple[str, ...]]
  17. # the possible types for HTTP headers
  18. HeadersValue = t.Union[
  19. "Headers", t.Dict[HeaderName, HeaderValue], t.List[t.Tuple[HeaderName, HeaderValue]]
  20. ]
  21. # The possible types returned by a route function.
  22. ResponseReturnValue = t.Union[
  23. ResponseValue,
  24. t.Tuple[ResponseValue, HeadersValue],
  25. t.Tuple[ResponseValue, StatusCode],
  26. t.Tuple[ResponseValue, StatusCode, HeadersValue],
  27. "WSGIApplication",
  28. ]
  29. AppOrBlueprintKey = t.Optional[str] # The App key is None, whereas blueprints are named
  30. AfterRequestCallable = t.Callable[["Response"], "Response"]
  31. BeforeRequestCallable = t.Callable[[], None]
  32. ErrorHandlerCallable = t.Callable[[Exception], ResponseReturnValue]
  33. TeardownCallable = t.Callable[[t.Optional[BaseException]], "Response"]
  34. TemplateContextProcessorCallable = t.Callable[[], t.Dict[str, t.Any]]
  35. TemplateFilterCallable = t.Callable[[t.Any], str]
  36. TemplateGlobalCallable = t.Callable[[], t.Any]
  37. TemplateTestCallable = t.Callable[[t.Any], bool]
  38. URLDefaultCallable = t.Callable[[str, dict], None]
  39. URLValuePreprocessorCallable = t.Callable[[t.Optional[str], t.Optional[dict]], None]