Merge remote-tracking branch 'upstream/2.0.x'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Adrian Moennich · committed by Adrian Moennich · parents 7161776, 8e589da · Browse files · 5 files·+21 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+21 added−10 removed
- other:+21 added−10 removed
Provenance
- Commit
6f5870a- Tree
c516b27- Author
Adrian Moennich <adrian@planetcoding.net>- Committer
Adrian Moennich <adrian@planetcoding.net>- Parent 1
7161776- Parent 2
8e589da
5 files changed+21 added−10 removed
modified:docs/tutorial/index.rst+1 added-1 removed
53 unmodified lines54 55 .. image:: flaskr_edit.png56 :align: center57 :class: screenshot58- :alt: screenshot of login page58+ :alt: screenshot of edit page59 60 :gh:`The tutorial project is available as an example in the Flask61 repository <examples/tutorial>`, if you want to compare your project62 with the final product as you follow the tutorial.2 unmodified linesmodified:src/flask/app.py+5 added-2 removed
57 unmodified lines58 from .signals import request_tearing_down59 from .templating import DispatchingJinjaLoader60 from .templating import Environment61 from .typing import AfterRequestCallable62+from .typing import BeforeFirstRequestCallable63 from .typing import BeforeRequestCallable64 from .typing import ErrorHandlerCallable65 from .typing import ResponseReturnValue66 from .typing import TeardownCallable372 unmodified lines439 #: first request to this instance. To register a function, use the440 #: :meth:`before_first_request` decorator.441 #:442 #: .. versionadded:: 0.8442- self.before_first_request_funcs: t.List[BeforeRequestCallable] = []443+ self.before_first_request_funcs: t.List[BeforeFirstRequestCallable] = []444 445 #: A list of functions that are called when the application context446 #: is destroyed. Since the application context is also torn down447 #: if the request ends this is the place to store code that disconnects763 unmodified lines1211 """1212 self.jinja_env.globals[name or f.__name__] = f1213 1214 @setupmethod1214- def before_first_request(self, f: BeforeRequestCallable) -> BeforeRequestCallable:1215+ def before_first_request(1216+ self, f: BeforeFirstRequestCallable1217+ ) -> BeforeFirstRequestCallable:1218 """Registers a function to be run before the first request to this1219 instance of the application.1220 1221 The function will be called without any arguments and its return870 unmodified linesmodified:src/flask/blueprints.py+3 added-2 removed
4 unmodified lines5 from .scaffold import _endpoint_from_view_func6 from .scaffold import _sentinel7 from .scaffold import Scaffold8 from .typing import AfterRequestCallable9+from .typing import BeforeFirstRequestCallable10 from .typing import BeforeRequestCallable11 from .typing import ErrorHandlerCallable12 from .typing import TeardownCallable13 from .typing import TemplateContextProcessorCallable523 unmodified lines537 )538 return f539 540 def before_app_first_request(540- self, f: BeforeRequestCallable541- ) -> BeforeRequestCallable:541+ self, f: BeforeFirstRequestCallable542+ ) -> BeforeFirstRequestCallable:543 """Like :meth:`Flask.before_first_request`. Such a function is544 executed before the first request to the application.545 """546 self.record_once(lambda s: s.app.before_first_request_funcs.append(f))58 unmodified linesmodified:src/flask/typing.py+6 added-5 removed
33 unmodified lines34 ]35 36 AppOrBlueprintKey = t.Optional[str] # The App key is None, whereas blueprints are named37 AfterRequestCallable = t.Callable[["Response"], "Response"]38-BeforeRequestCallable = t.Callable[[], None]38+BeforeFirstRequestCallable = t.Callable[[], None]39+BeforeRequestCallable = t.Callable[[], t.Optional[ResponseReturnValue]]40 ErrorHandlerCallable = t.Callable[[Exception], ResponseReturnValue]40-TeardownCallable = t.Callable[[t.Optional[BaseException]], "Response"]41+TeardownCallable = t.Callable[[t.Optional[BaseException]], None]42 TemplateContextProcessorCallable = t.Callable[[], t.Dict[str, t.Any]]42-TemplateFilterCallable = t.Callable[[t.Any], str]43-TemplateGlobalCallable = t.Callable[[], t.Any]44-TemplateTestCallable = t.Callable[[t.Any], bool]43+TemplateFilterCallable = t.Callable[..., t.Any]44+TemplateGlobalCallable = t.Callable[..., t.Any]45+TemplateTestCallable = t.Callable[..., bool]46 URLDefaultCallable = t.Callable[[str, dict], None]47 URLValuePreprocessorCallable = t.Callable[[t.Optional[str], t.Optional[dict]], None]modified:CHANGES.rst+6 added
11 unmodified lines12 -------------13 14 Unreleased15 16+- Fix type annotation for ``teardown_request``. :issue:`4093`17+- Fix type annotation for ``before_request`` and ``before_app_request``18+ decorators. :issue:`4104`19+- Fixed the issue where typing requires template global20+ decorators to accept functions with no arguments. :issue:`4098`21 22+23 Version 2.0.124 -------------25 26 Released 2021-05-211152 unmodified lines