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
<mask> response = self.make_response(rv) <mask> response = self.process_response(response) <mask> except Exception, e: <mask> response = self.make_response(self.handle_exception(e)) <mask> try: <mask> response = self.p...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9983e847425621b5e474ae9da6822f1af0b0cc1f
flask.py
called = []
<mask> assert 'Internal Server Error' in rv.data <mask> assert len(called) == 1 <mask> <mask> def test_after_request_handler_error(self): <mask> error_out = StringIO() <mask> app = flask.Flask(__name__) <mask> app.logger.addHandler(StreamHandler(error_out)) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9983e847425621b5e474ae9da6822f1af0b0cc1f
tests/flask_tests.py
<mask> <mask> def test_after_request_handler_error(self): <mask> error_out = StringIO() <mask> app = flask.Flask(__name__) <mask> app.logger.addHandler(StreamHandler(error_out)) <mask> @app.after_request <mask> def after_request(response): <mask> 1/0 <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9983e847425621b5e474ae9da6822f1af0b0cc1f
tests/flask_tests.py
called.append(True)
<mask> @app.after_request <mask> def after_request(response): <mask> 1/0 <mask> return response <mask> @app.route('/') <mask> def fails(): <mask> 1/0 <mask> rv = app.test_client().get('/') </s> Fixed after_request handlers being called...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9983e847425621b5e474ae9da6822f1af0b0cc1f
tests/flask_tests.py
assert len(called) == 1
<mask> 1/0 <mask> rv = app.test_client().get('/') <mask> assert rv.status_code == 500 <mask> assert 'Internal Server Error' in rv.data <mask> assert 'after_request handler failed' in error_out.getvalue() <mask> <mask> def test_error_handling(self): <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9983e847425621b5e474ae9da6822f1af0b0cc1f
tests/flask_tests.py
def test_logger_cache(self): app = flask.Flask(__name__) logger1 = app.logger assert app.logger is logger1 assert logger1.name == __name__ app.logger_name = __name__ + '/test_logger_cache' assert app.logger is not logger1
<mask> <mask> class LoggingTestCase(unittest.TestCase): <mask> <mask> def test_debug_log(self): <mask> app = flask.Flask(__name__) <mask> app.debug = True <mask> @app.route('/') <mask> def index(): </s> Fixed after_request handlers being called twice in some cases and impr...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9983e847425621b5e474ae9da6822f1af0b0cc1f
tests/flask_tests.py
<mask> else: <mask> assert False, 'debug log ate the exception' <mask> <mask> def test_exception_logging(self): <mask> from logging import StreamHandler <mask> out = StringIO() <mask> app = flask.Flask(__name__) <mask> app.logger.addHandler(Stream...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9983e847425621b5e474ae9da6822f1af0b0cc1f
tests/flask_tests.py
app.logger_name = 'flask_tests/test_exception_logging'
<mask> def test_exception_logging(self): <mask> out = StringIO() <mask> app = flask.Flask(__name__) <mask> app.logger.addHandler(StreamHandler(out)) <mask> <mask> @app.route('/') <mask> def index(): <mask> 1/0 </s> Fixed after_request handlers being call...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9983e847425621b5e474ae9da6822f1af0b0cc1f
tests/flask_tests.py
elif bp_url_prefix is not None: bp_options["url_prefix"] = bp_url_prefix elif state.url_prefix is not None:
<mask> if state.url_prefix is not None and bp_url_prefix is not None: <mask> bp_options["url_prefix"] = ( <mask> state.url_prefix.rstrip("/") + "/" + bp_url_prefix.lstrip("/") <mask> ) <mask> else: <mask> bp_options["url_p...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99afbb277d25d3b052e00b9a8da216054d51d62a
src/flask/blueprints.py
@pytest.mark.parametrize( "parent_init, child_init, parent_registration, child_registration", [ ("/parent", "/child", None, None), ("/parent", None, None, "/child"), (None, None, "/parent", "/child"), ("/other", "/something", "/parent", "/child"), ], ) def test_nesting_url_pr...
<mask> assert client.get("/parent/child/no").data == b"Parent no" <mask> assert client.get("/parent/child/grandchild/no").data == b"Grandchild no" <mask> <mask> <mask> def test_nested_blueprint_url_prefix(app, client): <mask> parent = flask.Blueprint("parent", __name__, url_prefix="/parent") <mask>...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99afbb277d25d3b052e00b9a8da216054d51d62a
tests/test_blueprints.py
def index(): return "index"
<mask> def parent_index(): <mask> return "Parent" <mask> <mask> @child.route("/") <mask> def child_index(): <mask> return "Child" <mask> <mask> @grandchild.route("/") <mask> def grandchild_index(): <mask> return "Grandchild" <mask> <mask> @apple.route("/") ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/pallets/flask/commit/99afbb277d25d3b052e00b9a8da216054d51d62a
tests/test_blueprints.py
parent.register_blueprint(child, url_prefix=child_registration) app.register_blueprint(parent, url_prefix=parent_registration)
<mask> @child.route("/child-endpoint") <mask> def child_index(): <mask> return "Child" <mask> <mask> parent.register_blueprint(child) <mask> app.register_blueprint(parent, url_prefix="/parent") <mask> <mask> assert client.get("/parent/child-endpoint").data == b"Child" </s> Fix blu...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep" ]
https://github.com/pallets/flask/commit/99afbb277d25d3b052e00b9a8da216054d51d62a
tests/test_blueprints.py
response = client.get("/parent/child/") assert response.status_code == 200
<mask> <mask> parent.register_blueprint(child) <mask> app.register_blueprint(parent, url_prefix="/parent") <mask> <mask> assert client.get("/parent/child-endpoint").data == b"Child" </s> Fix blueprint nested url_prefix This ensures that the url_prefix is correctly applied, no matter if set during t...
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/pallets/flask/commit/99afbb277d25d3b052e00b9a8da216054d51d62a
tests/test_blueprints.py
from js_example import views # noqa: E402, F401
<mask> from flask import Flask <mask> <mask> app = Flask(__name__) <mask> <mask> from js_example import views # noqa: F401 </s> move and update flake8 config </s> remove from blueprintapp.apps.admin import admin from blueprintapp.apps.frontend import frontend </s> add from blueprintapp.apps.admin import admin...
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/pallets/flask/commit/99b34f7148b77d4b1311593590629c2bc8e8e772
examples/javascript/js_example/__init__.py
<mask> source = <mask> src <mask> */site-packages <mask> <mask> [flake8] <mask> # B = bugbear <mask> # E = pycodestyle errors <mask> # F = flake8 pyflakes <mask> # W = pycodestyle warnings <mask> # B9 = bugbear opinions <mask> # ISC = implicit str concat <mask> select = B, E, F, W, B9, ISC <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/pallets/flask/commit/99b34f7148b77d4b1311593590629c2bc8e8e772
setup.cfg
raise ValueError("dummy")
<mask> cleanup_stuff.append(exception) <mask> <mask> @app.route("/") <mask> def index(): <mask> raise Exception("dummy") <mask> <mask> with pytest.raises(Exception, match="dummy"): <mask> with app.app_context(): <mask> client.get("/") <mask> </s> move and up...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99b34f7148b77d4b1311593590629c2bc8e8e772
tests/test_appctx.py
with pytest.raises(ValueError, match="dummy"):
<mask> @app.route("/") <mask> def index(): <mask> raise Exception("dummy") <mask> <mask> with pytest.raises(Exception, match="dummy"): <mask> with app.app_context(): <mask> client.get("/") <mask> <mask> assert len(cleanup_stuff) == 1 <mask> assert isinstance(c...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99b34f7148b77d4b1311593590629c2bc8e8e772
tests/test_appctx.py
assert isinstance(cleanup_stuff[0], ValueError)
<mask> with app.app_context(): <mask> client.get("/") <mask> <mask> assert len(cleanup_stuff) == 1 <mask> assert isinstance(cleanup_stuff[0], Exception) <mask> assert str(cleanup_stuff[0]) == "dummy" <mask> <mask> <mask> def test_app_ctx_globals_methods(app, app_ctx): <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99b34f7148b77d4b1311593590629c2bc8e8e772
tests/test_appctx.py
from blueprintapp.apps.admin import admin # noqa: E402 from blueprintapp.apps.frontend import frontend # noqa: E402
<mask> from flask import Flask <mask> <mask> app = Flask(__name__) <mask> app.config["DEBUG"] = True <mask> from blueprintapp.apps.admin import admin <mask> from blueprintapp.apps.frontend import frontend <mask> <mask> app.register_blueprint(admin) <mask> app.register_blueprint(frontend) </s> move and updat...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99b34f7148b77d4b1311593590629c2bc8e8e772
tests/test_apps/blueprintapp/__init__.py
with pytest.raises(AssertionError):
<mask> with app.test_request_context(): <mask> rv = flask.url_for("static", filename="index.html", _external=True) <mask> assert rv == "http://example.com/static/index.html" <mask> # Providing static_host without host_matching=True should error. <mask> with pytest.raises(Exception): <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99b34f7148b77d4b1311593590629c2bc8e8e772
tests/test_basic.py
with pytest.raises(AssertionError):
<mask> with pytest.raises(Exception): <mask> flask.Flask(__name__, static_host="example.com") <mask> # Providing host_matching=True with static_folder <mask> # but without static_host should error. <mask> with pytest.raises(Exception): <mask> flask.Flask(__name__, host_matching=Tru...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99b34f7148b77d4b1311593590629c2bc8e8e772
tests/test_basic.py
- Add ``--app``, ``--env``, and ``--debug`` options to the ``flask`` CLI, instead of requiring that they are set through environment variables. :issue:`2836` - Add ``--env-file`` option to the ``flask`` CLI. This allows specifying a dotenv file to load in addition to ``.env`` and ``.flaskenv``. :iss...
<mask> - A ``flask.cli.FlaskGroup`` Click group can be nested as a <mask> sub-command in a custom CLI. :issue:`3263` <mask> <mask> <mask> Version 2.1.3 <mask> ------------- <mask> <mask> Unreleased </s> add --app, --env, --debug, and --env-file CLI options </s> remove self.app_import_path = ap...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
CHANGES.rst
from click.core import ParameterSource
<mask> from threading import Thread <mask> <mask> import click <mask> from werkzeug.serving import is_running_from_reloader <mask> from werkzeug.utils import import_string <mask> <mask> from .globals import current_app </s> add --app, --env, --debug, and --env-file CLI options </s> remove app = Dispatchin...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
if t.TYPE_CHECKING: from .app import Flask
<mask> from .helpers import get_load_dotenv <mask> <mask> <mask> class NoAppException(click.UsageError): <mask> """Raised if an application cannot be found or loaded.""" <mask> </s> add --app, --env, --debug, and --env-file CLI options </s> remove Provides commands from Flask, extensions, and the applicat...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
f" '{module.__name__}'. Use '{module.__name__}:name'" " to specify the correct one."
<mask> return matches[0] <mask> elif len(matches) > 1: <mask> raise NoAppException( <mask> "Detected multiple Flask applications in module" <mask> f" {module.__name__!r}. Use 'FLASK_APP={module.__name__}:name'" <mask> f" to specify the correct one." <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
f"Detected factory '{attr_name}' in module '{module.__name__}',"
<mask> if not _called_with_wrong_args(app_factory): <mask> raise <mask> <mask> raise NoAppException( <mask> f"Detected factory {attr_name!r} in module {module.__name__!r}," <mask> " but could not call it without arguments...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
f" '{module.__name__}:{attr_name}(args)'"
<mask> <mask> raise NoAppException( <mask> f"Detected factory {attr_name!r} in module {module.__name__!r}," <mask> " but could not call it without arguments. Use" <mask> f" \"FLASK_APP='{module.__name__}:{attr_name}(args)'\"" <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
f" '{module.__name__}'. Use '{module.__name__}:name'"
<mask> ) from e <mask> <mask> raise NoAppException( <mask> "Failed to find Flask application or factory in module" <mask> f" {module.__name__!r}. Use 'FLASK_APP={module.__name__}:name'" <mask> " to specify one." <mask> ) <mask> <mask> <mask> def _called_with_...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
help="Show the Flask version.",
<mask> <mask> <mask> version_option = click.Option( <mask> ["--version"], <mask> help="Show the flask version", <mask> expose_value=False, <mask> callback=get_version, <mask> is_flag=True, <mask> is_eager=True, <mask> ) </s> add --app, --env, --debug, and --env-file CLI options </s>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
def __init__( self, app_import_path: str | None = None, create_app: t.Callable[..., Flask] | None = None, set_debug_flag: bool = True, ) -> None:
<mask> :class:`FlaskGroup` but you can also manually create it and pass it <mask> onwards as click object. <mask> """ <mask> <mask> def __init__(self, app_import_path=None, create_app=None, set_debug_flag=True): <mask> #: Optionally the import path for the Flask application. <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
self.app_import_path = app_import_path
<mask> """ <mask> <mask> def __init__(self, app_import_path=None, create_app=None, set_debug_flag=True): <mask> #: Optionally the import path for the Flask application. <mask> self.app_import_path = app_import_path or os.environ.get("FLASK_APP") <mask> #: Optionally a function tha...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
self.data: t.Dict[t.Any, t.Any] = {}
<mask> #: the instance of the application. <mask> self.create_app = create_app <mask> #: A dictionary with arbitrary data that can be associated with <mask> #: this script info. <mask> self.data = {} <mask> self.set_debug_flag = set_debug_flag <mask> self._...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
self._loaded_app: Flask | None = None
<mask> #: A dictionary with arbitrary data that can be associated with <mask> #: this script info. <mask> self.data = {} <mask> self.set_debug_flag = set_debug_flag <mask> self._loaded_app = None <mask> <mask> def load_app(self): <mask> """Loads the Flask app...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
def load_app(self) -> Flask:
<mask> self.data = {} <mask> self.set_debug_flag = set_debug_flag <mask> self._loaded_app = None <mask> <mask> def load_app(self): <mask> """Loads the Flask app (if not yet loaded) and returns it. Calling <mask> this multiple times will just result in the already loa...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
"Could not locate a Flask application. Use the" " 'flask --app' option, 'FLASK_APP' environment" " variable, or a 'wsgi.py' or 'app.py' file in the" " current directory."
<mask> break <mask> <mask> if not app: <mask> raise NoAppException( <mask> "Could not locate a Flask application. You did not provide " <mask> 'the "FLASK_APP" environment variable, and a "wsgi.py" or ' <mask> '"app.py" ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
.. versionchanged:: 2.2 Added the ``-A/--app``, ``-E/--env``, ``--debug/--no-debug``, and ``-e/--env-file`` options.
<mask> directory to the directory containing the first file found. <mask> :param set_debug_flag: Set the app's debug flag based on the active <mask> environment <mask> <mask> .. versionchanged:: 1.0 <mask> If installed, python-dotenv will be used to load environment variables <ma...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
add_default_commands: bool = True, create_app: t.Callable[..., Flask] | None = None, add_version_option: bool = True, load_dotenv: bool = True, set_debug_flag: bool = True, **extra: t.Any, ) -> None:
<mask> """ <mask> <mask> def __init__( <mask> self, <mask> add_default_commands=True, <mask> create_app=None, <mask> add_version_option=True, <mask> load_dotenv=True, <mask> set_debug_flag=True, <mask> **extra, <mask> ): <mask> par...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
# Processing is done with option callbacks instead of a group # callback. This allows users to make a custom group callback # without losing the behavior. --env-file must come first so # that it is eagerly evaluated before --app. params.extend((_env_file_option, _app_option, _env...
<mask> ) -> None: <mask> params = list(extra.pop("params", None) or ()) <mask> <mask> if add_version_option: <mask> params.append(version_option) <mask> </s> add --app, --env, --debug, and --env-file CLI options </s> remove add_default_commands=True, create_app=N...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
info_name: str | None, args: list[str], parent: click.Context | None = None,
<mask> return sorted(rv) <mask> <mask> def make_context( <mask> self, <mask> info_name: t.Optional[str], <mask> args: t.List[str], <mask> parent: t.Optional[click.Context] = None, <mask> **extra: t.Any, <mask> ) -> click.Context: <mask> if get_l...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
# Attempt to load .env and .flask env files. The --env-file # option can cause another file to be loaded.
<mask> parent: click.Context | None = None, <mask> **extra: t.Any, <mask> ) -> click.Context: <mask> if get_load_dotenv(self.load_dotenv): <mask> load_dotenv() <mask> <mask> if "obj" not in extra and "obj" not in self.context_settings: </s> add --app, --env, --de...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]: if not args and self.no_args_is_help: # Attempt to load --env-file and --app early in case they # were given as env vars. Otherwise no_args_is_help will not # see commands from app.cli. _e...
<mask> <mask> return super().make_context(info_name, args, parent=parent, **extra) <mask> <mask> <mask> def _path_is_ancestor(path, other): <mask> """Take ``other`` and remove the length of ``path`` from it. Then join it <mask> to ``path``. If it is the original value, ``path`` is an ancestor ...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
def load_dotenv(path: str | os.PathLike | None = None) -> bool:
<mask> ``other``.""" <mask> return os.path.join(path, other[len(path) :].lstrip(os.sep)) == other <mask> <mask> <mask> def load_dotenv(path=None): <mask> """Load "dotenv" files in order of precedence to set environment variables. <mask> <mask> If an env var is already set it is not overwritte...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
.. versionchanged:: 2.0 The current directory is not changed to the location of the loaded file.
<mask> <mask> :param path: Load the file at this location instead of searching. <mask> :return: ``True`` if a file was loaded. <mask> <mask> .. versionchanged:: 1.1.0 <mask> Returns ``False`` when python-dotenv is not installed, or when <mask> the given path isn't a file. <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
.. versionchanged:: 1.1.0 Returns ``False`` when python-dotenv is not installed, or when the given path isn't a file.
<mask> <mask> .. versionchanged:: 2.0 <mask> When loading the env files, set the default encoding to UTF-8. <mask> <mask> .. versionadded:: 1.0 <mask> """ <mask> try: <mask> import dotenv </s> add --app, --env, --debug, and --env-file CLI options </s> remove .. versionchan...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
# Always return after attempting to load a given path, don't load # the default files.
<mask> ) <mask> <mask> return False <mask> <mask> # if the given path specifies the actual file then return True, <mask> # else False <mask> if path is not None: <mask> if os.path.isfile(path): <mask> return dotenv.load_dotenv(path, encoding="utf-8") <mask...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
loaded = False
<mask> return dotenv.load_dotenv(path, encoding="utf-8") <mask> <mask> return False <mask> <mask> new_dir = None <mask> <mask> for name in (".env", ".flaskenv"): <mask> path = dotenv.find_dotenv(name, usecwd=True) <mask> <mask> if not path: </s> add --app, --en...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
<mask> <mask> if not path: <mask> continue <mask> <mask> if new_dir is None: <mask> new_dir = os.path.dirname(path) <mask> <mask> dotenv.load_dotenv(path, encoding="utf-8") <mask> <mask> return new_dir is not None # at least one file was located and loa...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
loaded = True
<mask> continue <mask> <mask> dotenv.load_dotenv(path, encoding="utf-8") <mask> <mask> return loaded # True if at least one file was located and loaded. <mask> <mask> </s> add --app, --env, --debug, and --env-file CLI options </s> remove return new_dir is not None # at least on...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
return loaded # True if at least one file was located and loaded.
<mask> new_dir = os.path.dirname(path) <mask> <mask> dotenv.load_dotenv(path, encoding="utf-8") <mask> <mask> return new_dir is not None # at least one file was located and loaded <mask> <mask> <mask> def show_server_banner(env, debug, app_import_path, eager_loading): <mask> ""...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
The reloader and debugger are enabled by default with the '--env development' or '--debug' options.
<mask> <mask> This server is for development purposes only. It does not provide <mask> the stability, security, or performance of production WSGI servers. <mask> <mask> The reloader and debugger are enabled by default if <mask> FLASK_ENV=development or FLASK_DEBUG=1. <mask> """ <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
<mask> <mask> The reloader and debugger are enabled by default with the <mask> '--env development' or '--debug' options. <mask> """ <mask> debug = get_debug_flag() <mask> <mask> if reload is None: <mask> reload = debug </s> add --app, --env, --debug, and --env-file CLI options </s...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
<mask> if debugger is None: <mask> debugger = debug <mask> <mask> show_server_banner(get_env(), debug, info.app_import_path, eager_loading) <mask> app = DispatchingApp(info.load_app, use_eager_loading=eager_loading) <mask> <mask> from werkzeug.serving import run_simple <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
An application to load must be given with the '--app' option, 'FLASK_APP' environment variable, or with a 'wsgi.py' or 'app.py' file in the current directory. """,
<mask> name="flask", <mask> help="""\ <mask> A general utility script for Flask applications. <mask> <mask> Provides commands from Flask, extensions, and the application. Loads the <mask> application defined in the FLASK_APP environment variable, or from a wsgi.py <mask> file. Setting the FLASK_ENV envi...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/cli.py
"""Get whether the user has disabled loading default dotenv files by setting :envvar:`FLASK_SKIP_DOTENV`. The default is ``True``, load the files.
<mask> return val.lower() not in ("0", "false", "no") <mask> <mask> <mask> def get_load_dotenv(default: bool = True) -> bool: <mask> """Get whether the user has disabled loading dotenv files by setting <mask> :envvar:`FLASK_SKIP_DOTENV`. The default is ``True``, load the <mask> files. <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/99fa3c36abc03cd5b3407df34dce74e879ea377a
src/flask/helpers.py
- Fix the type of ``static_folder`` to accept ``pathlib.Path``. :issue:`4150`
<mask> - Support View and MethodView instances with async handlers. :issue:`4112` <mask> - Enhance typing of ``app.errorhandler`` decorator. :issue:`4095` <mask> - Fix registering a blueprint twice with differing names. :issue:`4124` <mask> <mask> <mask> Version 2.0.1 <mask> ------------- <mask> </s> ...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9a2adfba4d4310b005c222fcdfb85e96e3e6661d
CHANGES.rst
static_folder: t.Optional[t.Union[str, os.PathLike]] = "static",
<mask> def __init__( <mask> self, <mask> import_name: str, <mask> static_url_path: t.Optional[str] = None, <mask> static_folder: t.Optional[str] = "static", <mask> static_host: t.Optional[str] = None, <mask> host_matching: bool = False, <mask> subdomai...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9a2adfba4d4310b005c222fcdfb85e96e3e6661d
src/flask/app.py
static_folder: t.Optional[t.Union[str, os.PathLike]] = None,
<mask> def __init__( <mask> self, <mask> name: str, <mask> import_name: str, <mask> static_folder: t.Optional[str] = None, <mask> static_url_path: t.Optional[str] = None, <mask> template_folder: t.Optional[str] = None, <mask> url_prefix: t.Optional[str...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9a2adfba4d4310b005c222fcdfb85e96e3e6661d
src/flask/blueprints.py
static_folder: t.Optional[t.Union[str, os.PathLike]] = None,
<mask> <mask> def __init__( <mask> self, <mask> import_name: str, <mask> static_folder: t.Optional[str] = None, <mask> static_url_path: t.Optional[str] = None, <mask> template_folder: t.Optional[str] = None, <mask> root_path: t.Optional[str] = None, <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9a2adfba4d4310b005c222fcdfb85e96e3e6661d
src/flask/scaffold.py
self.static_folder = static_folder # type: ignore
<mask> #: The name of the package or module that this object belongs <mask> #: to. Do not change this once it is set by the constructor. <mask> self.import_name = import_name <mask> <mask> self.static_folder = static_folder <mask> self.static_url_path = static_url_path <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9a2adfba4d4310b005c222fcdfb85e96e3e6661d
src/flask/scaffold.py
def static_folder(self, value: t.Optional[t.Union[str, os.PathLike]]) -> None:
<mask> else: <mask> return None <mask> <mask> @static_folder.setter <mask> def static_folder(self, value: t.Optional[str]) -> None: <mask> if value is not None: <mask> value = os.fspath(value).rstrip(r"\/") <mask> <mask> self._static_folder = value <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9a2adfba4d4310b005c222fcdfb85e96e3e6661d
src/flask/scaffold.py
from sys import modules, exc_info
<mask> if fullname.startswith(self.prefix): <mask> return self <mask> <mask> def load_module(self, fullname): <mask> from sys import modules <mask> if fullname in modules: <mask> return modules[fullname] <mask> modname = fullname.split('.', self.prefi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9a70e62b8d545c8de7e3728e544cebe289a39254
flask/ext/__init__.py
exc_type, exc_value, tb = exc_info() if self.is_important_traceback(realname, tb): raise exc_type, exc_value, tb
<mask> realname = path % modname <mask> try: <mask> __import__(realname) <mask> except ImportError: <mask> continue <mask> module = modules[fullname] = modules[realname] <mask> if '.' not in modname: <mask> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9a70e62b8d545c8de7e3728e544cebe289a39254
flask/ext/__init__.py
raise ImportError('No module named %s' % fullname) def is_important_traceback(self, important_module, tb): """Walks a traceback's frames and checks if any of the frames originated in the given important module. If that is the case then we were able to import the module itself but a...
<mask> module = modules[fullname] = modules[realname] <mask> if '.' not in modname: <mask> setattr(modules[__name__], modname, module) <mask> return module <mask> raise ImportError(fullname) <mask> <mask> <mask> _ExtensionImporter() <mask> del _Exte...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9a70e62b8d545c8de7e3728e544cebe289a39254
flask/ext/__init__.py
exc_type, exc_value, tb = sys.exc_info() if self.is_important_traceback(realname, tb): raise exc_type, exc_value, tb
<mask> realname = path % modname <mask> try: <mask> __import__(realname) <mask> except ImportError: <mask> continue <mask> module = sys.modules[fullname] = sys.modules[realname] <mask> if '.' not in modname: <mask> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9a70e62b8d545c8de7e3728e544cebe289a39254
scripts/flaskext_compat.py
raise ImportError('No module named %s' % fullname) def is_important_traceback(self, important_module, tb): """Walks a traceback's frames and checks if any of the frames originated in the given important module. If that is the case then we were able to import the module itself but a...
<mask> module = sys.modules[fullname] = sys.modules[realname] <mask> if '.' not in modname: <mask> setattr(ext_module, modname, module) <mask> return module <mask> raise ImportError(fullname) <mask> <mask> <mask> def activate(): <mask> """Activa...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9a70e62b8d545c8de7e3728e544cebe289a39254
scripts/flaskext_compat.py
<mask> <mask> app = Flask(__name__) <mask> app.register_blueprint(simple_page) <mask> # Blueprint can be registered many times <mask> app.register_blueprint(simple_page, url_prefix='/pages') <mask> <mask> <mask> if __name__ == '__main__': <mask> app.run(debug=True) </s> Updated the examples to be cli b...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace" ]
https://github.com/pallets/flask/commit/9ab59871007c12fad03f43ac08f889e4c080e64d
examples/blueprintexample/blueprintexample.py
2. initialize the database with this command: flask --app=flaskr initdb 3. now you can run flaskr: flask --app=flaskr run the application will greet you on http://localhost:5000/
<mask> 1. edit the configuration in the flaskr.py file or <mask> export an FLASKR_SETTINGS environment variable <mask> pointing to a configuration file. <mask> <mask> 2. now you can run the flaskr.py file with your <mask> python interpreter and the application will <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9ab59871007c12fad03f43ac08f889e4c080e64d
examples/flaskr/README
<mask> <mask> @app.route('/') <mask> def index(): <mask> return render_template('index.html') <mask> <mask> <mask> if __name__ == '__main__': <mask> app.run() </s> Updated the examples to be cli based </s> remove if __name__ == '__main__': app.run() </s> add </s> remove if __name__ == '__m...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace" ]
https://github.com/pallets/flask/commit/9ab59871007c12fad03f43ac08f889e4c080e64d
examples/jqueryexample/jqueryexample.py
2. fire up a shell and run this:
<mask> 1. edit the configuration in the minitwit.py file or <mask> export an MINITWIT_SETTINGS environment variable <mask> pointing to a configuration file. <mask> <mask> 2. fire up a python shell and run this: <mask> <mask> >>> from minitwit import init_db; init_db() <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9ab59871007c12fad03f43ac08f889e4c080e64d
examples/minitwit/README
flask --app=minitwit initdb
<mask> pointing to a configuration file. <mask> <mask> 2. fire up a python shell and run this: <mask> <mask> >>> from minitwit import init_db; init_db() <mask> <mask> 3. now you can run the minitwit.py file with your <mask> python interpreter and the application will <...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9ab59871007c12fad03f43ac08f889e4c080e64d
examples/minitwit/README
3. now you can run minitwit: flask --app=minitwit run the application will greet you on http://localhost:5000/
<mask> 2. fire up a python shell and run this: <mask> <mask> >>> from minitwit import init_db; init_db() <mask> <mask> 3. now you can run the minitwit.py file with your <mask> python interpreter and the application will <mask> greet you on http://localhost:5000/ <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9ab59871007c12fad03f43ac08f889e4c080e64d
examples/minitwit/README
@app.cli.command() def initdb():
<mask> if hasattr(top, 'sqlite_db'): <mask> top.sqlite_db.close() <mask> <mask> <mask> def init_db(): <mask> """Creates the database tables.""" <mask> with app.app_context(): <mask> db = get_db() <mask> with app.open_resource('schema.sql', mode='r') as f: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9ab59871007c12fad03f43ac08f889e4c080e64d
examples/minitwit/minitwit.py
db = get_db() with app.open_resource('schema.sql', mode='r') as f: db.cursor().executescript(f.read()) db.commit()
<mask> <mask> <mask> def init_db(): <mask> """Creates the database tables.""" <mask> with app.app_context(): <mask> db = get_db() <mask> with app.open_resource('schema.sql', mode='r') as f: <mask> db.cursor().executescript(f.read()) <mask> db.commit() <mask> <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9ab59871007c12fad03f43ac08f889e4c080e64d
examples/minitwit/minitwit.py
'@' not in request.form['email']:
<mask> if request.method == 'POST': <mask> if not request.form['username']: <mask> error = 'You have to enter a username' <mask> elif not request.form['email'] or \ <mask> '@' not in request.form['email']: <mask> error = 'You have to enter a valid email...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9ab59871007c12fad03f43ac08f889e4c080e64d
examples/minitwit/minitwit.py
<mask> <mask> # add some filters to jinja <mask> app.jinja_env.filters['datetimeformat'] = format_datetime <mask> app.jinja_env.filters['gravatar'] = gravatar_url <mask> <mask> <mask> if __name__ == '__main__': <mask> init_db() <mask> app.run() </s> Updated the examples to be cli based </s> remove ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace" ]
https://github.com/pallets/flask/commit/9ab59871007c12fad03f43ac08f889e4c080e64d
examples/minitwit/minitwit.py
<mask> out again. <mask> """ <mask> session.clear() <mask> return 'OK' <mask> <mask> <mask> if __name__ == '__main__': <mask> app.run() </s> Updated the examples to be cli based </s> remove if __name__ == '__main__': app.run() </s> add </s> remove if __name__ == '__main__': ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace" ]
https://github.com/pallets/flask/commit/9ab59871007c12fad03f43ac08f889e4c080e64d
examples/persona/persona.py
T_before_first_request = t.TypeVar( "T_before_first_request", bound=ft.BeforeFirstRequestCallable ) T_shell_context_processor = t.TypeVar( "T_shell_context_processor", bound=ft.ShellContextProcessorCallable ) T_teardown = t.TypeVar("T_teardown", bound=ft.TeardownCallable) T_template_filter = t.TypeVar("T_templa...
<mask> from .testing import FlaskCliRunner <mask> <mask> if sys.version_info >= (3, 8): <mask> iscoroutinefunction = inspect.iscoroutinefunction <mask> else: <mask> </s> Improve decorator typing (#4676) * Add a missing setupmethod decorator * Improve the decorator typing This will allow type che...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
self.shell_context_processors: t.List[ft.ShellContextProcessorCallable] = []
<mask> #: A list of shell context processor functions that should be run <mask> #: when a shell context is created. <mask> #: <mask> #: .. versionadded:: 0.11 <mask> self.shell_context_processors: t.List[t.Callable[[], t.Dict[str, t.Any]]] = [] <mask> <mask> #: Ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
view_func: t.Optional[ft.RouteCallable] = None,
<mask> def add_url_rule( <mask> self, <mask> rule: str, <mask> endpoint: t.Optional[str] = None, <mask> view_func: t.Optional[ft.ViewCallable] = None, <mask> provide_automatic_options: t.Optional[bool] = None, <mask> **options: t.Any, <mask> ) -> None: <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
) -> t.Callable[[T_template_filter], T_template_filter]:
<mask> <mask> @setupmethod <mask> def template_filter( <mask> self, name: t.Optional[str] = None <mask> ) -> t.Callable[[ft.TemplateFilterCallable], ft.TemplateFilterCallable]: <mask> """A decorator that is used to register custom template filter. <mask> You can specify a nam...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
def decorator(f: T_template_filter) -> T_template_filter:
<mask> :param name: the optional name of the filter, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f: ft.TemplateFilterCallable) -> ft.TemplateFilterCallable: <mask> self.add_template_filter(f, name=name) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
) -> t.Callable[[T_template_test], T_template_test]:
<mask> <mask> @setupmethod <mask> def template_test( <mask> self, name: t.Optional[str] = None <mask> ) -> t.Callable[[ft.TemplateTestCallable], ft.TemplateTestCallable]: <mask> """A decorator that is used to register custom template test. <mask> You can specify a name for th...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
def decorator(f: T_template_test) -> T_template_test:
<mask> :param name: the optional name of the test, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f: ft.TemplateTestCallable) -> ft.TemplateTestCallable: <mask> self.add_template_test(f, name=name) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
) -> t.Callable[[T_template_global], T_template_global]:
<mask> <mask> @setupmethod <mask> def template_global( <mask> self, name: t.Optional[str] = None <mask> ) -> t.Callable[[ft.TemplateGlobalCallable], ft.TemplateGlobalCallable]: <mask> """A decorator that is used to register a custom template global function. <mask> You can sp...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
def decorator(f: T_template_global) -> T_template_global:
<mask> :param name: the optional name of the global function, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f: ft.TemplateGlobalCallable) -> ft.TemplateGlobalCallable: <mask> self.add_template_global(f, name=name) ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
def before_first_request(self, f: T_before_first_request) -> T_before_first_request:
<mask> """ <mask> self.jinja_env.globals[name or f.__name__] = f <mask> <mask> @setupmethod <mask> def before_first_request( <mask> self, f: ft.BeforeFirstRequestCallable <mask> ) -> ft.BeforeFirstRequestCallable: <mask> """Registers a function to be run before the f...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
def teardown_appcontext(self, f: T_teardown) -> T_teardown:
<mask> self.before_first_request_funcs.append(f) <mask> return f <mask> <mask> @setupmethod <mask> def teardown_appcontext(self, f: ft.TeardownCallable) -> ft.TeardownCallable: <mask> """Registers a function to be called when the application context <mask> ends. These fu...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
def shell_context_processor( self, f: T_shell_context_processor ) -> T_shell_context_processor:
<mask> self.teardown_appcontext_funcs.append(f) <mask> return f <mask> <mask> @setupmethod <mask> def shell_context_processor(self, f: t.Callable) -> t.Callable: <mask> """Registers a shell context processor function. <mask> <mask> .. versionadded:: 0.11 <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/app.py
self.record(update_wrapper(wrapper, func))
<mask> def wrapper(state: BlueprintSetupState) -> None: <mask> if state.first_registration: <mask> func(state) <mask> <mask> return self.record(update_wrapper(wrapper, func)) <mask> <mask> def make_setup_state( <mask> self, app: "Flask", options: dict, f...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py
view_func: t.Optional[ft.RouteCallable] = None,
<mask> def add_url_rule( <mask> self, <mask> rule: str, <mask> endpoint: t.Optional[str] = None, <mask> view_func: t.Optional[ft.ViewCallable] = None, <mask> provide_automatic_options: t.Optional[bool] = None, <mask> **options: t.Any, <mask> ) -> None: <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py
) -> t.Callable[[T_template_filter], T_template_filter]:
<mask> <mask> @setupmethod <mask> def app_template_filter( <mask> self, name: t.Optional[str] = None <mask> ) -> t.Callable[[ft.TemplateFilterCallable], ft.TemplateFilterCallable]: <mask> """Register a custom template filter, available application wide. Like <mask> :meth:`Fl...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py
def decorator(f: T_template_filter) -> T_template_filter:
<mask> :param name: the optional name of the filter, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f: ft.TemplateFilterCallable) -> ft.TemplateFilterCallable: <mask> self.add_app_template_filter(f, name=name) <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py
) -> t.Callable[[T_template_test], T_template_test]:
<mask> <mask> @setupmethod <mask> def app_template_test( <mask> self, name: t.Optional[str] = None <mask> ) -> t.Callable[[ft.TemplateTestCallable], ft.TemplateTestCallable]: <mask> """Register a custom template test, available application wide. Like <mask> :meth:`Flask.temp...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py
def decorator(f: T_template_test) -> T_template_test:
<mask> :param name: the optional name of the test, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f: ft.TemplateTestCallable) -> ft.TemplateTestCallable: <mask> self.add_app_template_test(f, name=name) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py
) -> t.Callable[[T_template_global], T_template_global]:
<mask> <mask> @setupmethod <mask> def app_template_global( <mask> self, name: t.Optional[str] = None <mask> ) -> t.Callable[[ft.TemplateGlobalCallable], ft.TemplateGlobalCallable]: <mask> """Register a custom template global, available application wide. Like <mask> :meth:`Fl...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py
def decorator(f: T_template_global) -> T_template_global:
<mask> :param name: the optional name of the global, otherwise the <mask> function name will be used. <mask> """ <mask> <mask> def decorator(f: ft.TemplateGlobalCallable) -> ft.TemplateGlobalCallable: <mask> self.add_app_template_global(f, name=name) <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py
def before_app_request(self, f: T_before_request) -> T_before_request:
<mask> <mask> self.record_once(register_template) <mask> <mask> @setupmethod <mask> def before_app_request( <mask> self, f: ft.BeforeRequestCallable <mask> ) -> ft.BeforeRequestCallable: <mask> """Like :meth:`Flask.before_request`. Such a function is executed <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py
self, f: T_before_first_request ) -> T_before_first_request:
<mask> return f <mask> <mask> @setupmethod <mask> def before_app_first_request( <mask> self, f: ft.BeforeFirstRequestCallable <mask> ) -> ft.BeforeFirstRequestCallable: <mask> """Like :meth:`Flask.before_first_request`. Such a function is <mask> executed before the ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py
@setupmethod def after_app_request(self, f: T_after_request) -> T_after_request:
<mask> ) <mask> self.record_once(lambda s: s.app.before_first_request_funcs.append(f)) <mask> return f <mask> <mask> def after_app_request(self, f: ft.AfterRequestCallable) -> ft.AfterRequestCallable: <mask> """Like :meth:`Flask.after_request` but for a blueprint. Such a func...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py
def teardown_app_request(self, f: T_teardown) -> T_teardown:
<mask> ) <mask> return f <mask> <mask> @setupmethod <mask> def teardown_app_request(self, f: ft.TeardownCallable) -> ft.TeardownCallable: <mask> """Like :meth:`Flask.teardown_request` but for a blueprint. Such a <mask> function is executed when tearing down each request,...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9b44bf2818d8e3cde422ad7f43fb33dfc6737289
src/flask/blueprints.py