Fix type annotation for before_request and before_app_request decorators

This commit is contained in:
Marat Sharafutdinov 2021-05-25 18:04:41 +03:00 committed by Phil Jones
parent f7adb2c813
commit a960236117
4 changed files with 13 additions and 6 deletions

View file

@ -59,6 +59,7 @@ from .signals import request_tearing_down
from .templating import DispatchingJinjaLoader
from .templating import Environment
from .typing import AfterRequestCallable
from .typing import BeforeFirstRequestCallable
from .typing import BeforeRequestCallable
from .typing import ErrorHandlerCallable
from .typing import ResponseReturnValue
@ -439,7 +440,7 @@ class Flask(Scaffold):
#: :meth:`before_first_request` decorator.
#:
#: .. versionadded:: 0.8
self.before_first_request_funcs: t.List[BeforeRequestCallable] = []
self.before_first_request_funcs: t.List[BeforeFirstRequestCallable] = []
#: A list of functions that are called when the application context
#: is destroyed. Since the application context is also torn down
@ -1211,7 +1212,9 @@ class Flask(Scaffold):
self.jinja_env.globals[name or f.__name__] = f
@setupmethod
def before_first_request(self, f: BeforeRequestCallable) -> BeforeRequestCallable:
def before_first_request(
self, f: BeforeFirstRequestCallable
) -> BeforeFirstRequestCallable:
"""Registers a function to be run before the first request to this
instance of the application.