add errorhandler type check tests

This commit is contained in:
David Lord 2022-06-05 15:44:28 -07:00
parent 81be290ec8
commit 3351a8677e
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
4 changed files with 40 additions and 4 deletions

View file

@ -561,12 +561,14 @@ class Blueprint(Scaffold):
)
return f
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