docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
listlengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
from .testing import FlaskClient as cls # type: ignore return cls( # type: ignore self, self.response_class, use_cookies=use_cookies, **kwargs )
<mask> the constructor of :attr:`test_client_class`. <mask> """ <mask> cls = self.test_client_class <mask> if cls is None: <mask> from .testing import FlaskClient as cls <mask> return cls(self, self.response_class, use_cookies=use_cookies, **kwargs) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def test_cli_runner(self, **kwargs: t.Any) -> "FlaskCliRunner":
<mask> if cls is None: <mask> from .testing import FlaskClient as cls <mask> return cls(self, self.response_class, use_cookies=use_cookies, **kwargs) <mask> <mask> def test_cli_runner(self, **kwargs): <mask> """Create a CLI runner for testing CLI commands. <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
from .testing import FlaskCliRunner as cls # type: ignore
<mask> """ <mask> cls = self.test_cli_runner_class <mask> <mask> if cls is None: <mask> from .testing import FlaskCliRunner as cls <mask> <mask> return cls(self, **kwargs) <mask> <mask> @setupmethod <mask> def register_blueprint(self, blueprint, **options...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
return cls(self, **kwargs) # type: ignore
<mask> <mask> if cls is None: <mask> from .testing import FlaskCliRunner as cls <mask> <mask> return cls(self, **kwargs) <mask> <mask> @setupmethod <mask> def register_blueprint(self, blueprint, **options): <mask> """Register a :class:`~flask.Blueprint` on the app...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def register_blueprint(self, blueprint: "Blueprint", **options: t.Any) -> None:
<mask> <mask> return cls(self, **kwargs) <mask> <mask> @setupmethod <mask> def register_blueprint(self, blueprint, **options): <mask> """Register a :class:`~flask.Blueprint` on the application. Keyword <mask> arguments passed to this method will override the defaults set on the ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def iter_blueprints(self) -> t.ValuesView["Blueprint"]:
<mask> .. versionadded:: 0.7 <mask> """ <mask> blueprint.register(self, options) <mask> <mask> def iter_blueprints(self): <mask> """Iterates over all blueprints by the order they were registered. <mask> <mask> .. versionadded:: 0.11 <mask> """ <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
rule: str, endpoint: t.Optional[str] = None, view_func: t.Optional[t.Callable] = None, provide_automatic_options: t.Optional[bool] = None, **options: t.Any, ) -> None:
<mask> <mask> @setupmethod <mask> def add_url_rule( <mask> self, <mask> rule, <mask> endpoint=None, <mask> view_func=None, <mask> provide_automatic_options=None, <mask> **options, <mask> ): <mask> if endpoint is None: <mask> en...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
endpoint = _endpoint_from_view_func(view_func) # type: ignore
<mask> provide_automatic_options=None, <mask> **options, <mask> ): <mask> if endpoint is None: <mask> endpoint = _endpoint_from_view_func(view_func) <mask> options["endpoint"] = endpoint <mask> methods = options.pop("methods", None) <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
rule.provide_automatic_options = provide_automatic_options # type: ignore
<mask> # Add the required methods now. <mask> methods |= required_methods <mask> <mask> rule = self.url_rule_class(rule, methods=methods, **options) <mask> rule.provide_automatic_options = provide_automatic_options <mask> <mask> self.url_map.add(rule) <mask> if ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
old_func = old_func.__wrapped__ # type: ignore
<mask> self.url_map.add(rule) <mask> if view_func is not None: <mask> old_func = self.view_functions.get(endpoint) <mask> if getattr(old_func, "_flask_sync_wrapper", False): <mask> old_func = old_func.__wrapped__ <mask> if old_func is not None an...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def template_filter(self, name: t.Optional[str] = None) -> t.Callable:
<mask> ) <mask> self.view_functions[endpoint] = self.ensure_sync(view_func) <mask> <mask> @setupmethod <mask> def template_filter(self, name=None): <mask> """A decorator that is used to register custom template filter. <mask> You can specify a name for the fil...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def decorator(f: TemplateFilterCallable) -> TemplateFilterCallable:
<mask> :param name: the optional name of the filter, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f): <mask> self.add_template_filter(f, name=name) <mask> return f <mask> <mask> return deco...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def add_template_filter( self, f: TemplateFilterCallable, name: t.Optional[str] = None ) -> None:
<mask> <mask> return decorator <mask> <mask> @setupmethod <mask> def add_template_filter(self, f, name=None): <mask> """Register a custom template filter. Works exactly like the <mask> :meth:`template_filter` decorator. <mask> <mask> :param name: the optional name of...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def template_test(self, name: t.Optional[str] = None) -> t.Callable:
<mask> """ <mask> self.jinja_env.filters[name or f.__name__] = f <mask> <mask> @setupmethod <mask> def template_test(self, name=None): <mask> """A decorator that is used to register custom template test. <mask> You can specify a name for the test, otherwise the function ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def decorator(f: TemplateTestCallable) -> TemplateTestCallable:
<mask> :param name: the optional name of the test, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f): <mask> self.add_template_test(f, name=name) <mask> return f <mask> <mask> return decorato...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def add_template_test( self, f: TemplateTestCallable, name: t.Optional[str] = None ) -> None:
<mask> <mask> return decorator <mask> <mask> @setupmethod <mask> def add_template_test(self, f, name=None): <mask> """Register a custom template test. Works exactly like the <mask> :meth:`template_test` decorator. <mask> <mask> .. versionadded:: 0.10 <mask> </s> A...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def template_global(self, name: t.Optional[str] = None) -> t.Callable:
<mask> """ <mask> self.jinja_env.tests[name or f.__name__] = f <mask> <mask> @setupmethod <mask> def template_global(self, name=None): <mask> """A decorator that is used to register a custom template global function. <mask> You can specify a name for the global function, ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def decorator(f: TemplateGlobalCallable) -> TemplateGlobalCallable:
<mask> :param name: the optional name of the global function, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f): <mask> self.add_template_global(f, name=name) <mask> return f <mask> <mask> re...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def add_template_global( self, f: TemplateGlobalCallable, name: t.Optional[str] = None ) -> None:
<mask> <mask> return decorator <mask> <mask> @setupmethod <mask> def add_template_global(self, f, name=None): <mask> """Register a custom template global function. Works exactly like the <mask> :meth:`template_global` decorator. <mask> <mask> .. versionadded:: 0.10 <...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def before_first_request(self, f: BeforeRequestCallable) -> BeforeRequestCallable:
<mask> """ <mask> self.jinja_env.globals[name or f.__name__] = f <mask> <mask> @setupmethod <mask> def before_first_request(self, f): <mask> """Registers a function to be run before the first request to this <mask> instance of the application. <mask> <mask> The...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def teardown_appcontext(self, f: TeardownCallable) -> TeardownCallable:
<mask> self.before_first_request_funcs.append(self.ensure_sync(f)) <mask> return f <mask> <mask> @setupmethod <mask> def teardown_appcontext(self, f): <mask> """Registers a function to be called when the application context <mask> ends. These functions are typically also...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def shell_context_processor(self, f: t.Callable) -> t.Callable:
<mask> self.teardown_appcontext_funcs.append(self.ensure_sync(f)) <mask> return f <mask> <mask> @setupmethod <mask> def shell_context_processor(self, f): <mask> """Registers a shell context processor function. <mask> <mask> .. versionadded:: 0.11 <mask> """ <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def _find_error_handler(self, e: Exception) -> t.Optional[ErrorHandlerCallable]:
<mask> """ <mask> self.shell_context_processors.append(f) <mask> return f <mask> <mask> def _find_error_handler(self, e): <mask> """Return a registered error handler for an exception in this order: <mask> blueprint handler for a specific code, app handler for a specif...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
return None
<mask> if handler is not None: <mask> return handler <mask> <mask> def handle_http_exception( <mask> self, e: HTTPException <mask> ) -> t.Union[HTTPException, ResponseReturnValue]: <mask> """Handles an HTTP exception. By default this will invo...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def handle_http_exception( self, e: HTTPException ) -> t.Union[HTTPException, ResponseReturnValue]:
<mask> <mask> if handler is not None: <mask> return handler <mask> <mask> def handle_http_exception(self, e): <mask> """Handles an HTTP exception. By default this will invoke the <mask> registered error handlers and fall back to returning the <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def trap_http_exception(self, e: Exception) -> bool:
<mask> if handler is None: <mask> return e <mask> return handler(e) <mask> <mask> def trap_http_exception(self, e): <mask> """Checks if an HTTP exception should be trapped or not. By default <mask> this will return ``False`` for all exceptions except for a bad re...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def handle_user_exception( self, e: Exception ) -> t.Union[HTTPException, ResponseReturnValue]:
<mask> return isinstance(e, BadRequest) <mask> <mask> return False <mask> <mask> def handle_user_exception(self, e): <mask> """This method is called whenever an exception occurs that <mask> should be handled. A special case is :class:`~werkzeug <mask> .exception...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def handle_exception(self, e: Exception) -> Response:
<mask> raise <mask> <mask> return handler(e) <mask> <mask> def handle_exception(self, e): <mask> """Handle an exception that did not have an error handler <mask> associated with it, or that was raised from an error handler. <mask> This always causes a 500 ``Inte...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
server_error: t.Union[InternalServerError, ResponseReturnValue]
<mask> <mask> raise e <mask> <mask> self.log_exception(exc_info) <mask> server_error = InternalServerError(original_exception=e) <mask> handler = self._find_error_handler(server_error) <mask> <mask> if handler is not None: </s> Add initial type hints This should ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def log_exception( self, exc_info: t.Union[ t.Tuple[type, BaseException, TracebackType], t.Tuple[None, None, None] ], ) -> None:
<mask> server_error = handler(server_error) <mask> <mask> return self.finalize_request(server_error, from_error_handler=True) <mask> <mask> def log_exception(self, exc_info): <mask> """Logs an exception. This is called by :meth:`handle_exception` <mask> if debugging is ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def raise_routing_exception(self, request: Request) -> t.NoReturn:
<mask> self.logger.error( <mask> f"Exception on {request.path} [{request.method}]", exc_info=exc_info <mask> ) <mask> <mask> def raise_routing_exception(self, request): <mask> """Exceptions that are recording during routing are reraised with <mask> this method. D...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
raise request.routing_exception # type: ignore
<mask> not self.debug <mask> or not isinstance(request.routing_exception, RequestRedirect) <mask> or request.method in ("GET", "HEAD", "OPTIONS") <mask> ): <mask> raise request.routing_exception <mask> <mask> from .debughelpers import FormDataRouti...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def dispatch_request(self) -> ResponseReturnValue:
<mask> from .debughelpers import FormDataRoutingRedirect <mask> <mask> raise FormDataRoutingRedirect(request) <mask> <mask> def dispatch_request(self): <mask> """Does the request dispatching. Matches the URL and returns the <mask> return value of the view or error handler. ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def full_dispatch_request(self) -> Response:
<mask> return self.make_default_options_response() <mask> # otherwise dispatch to the handler for that endpoint <mask> return self.view_functions[rule.endpoint](**req.view_args) <mask> <mask> def full_dispatch_request(self): <mask> """Dispatches the request and on top of t...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def finalize_request( self, rv: t.Union[ResponseReturnValue, HTTPException], from_error_handler: bool = False, ) -> Response:
<mask> except Exception as e: <mask> rv = self.handle_user_exception(e) <mask> return self.finalize_request(rv) <mask> <mask> def finalize_request(self, rv, from_error_handler=False): <mask> """Given the return value from a view function this finalizes <mask> the ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def try_trigger_before_first_request_functions(self) -> None:
<mask> "Request finalizing failed with an error while handling an error" <mask> ) <mask> return response <mask> <mask> def try_trigger_before_first_request_functions(self): <mask> """Called before each request and will ensure that it triggers <mask> the :a...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def make_default_options_response(self) -> Response:
<mask> for func in self.before_first_request_funcs: <mask> func() <mask> self._got_first_request = True <mask> <mask> def make_default_options_response(self): <mask> """This method is called to create the default ``OPTIONS`` response. <mask> This can b...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def should_ignore_error(self, error: t.Optional[BaseException]) -> bool:
<mask> rv = self.response_class() <mask> rv.allow.update(methods) <mask> return rv <mask> <mask> def should_ignore_error(self, error): <mask> """This is called to figure out if an error should be ignored <mask> or not as far as the teardown system is concerned. If th...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def ensure_sync(self, func: t.Callable) -> t.Callable:
<mask> .. versionadded:: 0.10 <mask> """ <mask> return False <mask> <mask> def ensure_sync(self, func): <mask> """Ensure that the function is synchronous for WSGI workers. <mask> Plain ``def`` functions are returned as-is. ``async def`` <mask> functions are w...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def make_response(self, rv: ResponseReturnValue) -> Response:
<mask> return run_async(func) <mask> <mask> return func <mask> <mask> def make_response(self, rv): <mask> """Convert the return value from a view function to an instance of <mask> :attr:`response_class`. <mask> <mask> :param rv: the return value from the view ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
rv = self.response_class.force_type(rv, request.environ) # type: ignore # noqa: B950
<mask> elif isinstance(rv, BaseResponse) or callable(rv): <mask> # evaluate a WSGI callable, or coerce a different response <mask> # class to the correct type <mask> try: <mask> rv = self.response_class.force_type(rv, request.environ) ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
rv = t.cast(Response, rv)
<mask> " dict, tuple, Response instance, or WSGI" <mask> f" callable, but it was a {type(rv).__name__}." <mask> ) <mask> <mask> # prefer the status if it was provided <mask> if status is not None: <mask> if isinstance(status, (s...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
rv.status = status # type: ignore
<mask> <mask> # prefer the status if it was provided <mask> if status is not None: <mask> if isinstance(status, (str, bytes, bytearray)): <mask> rv.status = status <mask> else: <mask> rv.status_code = status <mask> <mask> # exten...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def create_url_adapter( self, request: t.Optional[Request] ) -> t.Optional[MapAdapter]:
<mask> rv.headers.update(headers) <mask> <mask> return rv <mask> <mask> def create_url_adapter(self, request): <mask> """Creates a URL adapter for the given request. The URL adapter <mask> is created at a point where the request context is not yet set <mask> up ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
return None def inject_url_defaults(self, endpoint: str, values: dict) -> None:
<mask> script_name=self.config["APPLICATION_ROOT"], <mask> url_scheme=self.config["PREFERRED_URL_SCHEME"], <mask> ) <mask> <mask> def inject_url_defaults(self, endpoint, values): <mask> """Injects the URL defaults for the given endpoint directly into <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
funcs: t.Iterable[URLDefaultCallable] = self.url_default_functions[None]
<mask> automatically called on URL building. <mask> <mask> .. versionadded:: 0.7 <mask> """ <mask> funcs = self.url_default_functions[None] <mask> if "." in endpoint: <mask> bp = endpoint.rsplit(".", 1)[0] <mask> funcs = chain(funcs, self.url_defa...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def handle_url_build_error( self, error: Exception, endpoint: str, values: dict ) -> str:
<mask> funcs = chain(funcs, self.url_default_functions[bp]) <mask> for func in funcs: <mask> func(endpoint, values) <mask> <mask> def handle_url_build_error(self, error, endpoint, values): <mask> """Handle :class:`~werkzeug.routing.BuildError` on <mask> :meth:...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def preprocess_request(self) -> t.Optional[ResponseReturnValue]:
<mask> raise <mask> <mask> raise error <mask> <mask> def preprocess_request(self): <mask> """Called before the request is dispatched. Calls <mask> :attr:`url_value_preprocessors` registered with the app and the <mask> current blueprint (if any). Then calls :attr...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
funcs: t.Iterable[URLValuePreprocessorCallable] = self.url_value_preprocessors[ None ]
<mask> value is handled as if it was the return value from the view, and <mask> further request handling is stopped. <mask> """ <mask> <mask> funcs = self.url_value_preprocessors[None] <mask> for bp in self._request_blueprints(): <mask> if bp in self.url_value...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
funcs: t.Iterable[BeforeRequestCallable] = self.before_request_funcs[None]
<mask> funcs = chain(funcs, self.url_value_preprocessors[bp]) <mask> for func in funcs: <mask> func(request.endpoint, request.view_args) <mask> <mask> funcs = self.before_request_funcs[None] <mask> for bp in self._request_blueprints(): <mask> if bp...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
return None def process_response(self, response: Response) -> Response:
<mask> rv = func() <mask> if rv is not None: <mask> return rv <mask> <mask> def process_response(self, response): <mask> """Can be overridden in order to modify the response object <mask> before it's sent to the WSGI server. By default this will <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
funcs: t.Iterable[AfterRequestCallable] = ctx._after_request_functions
<mask> :return: a new response object or the same, has to be an <mask> instance of :attr:`response_class`. <mask> """ <mask> ctx = _request_ctx_stack.top <mask> funcs = ctx._after_request_functions <mask> for bp in self._request_blueprints(): <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def do_teardown_request( self, exc: t.Optional[BaseException] = _sentinel # type: ignore ) -> None:
<mask> if not self.session_interface.is_null_session(ctx.session): <mask> self.session_interface.save_session(self, ctx.session, response) <mask> return response <mask> <mask> def do_teardown_request(self, exc=_sentinel): <mask> """Called after the request is dispatched an...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
funcs: t.Iterable[TeardownCallable] = reversed( self.teardown_request_funcs[None] )
<mask> Added the ``exc`` argument. <mask> """ <mask> if exc is _sentinel: <mask> exc = sys.exc_info()[1] <mask> funcs = reversed(self.teardown_request_funcs[None]) <mask> for bp in self._request_blueprints(): <mask> if bp in self.teardown_reques...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def do_teardown_appcontext( self, exc: t.Optional[BaseException] = _sentinel # type: ignore ) -> None:
<mask> for func in funcs: <mask> func(exc) <mask> request_tearing_down.send(self, exc=exc) <mask> <mask> def do_teardown_appcontext(self, exc=_sentinel): <mask> """Called right before the application context is popped. <mask> <mask> When handling a request, the ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def app_context(self) -> AppContext:
<mask> for func in reversed(self.teardown_appcontext_funcs): <mask> func(exc) <mask> appcontext_tearing_down.send(self, exc=exc) <mask> <mask> def app_context(self): <mask> """Create an :class:`~flask.ctx.AppContext`. Use as a ``with`` <mask> block to push the con...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def request_context(self, environ: dict) -> RequestContext:
<mask> .. versionadded:: 0.9 <mask> """ <mask> return AppContext(self) <mask> <mask> def request_context(self, environ): <mask> """Create a :class:`~flask.ctx.RequestContext` representing a <mask> WSGI environment. Use a ``with`` block to push the context, <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def test_request_context(self, *args: t.Any, **kwargs: t.Any) -> RequestContext:
<mask> :param environ: a WSGI environment <mask> """ <mask> return RequestContext(self, environ) <mask> <mask> def test_request_context(self, *args, **kwargs): <mask> """Create a :class:`~flask.ctx.RequestContext` for a WSGI <mask> environment created from the given v...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def wsgi_app(self, environ: dict, start_response: t.Callable) -> t.Any:
<mask> return self.request_context(builder.get_environ()) <mask> finally: <mask> builder.close() <mask> <mask> def wsgi_app(self, environ, start_response): <mask> """The actual WSGI application. This is not implemented in <mask> :meth:`__call__` so that middle...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
error: t.Optional[BaseException] = None
<mask> a list of headers, and an optional exception context to <mask> start the response. <mask> """ <mask> ctx = self.request_context(environ) <mask> error = None <mask> try: <mask> try: <mask> ctx.push() <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def __call__(self, environ: dict, start_response: t.Callable) -> t.Any:
<mask> if self.should_ignore_error(error): <mask> error = None <mask> ctx.auto_pop(error) <mask> <mask> def __call__(self, environ, start_response): <mask> """The WSGI server calls the Flask application object as the <mask> WSGI application. This calls...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
def _request_blueprints(self) -> t.Iterable[str]:
<mask> wrapped to apply middleware. <mask> """ <mask> return self.wsgi_app(environ, start_response) <mask> <mask> def _request_blueprints(self): <mask> if _request_ctx_stack.top.request.blueprint is None: <mask> return [] <mask> else: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/app.py
from .typing import AfterRequestCallable from .typing import BeforeRequestCallable from .typing import ErrorHandlerCallable from .typing import TeardownCallable from .typing import TemplateContextProcessorCallable from .typing import TemplateFilterCallable from .typing import TemplateGlobalCallable from .typing import ...
<mask> <mask> from .scaffold import _endpoint_from_view_func <mask> from .scaffold import _sentinel <mask> from .scaffold import Scaffold <mask> <mask> <mask> class BlueprintSetupState: <mask> """Temporary holder object for registering a blueprint with the <mask> application. An instance of this cl...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def __init__( self, blueprint: "Blueprint", app: "Flask", options: t.Any, first_registration: bool, ) -> None:
<mask> :meth:`~flask.Blueprint.make_setup_state` method and later passed <mask> to all register callback functions. <mask> """ <mask> <mask> def __init__(self, blueprint, app, options, first_registration): <mask> #: a reference to the current application <mask> self.app = app <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def add_url_rule( self, rule: str, endpoint: t.Optional[str] = None, view_func: t.Optional[t.Callable] = None, **options: t.Any, ) -> None:
<mask> #: URL that was defined with the blueprint. <mask> self.url_defaults = dict(self.blueprint.url_values_defaults) <mask> self.url_defaults.update(self.options.get("url_defaults", ())) <mask> <mask> def add_url_rule(self, rule, endpoint=None, view_func=None, **options): <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
endpoint = _endpoint_from_view_func(view_func) # type: ignore
<mask> else: <mask> rule = self.url_prefix <mask> options.setdefault("subdomain", self.subdomain) <mask> if endpoint is None: <mask> endpoint = _endpoint_from_view_func(view_func) <mask> defaults = self.url_defaults <mask> if "defaults" in o...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
name: str, import_name: str, static_folder: t.Optional[str] = None, static_url_path: t.Optional[str] = None, template_folder: t.Optional[str] = None, url_prefix: t.Optional[str] = None, subdomain: t.Optional[str] = None, url_defaults: t.Optional[dict] = No...
<mask> json_decoder = None <mask> <mask> def __init__( <mask> self, <mask> name, <mask> import_name, <mask> static_folder=None, <mask> static_url_path=None, <mask> template_folder=None, <mask> url_prefix=None, <mask> subdomain=None, <m...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
self.deferred_functions: t.List[DeferredSetupFunction] = []
<mask> ) <mask> self.name = name <mask> self.url_prefix = url_prefix <mask> self.subdomain = subdomain <mask> self.deferred_functions = [] <mask> <mask> if url_defaults is None: <mask> url_defaults = {} <mask> <mask> self.url_values_default...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
self._blueprints: t.List[t.Tuple["Blueprint", dict]] = []
<mask> url_defaults = {} <mask> <mask> self.url_values_defaults = url_defaults <mask> self.cli_group = cli_group <mask> self._blueprints = [] <mask> <mask> def _is_setup_finished(self): <mask> return self.warn_on_modifications and self._got_registered_once <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def _is_setup_finished(self) -> bool:
<mask> self.url_values_defaults = url_defaults <mask> self.cli_group = cli_group <mask> self._blueprints = [] <mask> <mask> def _is_setup_finished(self): <mask> return self.warn_on_modifications and self._got_registered_once <mask> <mask> def record(self, func): <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def record(self, func: t.Callable) -> None:
<mask> <mask> def _is_setup_finished(self): <mask> return self.warn_on_modifications and self._got_registered_once <mask> <mask> def record(self, func): <mask> """Registers a function that is called when the blueprint is <mask> registered on the application. This function is ca...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def record_once(self, func: t.Callable) -> None:
<mask> ) <mask> ) <mask> self.deferred_functions.append(func) <mask> <mask> def record_once(self, func): <mask> """Works like :meth:`record` but wraps the function in another <mask> function that will ensure the function is only called once. If the <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def wrapper(state: BlueprintSetupState) -> None:
<mask> blueprint is registered a second time on the application, the <mask> function passed is not called. <mask> """ <mask> <mask> def wrapper(state): <mask> if state.first_registration: <mask> func(state) <mask> <mask> return self.record(u...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def make_setup_state( self, app: "Flask", options: dict, first_registration: bool = False ) -> BlueprintSetupState:
<mask> func(state) <mask> <mask> return self.record(update_wrapper(wrapper, func)) <mask> <mask> def make_setup_state(self, app, options, first_registration=False): <mask> """Creates an instance of :meth:`~flask.blueprints.BlueprintSetupState` <mask> object that is l...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def register_blueprint(self, blueprint: "Blueprint", **options: t.Any) -> None:
<mask> Subclasses can override this to return a subclass of the setup state. <mask> """ <mask> return BlueprintSetupState(self, app, options, first_registration) <mask> <mask> def register_blueprint(self, blueprint, **options): <mask> """Register a :class:`~flask.Blueprint` on...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def register(self, app: "Flask", options: dict) -> None:
<mask> .. versionadded:: 2.0 <mask> """ <mask> self._blueprints.append((blueprint, options)) <mask> <mask> def register(self, app, options): <mask> """Called by :meth:`Flask.register_blueprint` to register all <mask> views and callbacks registered on the blueprint wit...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def add_url_rule( self, rule: str, endpoint: t.Optional[str] = None, view_func: t.Optional[t.Callable] = None, **options: t.Any, ) -> None:
<mask> bp_options["url_prefix"] = url_prefix <mask> bp_options["name_prefix"] = options.get("name_prefix", "") + self.name + "." <mask> blueprint.register(app, bp_options) <mask> <mask> def add_url_rule(self, rule, endpoint=None, view_func=None, **options): <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def app_template_filter(self, name: t.Optional[str] = None) -> t.Callable:
<mask> "." not in view_func.__name__ <mask> ), "Blueprint view function name should not contain dots" <mask> self.record(lambda s: s.add_url_rule(rule, endpoint, view_func, **options)) <mask> <mask> def app_template_filter(self, name=None): <mask> """Register a cus...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def decorator(f: TemplateFilterCallable) -> TemplateFilterCallable:
<mask> :param name: the optional name of the filter, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f): <mask> self.add_app_template_filter(f, name=name) <mask> return f <mask> <mask> return ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def add_app_template_filter( self, f: TemplateFilterCallable, name: t.Optional[str] = None ) -> None:
<mask> return f <mask> <mask> return decorator <mask> <mask> def add_app_template_filter(self, f, name=None): <mask> """Register a custom template filter, available application wide. Like <mask> :meth:`Flask.add_template_filter` but for a blueprint. Works exactly <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def register_template(state: BlueprintSetupState) -> None:
<mask> :param name: the optional name of the filter, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def register_template(state): <mask> state.app.jinja_env.filters[name or f.__name__] = f <mask> <mask> self.record_onc...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def app_template_test(self, name: t.Optional[str] = None) -> t.Callable:
<mask> state.app.jinja_env.filters[name or f.__name__] = f <mask> <mask> self.record_once(register_template) <mask> <mask> def app_template_test(self, name=None): <mask> """Register a custom template test, available application wide. Like <mask> :meth:`Flask.template_te...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def decorator(f: TemplateTestCallable) -> TemplateTestCallable:
<mask> :param name: the optional name of the test, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f): <mask> self.add_app_template_test(f, name=name) <mask> return f <mask> <mask> return deco...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def add_app_template_test( self, f: TemplateTestCallable, name: t.Optional[str] = None ) -> None:
<mask> return f <mask> <mask> return decorator <mask> <mask> def add_app_template_test(self, f, name=None): <mask> """Register a custom template test, available application wide. Like <mask> :meth:`Flask.add_template_test` but for a blueprint. Works exactly <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def register_template(state: BlueprintSetupState) -> None:
<mask> :param name: the optional name of the test, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def register_template(state): <mask> state.app.jinja_env.tests[name or f.__name__] = f <mask> <mask> self.record_once(re...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def app_template_global(self, name: t.Optional[str] = None) -> t.Callable:
<mask> state.app.jinja_env.tests[name or f.__name__] = f <mask> <mask> self.record_once(register_template) <mask> <mask> def app_template_global(self, name=None): <mask> """Register a custom template global, available application wide. Like <mask> :meth:`Flask.template_...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def decorator(f: TemplateGlobalCallable) -> TemplateGlobalCallable:
<mask> :param name: the optional name of the global, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f): <mask> self.add_app_template_global(f, name=name) <mask> return f <mask> <mask> return ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def add_app_template_global( self, f: TemplateGlobalCallable, name: t.Optional[str] = None ) -> None:
<mask> return f <mask> <mask> return decorator <mask> <mask> def add_app_template_global(self, f, name=None): <mask> """Register a custom template global, available application wide. Like <mask> :meth:`Flask.add_template_global` but for a blueprint. Works exactly <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def register_template(state: BlueprintSetupState) -> None:
<mask> :param name: the optional name of the global, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def register_template(state): <mask> state.app.jinja_env.globals[name or f.__name__] = f <mask> <mask> self.record_onc...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def before_app_request(self, f: BeforeRequestCallable) -> BeforeRequestCallable:
<mask> state.app.jinja_env.globals[name or f.__name__] = f <mask> <mask> self.record_once(register_template) <mask> <mask> def before_app_request(self, f): <mask> """Like :meth:`Flask.before_request`. Such a function is executed <mask> before each request, even if outsi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def before_app_first_request( self, f: BeforeRequestCallable ) -> BeforeRequestCallable:
<mask> ) <mask> ) <mask> return f <mask> <mask> def before_app_first_request(self, f): <mask> """Like :meth:`Flask.before_first_request`. Such a function is <mask> executed before the first request to the application. <mask> """ <mask> self.reco...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def after_app_request(self, f: AfterRequestCallable) -> AfterRequestCallable:
<mask> lambda s: s.app.before_first_request_funcs.append(s.app.ensure_sync(f)) <mask> ) <mask> return f <mask> <mask> def after_app_request(self, f): <mask> """Like :meth:`Flask.after_request` but for a blueprint. Such a function <mask> is executed after each req...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def teardown_app_request(self, f: TeardownCallable) -> TeardownCallable:
<mask> ) <mask> ) <mask> return f <mask> <mask> def teardown_app_request(self, f): <mask> """Like :meth:`Flask.teardown_request` but for a blueprint. Such a <mask> function is executed when tearing down each request, even if outside of <mask> the bluepri...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def app_context_processor( self, f: TemplateContextProcessorCallable ) -> TemplateContextProcessorCallable:
<mask> lambda s: s.app.teardown_request_funcs.setdefault(None, []).append(f) <mask> ) <mask> return f <mask> <mask> def app_context_processor(self, f): <mask> """Like :meth:`Flask.context_processor` but for a blueprint. Such a <mask> function is executed each req...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def app_errorhandler(self, code: t.Union[t.Type[Exception], int]) -> t.Callable:
<mask> lambda s: s.app.template_context_processors.setdefault(None, []).append(f) <mask> ) <mask> return f <mask> <mask> def app_errorhandler(self, code): <mask> """Like :meth:`Flask.errorhandler` but for a blueprint. This <mask> handler is used for all requests,...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def decorator(f: ErrorHandlerCallable) -> ErrorHandlerCallable:
<mask> """Like :meth:`Flask.errorhandler` but for a blueprint. This <mask> handler is used for all requests, even if outside of the blueprint. <mask> """ <mask> <mask> def decorator(f): <mask> self.record_once(lambda s: s.app.errorhandler(code)(f)) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def app_url_value_preprocessor( self, f: URLValuePreprocessorCallable ) -> URLValuePreprocessorCallable:
<mask> return f <mask> <mask> return decorator <mask> <mask> def app_url_value_preprocessor(self, f): <mask> """Same as :meth:`url_value_preprocessor` but application wide.""" <mask> self.record_once( <mask> lambda s: s.app.url_value_preprocessors.setdefault...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def app_url_defaults(self, f: URLDefaultCallable) -> URLDefaultCallable:
<mask> lambda s: s.app.url_value_preprocessors.setdefault(None, []).append(f) <mask> ) <mask> return f <mask> <mask> def app_url_defaults(self, f): <mask> """Same as :meth:`url_defaults` but application wide.""" <mask> self.record_once( <mask> lambda ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
def ensure_sync(self, f: t.Callable) -> t.Callable:
<mask> lambda s: s.app.url_default_functions.setdefault(None, []).append(f) <mask> ) <mask> return f <mask> <mask> def ensure_sync(self, f): <mask> """Ensure the function is synchronous. <mask> <mask> Override if you would like custom async to sync behaviour in ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/blueprints.py
ssl = None # type: ignore
<mask> <mask> try: <mask> import ssl <mask> except ImportError: <mask> ssl = None <mask> <mask> <mask> class NoAppException(click.UsageError): <mask> """Raised if an application cannot be found or loaded.""" <mask> </s> Add initial type hints This should make it easier for users to correctly...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/cli.py