Merge branch '2.1.x'

This commit is contained in:
David Lord 2022-06-06 09:30:30 -07:00
commit 7a2d5fb6df
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
11 changed files with 203 additions and 64 deletions

View file

@ -392,7 +392,7 @@ class Blueprint(Scaffold):
self,
rule: str,
endpoint: t.Optional[str] = None,
view_func: t.Optional[t.Callable] = None,
view_func: t.Optional[ft.ViewCallable] = None,
provide_automatic_options: t.Optional[bool] = None,
**options: t.Any,
) -> None:
@ -580,12 +580,14 @@ class Blueprint(Scaffold):
return f
@setupmethod
def app_errorhandler(self, code: t.Union[t.Type[Exception], int]) -> t.Callable:
def app_errorhandler(
self, code: t.Union[t.Type[Exception], int]
) -> t.Callable[[ft.ErrorHandlerDecorator], ft.ErrorHandlerDecorator]:
"""Like :meth:`Flask.errorhandler` but for a blueprint. This
handler is used for all requests, even if outside of the blueprint.
"""
def decorator(f: ft.ErrorHandlerCallable) -> ft.ErrorHandlerCallable:
def decorator(f: ft.ErrorHandlerDecorator) -> ft.ErrorHandlerDecorator:
self.record_once(lambda s: s.app.errorhandler(code)(f))
return f