Improve decorator factory type signatures
Before adoption: this commit came in with the history the project adopted, so no landing records it.
These changes are required to preserve the type signatures of the created decorators.
authored by Alex Hedges · committed by Phil Jones · parent 8796b2a · Browse files · 3 files·+19 added−7 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+19 added−7 removed
- other:+19 added−7 removed
Provenance
- Commit
10a36cb- Tree
695d4a1- Author
Alex Hedges <ahedges@isi.edu>- Committer
Phil Jones <philip.graham.jones@googlemail.com>- Parent
8796b2a
3 files changed+19 added−7 removed
modified:src/flask/app.py+9 added-3 removed
1087 unmodified lines1088 )1089 self.view_functions[endpoint] = view_func1090 1091 @setupmethod1092- def template_filter(self, name: t.Optional[str] = None) -> t.Callable:1092+ def template_filter(1093+ self, name: t.Optional[str] = None1094+ ) -> t.Callable[[TemplateFilterCallable], TemplateFilterCallable]:1095 """A decorator that is used to register custom template filter.1096 You can specify a name for the filter, otherwise the function1097 name will be used. Example::1098 23 unmodified lines1122 """1123 self.jinja_env.filters[name or f.__name__] = f1124 1125 @setupmethod1124- def template_test(self, name: t.Optional[str] = None) -> t.Callable:1126+ def template_test(1127+ self, name: t.Optional[str] = None1128+ ) -> t.Callable[[TemplateTestCallable], TemplateTestCallable]:1129 """A decorator that is used to register custom template test.1130 You can specify a name for the test, otherwise the function1131 name will be used. Example::1132 32 unmodified lines1165 """1166 self.jinja_env.tests[name or f.__name__] = f1167 1168 @setupmethod1165- def template_global(self, name: t.Optional[str] = None) -> t.Callable:1169+ def template_global(1170+ self, name: t.Optional[str] = None1171+ ) -> t.Callable[[TemplateGlobalCallable], TemplateGlobalCallable]:1172 """A decorator that is used to register a custom template global function.1173 You can specify a name for the global function, otherwise the function1174 name will be used. Example::1175 907 unmodified linesmodified:src/flask/blueprints.py+9 added-3 removed
385 unmodified lines386 **options,387 )388 )389 390- def app_template_filter(self, name: t.Optional[str] = None) -> t.Callable:390+ def app_template_filter(391+ self, name: t.Optional[str] = None392+ ) -> t.Callable[[TemplateFilterCallable], TemplateFilterCallable]:393 """Register a custom template filter, available application wide. Like394 :meth:`Flask.template_filter` but for a blueprint.395 396 :param name: the optional name of the filter, otherwise the21 unmodified lines418 state.app.jinja_env.filters[name or f.__name__] = f419 420 self.record_once(register_template)421 420- def app_template_test(self, name: t.Optional[str] = None) -> t.Callable:422+ def app_template_test(423+ self, name: t.Optional[str] = None424+ ) -> t.Callable[[TemplateTestCallable], TemplateTestCallable]:425 """Register a custom template test, available application wide. Like426 :meth:`Flask.template_test` but for a blueprint.427 428 .. versionadded:: 0.1025 unmodified lines454 state.app.jinja_env.tests[name or f.__name__] = f455 456 self.record_once(register_template)457 454- def app_template_global(self, name: t.Optional[str] = None) -> t.Callable:458+ def app_template_global(459+ self, name: t.Optional[str] = None460+ ) -> t.Callable[[TemplateGlobalCallable], TemplateGlobalCallable]:461 """Register a custom template global, available application wide. Like462 :meth:`Flask.template_global` but for a blueprint.463 464 .. versionadded:: 0.10103 unmodified linesmodified:src/flask/scaffold.py+1 added-1 removed
642 unmodified lines643 644 @setupmethod645 def errorhandler(646 self, code_or_exception: t.Union[t.Type[Exception], int]647- ) -> t.Callable:647+ ) -> t.Callable[[ErrorHandlerCallable], ErrorHandlerCallable]:648 """Register a function to handle errors by code or exception class.649 650 A decorator that is used to register a function given an651 error code. Example::213 unmodified lines