Skip to content
Myr

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

3 files+19 added−7 removed

modified:src/flask/app.py+9 added-3 removed
1087 unmodified lines
1088 )1089 self.view_functions[endpoint] = view_func10901091 @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 lines
1122 """1123 self.jinja_env.filters[name or f.__name__] = f11241125 @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 lines
1165 """1166 self.jinja_env.tests[name or f.__name__] = f11671168 @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 lines
modified:src/flask/blueprints.py+9 added-3 removed
385 unmodified lines
386 **options,387 )388 )389390 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.395396 :param name: the optional name of the filter, otherwise the
21 unmodified lines
418 state.app.jinja_env.filters[name or f.__name__] = f419420 self.record_once(register_template)421420 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.427428 .. versionadded:: 0.10
25 unmodified lines
454 state.app.jinja_env.tests[name or f.__name__] = f455456 self.record_once(register_template)457454 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.463464 .. versionadded:: 0.10
103 unmodified lines
modified:src/flask/scaffold.py+1 added-1 removed
642 unmodified lines
643644 @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.649650 A decorator that is used to register a function given an651 error code. Example::
213 unmodified lines