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 |
|---|---|---|---|---|
def test_error_handler_subclass(app): | <mask> assert c.get('/custom').data == b'custom'
<mask> assert c.get('/keyerror').data == b'KeyError'
<mask>
<mask>
<mask> def test_error_handler_subclass():
<mask> app = flask.Flask(__name__)
<mask>
<mask> class ParentException(Exception):
<mask> pass
<mask>
<mask> class Chil... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_user_error_handler.py |
def test_error_handler_http_subclass(app): | <mask> assert c.get('/child-unregistered').data == b'parent'
<mask> assert c.get('/child-registered').data == b'child-registered'
<mask>
<mask>
<mask> def test_error_handler_http_subclass():
<mask> app = flask.Flask(__name__)
<mask>
<mask> class ForbiddenSubclassRegistered(Forbidden):
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_user_error_handler.py |
def test_error_handler_blueprint(app): | <mask> assert c.get('/forbidden-unregistered').data == b'forbidden'
<mask> assert c.get('/forbidden-registered').data == b'forbidden-registered'
<mask>
<mask>
<mask> def test_error_handler_blueprint():
<mask> bp = flask.Blueprint('bp', __name__)
<mask>
<mask> @bp.errorhandler(500)
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_user_error_handler.py |
<mask> @bp.route('/error')
<mask> def bp_test():
<mask> raise InternalServerError()
<mask>
<mask> app = flask.Flask(__name__)
<mask>
<mask> @app.errorhandler(500)
<mask> def app_exception_handler(e):
<mask> return 'app-error'
<mask>
<mask> @app.route('/error')
</s>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_user_error_handler.py | |
<mask> assert c.put('/').status_code == 405
<mask> meths = parse_set_header(c.open('/', method='OPTIONS').headers['Allow'])
<mask> assert sorted(meths) == ['GET', 'HEAD', 'OPTIONS', 'POST']
<mask>
<mask> def test_basic_view():
<mask> app = flask.Flask(__name__)
<mask>
<mask> class Index(fl... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py | |
def test_basic_view(app): | <mask> meths = parse_set_header(c.open('/', method='OPTIONS').headers['Allow'])
<mask> assert sorted(meths) == ['GET', 'HEAD', 'OPTIONS', 'POST']
<mask>
<mask>
<mask> class Index(flask.views.View):
<mask> methods = ['GET', 'POST']
<mask>
<mask> def dispatch_request(self):
<mask> ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py |
<mask>
<mask> app.add_url_rule('/', view_func=Index.as_view('index'))
<mask> common_test(app)
<mask>
<mask> def test_method_based_view():
<mask> app = flask.Flask(__name__)
<mask>
<mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> return 'GET'
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py | |
def test_method_based_view(app): | <mask> common_test(app)
<mask>
<mask>
<mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> return 'GET'
<mask>
</s> DRYing up the test suite using pytest fixtures (#2306)
* add fixtures to conftest.py
* use fixtures in test_appctx.py
* use fixtures in te... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py |
<mask> app.add_url_rule('/', view_func=Index.as_view('index'))
<mask>
<mask> common_test(app)
<mask>
<mask> def test_view_patching():
<mask> app = flask.Flask(__name__)
<mask>
<mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> 1 // 0
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py | |
def test_view_patching(app): | <mask>
<mask> common_test(app)
<mask>
<mask>
<mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> 1 // 0
<mask>
<mask> def post(self):
</s> DRYing up the test suite using pytest fixtures (#2306)
* add fixtures to conftest.py
* use fixtures in tes... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py |
<mask> view.view_class = Other
<mask> app.add_url_rule('/', view_func=view)
<mask> common_test(app)
<mask>
<mask> def test_view_inheritance():
<mask> app = flask.Flask(__name__)
<mask>
<mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> return 'GE... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py | |
def test_view_inheritance(app): | <mask> app.add_url_rule('/', view_func=view)
<mask> common_test(app)
<mask>
<mask>
<mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> return 'GET'
<mask>
<mask> def post(self):
</s> DRYing up the test suite using pytest fixtures (#2306)
* add f... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py |
<mask>
<mask> meths = parse_set_header(c.open('/', method='OPTIONS').headers['Allow'])
<mask> assert sorted(meths) == ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST']
<mask>
<mask> def test_view_decorators():
<mask> app = flask.Flask(__name__)
<mask>
<mask> def add_x_parachute(f):
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py | |
def test_view_decorators(app): | <mask> assert sorted(meths) == ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST']
<mask>
<mask>
<mask> def add_x_parachute(f):
<mask> def new_function(*args, **kwargs):
<mask> resp = flask.make_response(f(*args, **kwargs))
<mask> resp.headers['X-Parachute'] = 'awesome'
<mask>... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py |
<mask> c = app.test_client()
<mask> rv = c.open('/', method='OPTIONS')
<mask> assert 'OPTIONS' in rv.allow
<mask>
<mask> def test_implicit_head():
<mask> app = flask.Flask(__name__)
<mask>
<mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> return... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py | |
def test_implicit_head(app): | <mask> assert 'OPTIONS' in rv.allow
<mask>
<mask>
<mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> return flask.Response('Blub', headers={
<mask> 'X-Method': flask.request.method
<mask> })
</s> DRYing up the test suite using pyte... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py |
<mask> rv = c.head('/')
<mask> assert rv.data == b''
<mask> assert rv.headers['X-Method'] == 'HEAD'
<mask>
<mask> def test_explicit_head():
<mask> app = flask.Flask(__name__)
<mask>
<mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> return 'GET'
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py | |
def test_explicit_head(app): | <mask>
<mask>
<mask> class Index(flask.views.MethodView):
<mask> def get(self):
<mask> return 'GET'
<mask>
</s> DRYing up the test suite using pytest fixtures (#2306)
* add fixtures to conftest.py
* use fixtures in test_appctx.py
* use fixtures in test_blueprints.py
* use fix... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py |
def test_endpoint_override(app): | <mask> rv = c.head('/')
<mask> assert rv.data == b''
<mask> assert rv.headers['X-Method'] == 'HEAD'
<mask>
<mask> def test_endpoint_override():
<mask> app = flask.Flask(__name__)
<mask> app.debug = True
<mask>
<mask> class Index(flask.views.View):
<mask> methods = ['GET', 'PO... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py |
<mask>
<mask> # But these tests should still pass. We just log a warning.
<mask> common_test(app)
<mask>
<mask> def test_multiple_inheritance():
<mask> app = flask.Flask(__name__)
<mask>
<mask> class GetView(flask.views.MethodView):
<mask> def get(self):
<mask> return 'G... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py | |
def test_multiple_inheritance(app): | <mask> common_test(app)
<mask>
<mask>
<mask> class GetView(flask.views.MethodView):
<mask> def get(self):
<mask> return 'GET'
<mask>
<mask> class DeleteView(flask.views.MethodView):
<mask> def delete(self):
</s> DRYing up the test suite using pytest fixtures (#2306)
... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py |
<mask> assert c.get('/').data == b'GET'
<mask> assert c.delete('/').data == b'DELETE'
<mask> assert sorted(GetDeleteView.methods) == ['DELETE', 'GET']
<mask>
<mask> def test_remove_method_from_parent():
<mask> app = flask.Flask(__name__)
<mask>
<mask> class GetView(flask.views.MethodView):... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py | |
def test_remove_method_from_parent(app): | <mask>
<mask>
<mask> class GetView(flask.views.MethodView):
<mask> def get(self):
<mask> return 'GET'
<mask>
</s> DRYing up the test suite using pytest fixtures (#2306)
* add fixtures to conftest.py
* use fixtures in test_appctx.py
* use fixtures in test_blueprints.py
* use f... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_views.py |
- Require Werkzeug >= 2.3.7. | <mask>
<mask> Unreleased
<mask>
<mask> - Python 3.12 compatibility.
<mask> - Require Werkzeug >= 2.3.6.
<mask> - Use ``flit_core`` instead of ``setuptools`` as build backend.
<mask> - Refactor how an app's root and instance paths are determined. :issue:`5160`
<mask>
<mask>
<mask> Version 2.3.2
</... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | CHANGES.rst |
"Werkzeug>=2.3.7", | <mask> "Topic :: Software Development :: Libraries :: Application Frameworks",
<mask> ]
<mask> requires-python = ">=3.8"
<mask> dependencies = [
<mask> "Werkzeug>=2.3.6",
<mask> "Jinja2>=3.1.2",
<mask> "itsdangerous>=2.1.2",
<mask> "click>=8.1.3",
<mask> "blinker>=1.6.2",
<mask> "i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | pyproject.toml |
Werkzeug==2.3.7 | <mask> Werkzeug==2.3.6
<mask> Jinja2==3.1.2
<mask> MarkupSafe==2.1.1
<mask> itsdangerous==2.1.2
<mask> click==8.1.3
<mask> blinker==1.6.2
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove client.environ_base["REMOTE_ADDR"] = "0.0.0.1"
client.environ_base["HTTP_USER_AGENT"] = "Bar"
... | [
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | requirements/tests-pallets-min.in |
# SHA1:fe057f95a98251b053eec8fa27df0feb722c70e8 | <mask> # SHA1:5bd33f1c06b3fb16f7ab50e80ed309655d110713
<mask> #
<mask> # This file is autogenerated by pip-compile-multi
<mask> # To update, run:
<mask> #
<mask> # pip-compile-multi
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove werkzeug==2.3.6
</s> add werkzeug==2.3.7 </s> remove c... | [
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | requirements/tests-pallets-min.txt |
werkzeug==2.3.7 | <mask> # via
<mask> # -r requirements/tests-pallets-min.in
<mask> # jinja2
<mask> # werkzeug
<mask> werkzeug==2.3.6
<mask> # via -r requirements/tests-pallets-min.in
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove # SHA1:5bd33f1c06b3fb16f7ab50e80ed309655d110713
</s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | requirements/tests-pallets-min.txt |
import importlib.metadata | <mask> from __future__ import annotations
<mask>
<mask> import ast
<mask> import inspect
<mask> import os
<mask> import platform
<mask> import re
<mask> import sys
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove import werkzeug
</s> add </s> remove from flask import __version__ as f... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | src/flask/cli.py |
flask_version = importlib.metadata.version("flask")
werkzeug_version = importlib.metadata.version("werkzeug") | <mask> def get_version(ctx, param, value):
<mask> if not value or ctx.resilient_parsing:
<mask> return
<mask>
<mask> import werkzeug
<mask> from . import __version__
<mask>
<mask> click.echo(
<mask> f"Python {platform.python_version()}\n"
<mask> f"Flask {__version__}\... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | src/flask/cli.py |
f"Flask {flask_version}\n"
f"Werkzeug {werkzeug_version}", | <mask> from . import __version__
<mask>
<mask> click.echo(
<mask> f"Python {platform.python_version()}\n"
<mask> f"Flask {__version__}\n"
<mask> f"Werkzeug {werkzeug.__version__}",
<mask> color=ctx.color,
<mask> )
<mask> ctx.exit()
<mask>
<mask>
</s> bump w... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | src/flask/cli.py |
import importlib.metadata | <mask> from __future__ import annotations
<mask>
<mask> import typing as t
<mask> from contextlib import contextmanager
<mask> from contextlib import ExitStack
<mask> from copy import copy
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove import werkzeug
</s> add </s> remove from flask ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | src/flask/testing.py |
_werkzeug_version = ""
def _get_werkzeug_version() -> str:
global _werkzeug_version
if not _werkzeug_version:
_werkzeug_version = importlib.metadata.version("werkzeug")
return _werkzeug_version
| <mask> """
<mask> return self.app.json.dumps(obj, **kwargs)
<mask>
<mask>
<mask> class FlaskClient(Client):
<mask> """Works like a regular Werkzeug test client but has knowledge about
<mask> Flask's contexts to defer the cleanup of the request context until
<mask> the end of a ``wi... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | src/flask/testing.py |
"HTTP_USER_AGENT": f"Werkzeug/{_get_werkzeug_version()}", | <mask> self._new_contexts: list[t.ContextManager[t.Any]] = []
<mask> self._context_stack = ExitStack()
<mask> self.environ_base = {
<mask> "REMOTE_ADDR": "127.0.0.1",
<mask> "HTTP_USER_AGENT": f"werkzeug/{werkzeug.__version__}",
<mask> }
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | src/flask/testing.py |
<mask> locate_app("cliapp.importerrorapp", None, raise_if_not_found=False)
<mask>
<mask>
<mask> def test_get_version(test_apps, capsys):
<mask> from flask import __version__ as flask_version
<mask> from werkzeug import __version__ as werkzeug_version
<mask> from platform import python_versi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | tests/test_cli.py | |
assert f"Python {platform.python_version()}" in out
assert f"Flask {importlib.metadata.version('flask')}" in out
assert f"Werkzeug {importlib.metadata.version('werkzeug')}" in out | <mask>
<mask> ctx = MockCtx()
<mask> get_version(ctx, None, "test")
<mask> out, err = capsys.readouterr()
<mask> assert f"Python {python_version()}" in out
<mask> assert f"Flask {flask_version}" in out
<mask> assert f"Werkzeug {werkzeug_version}" in out
<mask>
<mask>
<mask> def test... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | tests/test_cli.py |
<mask> import click
<mask> import pytest
<mask> import werkzeug
<mask>
<mask> import flask
<mask> from flask import appcontext_popped
<mask> from flask.cli import ScriptInfo
<mask> from flask.globals import _cv_request
</s> bump werkzeug 2.3.7
use importlib.metadata.version </s> remove from flask import ... | [
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | tests/test_testing.py | |
def test_environ_base_default(app, client): | <mask> rv = client.get("/")
<mask> assert rv.data == b"http://localhost/"
<mask>
<mask>
<mask> def test_environ_base_default(app, client, app_ctx):
<mask> @app.route("/")
<mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Agent"]
<mask> return ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | tests/test_testing.py |
flask.g.remote_addr = flask.request.remote_addr
flask.g.user_agent = flask.request.user_agent.string
return "" | <mask>
<mask> def test_environ_base_default(app, client, app_ctx):
<mask> @app.route("/")
<mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Agent"]
<mask> return flask.request.remote_addr
<mask>
<mask> rv = client.get("/")
<mask> assert rv.data == b"1... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | tests/test_testing.py |
with client:
client.get("/")
assert flask.g.remote_addr == "127.0.0.1"
assert flask.g.user_agent == (
f"Werkzeug/{importlib.metadata.version('werkzeug')}"
) | <mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Agent"]
<mask> return flask.request.remote_addr
<mask>
<mask> rv = client.get("/")
<mask> assert rv.data == b"127.0.0.1"
<mask> assert flask.g.user_agent == f"werkzeug/{werkzeug.__version__}"
<mask>
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | tests/test_testing.py |
def test_environ_base_modified(app, client): | <mask> assert rv.data == b"127.0.0.1"
<mask> assert flask.g.user_agent == f"werkzeug/{werkzeug.__version__}"
<mask>
<mask>
<mask> def test_environ_base_modified(app, client, app_ctx):
<mask> @app.route("/")
<mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Age... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | tests/test_testing.py |
flask.g.remote_addr = flask.request.remote_addr
flask.g.user_agent = flask.request.user_agent.string
return "" | <mask>
<mask> def test_environ_base_modified(app, client, app_ctx):
<mask> @app.route("/")
<mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Agent"]
<mask> return flask.request.remote_addr
<mask>
<mask> client.environ_base["REMOTE_ADDR"] = "0.0.0.0"
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | tests/test_testing.py |
client.environ_base["REMOTE_ADDR"] = "192.168.0.22" | <mask> def index():
<mask> flask.g.user_agent = flask.request.headers["User-Agent"]
<mask> return flask.request.remote_addr
<mask>
<mask> client.environ_base["REMOTE_ADDR"] = "0.0.0.0"
<mask> client.environ_base["HTTP_USER_AGENT"] = "Foo"
<mask> rv = client.get("/")
<mask> a... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | tests/test_testing.py |
<mask> return flask.request.remote_addr
<mask>
<mask> client.environ_base["REMOTE_ADDR"] = "0.0.0.0"
<mask> client.environ_base["HTTP_USER_AGENT"] = "Foo"
<mask> rv = client.get("/")
<mask> assert rv.data == b"0.0.0.0"
<mask> assert flask.g.user_agent == "Foo"
<mask>
<mask> cl... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | tests/test_testing.py | |
with client:
client.get("/")
assert flask.g.remote_addr == "192.168.0.22"
assert flask.g.user_agent == "Foo" | <mask> rv = client.get("/")
<mask> assert rv.data == b"0.0.0.0"
<mask> assert flask.g.user_agent == "Foo"
<mask>
<mask> client.environ_base["REMOTE_ADDR"] = "0.0.0.1"
<mask> client.environ_base["HTTP_USER_AGENT"] = "Bar"
<mask> rv = client.get("/")
<mask> assert rv.data == b"0.0.0.1... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5bb30270d2e68d8d9278ac6f5abf67049acba662 | tests/test_testing.py |
state.app.add_url_rule(rule, '%s.%s' % (self.name, endpoint),
view_func, **options) | <mask>
<mask> def _register_rule(self, state, rule, endpoint, view_func, options):
<mask> if self.url_prefix:
<mask> rule = state.url_prefix + rule
<mask> self.app.add_url_rule(rule, '%s.%s' % (self.name, endpoint),
<mask> view_func, **options)
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c52fe980eda6065edcc39e6dd346636b1c40768 | flask.py |
options.setdefault('url_prefix', module.url_prefix)
state = _ModuleSetupState(self, **options) | <mask> session.save_cookie(response, self.session_cookie_name)
<mask>
<mask> def register_module(self, module, **options):
<mask> """Registers a module with this application."""
<mask> options.setdefault('url_prefix', self.url_prefix)
<mask> state = _ModuleSetupState(app, opti... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c52fe980eda6065edcc39e6dd346636b1c40768 | flask.py |
funcs = () | <mask> ctx = _request_ctx_stack.top
<mask> mod = ctx.request.module
<mask> if not isinstance(ctx.session, _NullSession):
<mask> self.save_session(ctx.session, response)
<mask> funcs = self.after_request_funcs.get(None, ())
<mask> if mod and mod in self.after_req... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c52fe980eda6065edcc39e6dd346636b1c40768 | flask.py |
if None in self.after_request_funcs:
funcs = chain(funcs, self.after_request_funcs[None]) | <mask> funcs = ()
<mask> if mod and mod in self.after_request_funcs:
<mask> funcs = chain(funcs, self.after_request_funcs[mod])
<mask> for handler in funcs:
<mask> response = handler(response)
<mask> return response
<mask>
<mask> def wsgi_app(self, en... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c52fe980eda6065edcc39e6dd346636b1c40768 | flask.py |
app.register_module(admin) | <mask> return 'admin logout'
<mask> @app.route('/')
<mask> def index():
<mask> return 'the index'
<mask> app.register_module('admin', admin)
<mask> c = app.test_client()
<mask> assert c.get('/').data == 'the index'
<mask> assert c.get('/adm... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c52fe980eda6065edcc39e6dd346636b1c40768 | tests/flask_tests.py |
suite.addTest(unittest.makeSuite(ModuleTestCase)) | <mask> if flask.json_available:
<mask> suite.addTest(unittest.makeSuite(JSONTestCase))
<mask> suite.addTest(unittest.makeSuite(MiniTwitTestCase))
<mask> suite.addTest(unittest.makeSuite(FlaskrTestCase))
<mask> return suite
<mask>
<mask>
<mask> if __name__ == '__main__':
<mask> uni... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c52fe980eda6065edcc39e6dd346636b1c40768 | tests/flask_tests.py |
if getattr(old_func, "_flask_sync_wrapper", False):
old_func = old_func.__wrapped__ | <mask> if view_func is not None:
<mask> old_func = self.view_functions.get(endpoint)
<mask> if old_func is not None and old_func != view_func:
<mask> raise AssertionError(
<mask> "View function mapping is overwriting an existing"
<mask> ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c6a0f0c121297362b4c78e4240dd8445b9d9f12 | src/flask/app.py |
outer._flask_sync_wrapper = True | <mask>
<mask> return async_to_sync(inner)(*args, **kwargs)
<mask>
<mask> return outer
</s> Fix wrapped view function comparison
Wrapped functions are not comparable, see
https://bugs.python.org/issue3564, therefore a marker is used to note
when the function has been sync wrapped to allow comparison ... | [
"keep",
"keep",
"add",
"keep"
] | https://github.com/pallets/flask/commit/5c6a0f0c121297362b4c78e4240dd8445b9d9f12 | src/flask/helpers.py |
@app.route("/home", methods=["GET", "POST"]) | <mask> def _async_app():
<mask> app = Flask(__name__)
<mask>
<mask> @app.route("/", methods=["GET", "POST"])
<mask> async def index():
<mask> await asyncio.sleep(0)
<mask> return request.method
<mask>
</s> Fix wrapped view function comparison
Wrapped functions are not comparable,... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c6a0f0c121297362b4c78e4240dd8445b9d9f12 | tests/test_async.py |
@pytest.mark.parametrize("path", ["/", "/home", "/bp/"]) | <mask> return app
<mask>
<mask>
<mask> @pytest.mark.skipif(sys.version_info < (3, 7), reason="requires Python >= 3.7")
<mask> @pytest.mark.parametrize("path", ["/", "/bp/"])
<mask> def test_async_route(path, async_app):
<mask> test_client = async_app.test_client()
<mask> response = test_client.get... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c6a0f0c121297362b4c78e4240dd8445b9d9f12 | tests/test_async.py |
from collections import OrderedDict
| <mask> import io
<mask> import re
<mask> from setuptools import setup
<mask>
<mask> with io.open('README.rst', 'rt', encoding='utf8') as f:
<mask> readme = f.read()
<mask>
<mask> with io.open('flask/__init__.py', 'rt', encoding='utf8') as f:
</s> ensure order of project urls </s> remove project_urls=... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c8110de25f08bf20e9fda6611403dc5c59ec849 | setup.py |
project_urls=OrderedDict((
('Documentation', 'http://flask.pocoo.org/docs/'),
('Code', 'https://github.com/pallets/pallets-sphinx-themes'),
('Issue tracker', 'https://github.com/pallets/pallets-sphinx-themes/issues'),
)), | <mask> version=version,
<mask> url='https://www.palletsprojects.com/p/flask/',
<mask> license='BSD',
<mask> author='Armin Ronacher',
<mask> author_email='armin.ronacher@active-4.com',
<mask> maintainer='Pallets team',
<mask> maintainer_email='contact@palletsprojects.com',
<mask> ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c8110de25f08bf20e9fda6611403dc5c59ec849 | setup.py |
<mask> packages=['flask', 'flask.json'],
<mask> include_package_data=True,
<mask> zip_safe=False,
<mask> platforms='any',
<mask> project_urls={
<mask> 'Bug Tracker': 'https://github.com/pallets/flask/issues',
<mask> 'Documentation': 'http://flask.pocoo.org/',
<mask> '... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c8110de25f08bf20e9fda6611403dc5c59ec849 | setup.py | |
def template_filter(self, name=None): | <mask> self.error_handlers[code] = f
<mask> return f
<mask> return decorator
<mask>
<mask> def template_filter(self, arg=None):
<mask> """A decorator that is used to register custom template filter.
<mask> You can specify a name for the filter, otherwise the f... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c9ef2c44dce5afc99a0b3b539ebaafe9b8ce3c5 | flask.py |
@app.template_filter() | <mask> """A decorator that is used to register custom template filter.
<mask> You can specify a name for the filter, otherwise the function
<mask> name will be used. Example::
<mask>
<mask> @app.template_filter
<mask> def reverse(s):
<mask> return s[::-1... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c9ef2c44dce5afc99a0b3b539ebaafe9b8ce3c5 | flask.py |
<mask>
<mask> :param name: the optional name of the filter, otherwise the
<mask> function name will be used.
<mask> """
<mask> if type(arg) is types.FunctionType:
<mask> self.jinja_env.filters[arg.__name__] = arg
<mask> return arg
<mask>
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c9ef2c44dce5afc99a0b3b539ebaafe9b8ce3c5 | flask.py | |
self.jinja_env.filters[name or f.__name__] = f | <mask> self.jinja_env.filters[arg.__name__] = arg
<mask> return arg
<mask>
<mask> def decorator(f):
<mask> self.jinja_env.filters[arg or f.__name__] = f
<mask> return f
<mask> return decorator
<mask>
<mask> def before_request(self, f):
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5c9ef2c44dce5afc99a0b3b539ebaafe9b8ce3c5 | flask.py |
def test_template_filter(self): | <mask> with app.test_request_context():
<mask> macro = flask.get_template_attribute('_macro.html', 'hello')
<mask> assert macro('World') == 'Hello World!'
<mask>
<mask> def test_template_filter_not_called(self):
<mask> app = flask.Flask(__name__)
<mask> @app.t... | [
"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/5c9ef2c44dce5afc99a0b3b539ebaafe9b8ce3c5 | tests/flask_tests.py |
.coverage
htmlcov | <mask> _mailinglist
<mask> .tox
<mask> .cache/
<mask> .idea/
</s> Added make target for test coverage, documented make commands </s> remove
Running the testsuite
---------------------
</s> add Getting Started
=============== | [
"keep",
"keep",
"keep",
"add"
] | https://github.com/pallets/flask/commit/5cadd4a348b4d42e22ddb2bfad93f74a4f34cc59 | .gitignore |
Getting Started
=============== | <mask>
<mask> - Try to follow `PEP8 <http://legacy.python.org/dev/peps/pep-0008/>`_, but you
<mask> may ignore the line-length-limit if following it would make the code uglier.
<mask>
<mask>
<mask> Running the testsuite
<mask> ---------------------
<mask>
<mask> You probably want to set up a `virtualenv
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5cadd4a348b4d42e22ddb2bfad93f74a4f34cc59 | CONTRIBUTING.rst |
cov:
pip install -r test-requirements.txt -q
FLASK_DEBUG= py.test --cov-report term --cov-report html --cov=flask --cov=examples tests examples
| <mask> tox-test:
<mask> pip install -r test-requirements.txt -q
<mask> tox
<mask>
<mask> audit:
<mask> python setup.py audit
<mask>
<mask> release:
</s> Added make target for test coverage, documented make commands </s> remove
Running the testsuite
---------------------
</s> add Getting Started
========... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5cadd4a348b4d42e22ddb2bfad93f74a4f34cc59 | Makefile |
from flask import Flask, flash, redirect, render_template, \
request, url_for
app = Flask(__name__)
app.secret_key = 'some_secret' | <mask> ---------------
<mask>
<mask> So here is a full example::
<mask>
<mask> from flask import flash, redirect, url_for, render_template
<mask>
<mask> @app.route('/')
<mask> def index():
<mask> return render_template('index.html')
<mask>
</s> Fix Message Flashing doc, from SwashBuck... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5cb50a46eeb29dddacf21d0348050e02ff96c3b5 | docs/patterns/flashing.rst |
request.form['password'] != 'secret': | <mask> def login():
<mask> error = None
<mask> if request.method == 'POST':
<mask> if request.form['username'] != 'admin' or \
<mask> request.form['password'] != 'secret':
<mask> error = 'Invalid credentials'
<mask> else:
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5cb50a46eeb29dddacf21d0348050e02ff96c3b5 | docs/patterns/flashing.rst |
if __name__ == "__main__":
app.run()
| <mask> return render_template('login.html', error=error)
<mask>
<mask> And here the ``layout.html`` template which does the magic:
<mask>
<mask> .. sourcecode:: html+jinja
<mask>
</s> Fix Message Flashing doc, from SwashBuckla #pocoo.
Provide a full example as promised in the doc. </s> remove ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5cb50a46eeb29dddacf21d0348050e02ff96c3b5 | docs/patterns/flashing.rst |
a configuration file. This is basically just a shortcut with nicer | <mask> self.root_path = root_path
<mask>
<mask> def from_envvar(self, variable_name, silent=False):
<mask> """Loads a configuration from an environment variable pointing to
<mask> a configuration file. This basically is just a shortcut with nicer
<mask> error messages for thi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5cc40f4728d5b5356cf49b7dfaa2b130e0b0aedf | flask/config.py |
:param silent: set to `True` if you want silent to fail for missing | <mask>
<mask> app.config.from_pyfile(os.environ['YOURAPPLICATION_SETTINGS'])
<mask>
<mask> :param variable_name: name of the environment variable
<mask> :param silent: set to `True` if you want silent failing for missing
<mask> files.
<mask> :return: b... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5cc40f4728d5b5356cf49b7dfaa2b130e0b0aedf | flask/config.py |
def from_pyfile(self, filename, silent=False): | <mask> variable_name)
<mask> self.from_pyfile(rv)
<mask> return True
<mask>
<mask> def from_pyfile(self, filename):
<mask> """Updates the values in the config from a Python file. This function
<mask> behaves as if the file was imported as modul... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5cc40f4728d5b5356cf49b7dfaa2b130e0b0aedf | flask/config.py |
:param silent: set to `True` if you want silent to fail for missing
files. | <mask>
<mask> :param filename: the filename of the config. This can either be an
<mask> absolute filename or a filename relative to the
<mask> root path.
<mask> """
<mask> filename = os.path.join(self.root_path, filename)
<mask> ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5cc40f4728d5b5356cf49b7dfaa2b130e0b0aedf | flask/config.py |
if silent and e.errno in (errno.ENOENT, errno.EISDIR):
return False | <mask> d.__file__ = filename
<mask> try:
<mask> execfile(filename, d.__dict__)
<mask> except IOError, e:
<mask> e.strerror = 'Unable to load configuration file (%s)' % e.strerror
<mask> raise
<mask> self.from_object(d)
<mask> return Tru... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5cc40f4728d5b5356cf49b7dfaa2b130e0b0aedf | flask/config.py |
return True | <mask> e.strerror = 'Unable to load configuration file (%s)' % e.strerror
<mask> raise
<mask> self.from_object(d)
<mask>
<mask> def from_object(self, obj):
<mask> """Updates the values from the given object. An object can be of one
<mask> of the following two... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5cc40f4728d5b5356cf49b7dfaa2b130e0b0aedf | flask/config.py |
- Remove the ``--eager-loading/--lazy-loading`` options from the
``flask run`` command. The app is always eager loaded the first
time, then lazily loaded in the reloader. The reloader always prints
errors immediately but continues serving. Remove the internal
``DispatchingApp`` middleware used by the ... | <mask> - Allow returning a list from a view function, to convert it to a
<mask> JSON response like a dict is. :issue:`4672`
<mask> - When type checking, allow ``TypedDict`` to be returned from view
<mask> functions. :pr:`4695`
<mask>
<mask>
<mask> Version 2.1.3
<mask> -------------
<mask>
<mask... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | CHANGES.rst |
* Serving Flask app 'hello' | <mask>
<mask> .. code-block:: text
<mask>
<mask> $ flask --app hello run
<mask> * Serving Flask app 'hello' (lazy loading)
<mask> * Running on http://127.0.0.1:5000 (Press CTRL+C to quit)
<mask>
<mask> .. admonition:: Application Discovery Behavior
<mask>
<mask> As a shortcut, if the fil... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | docs/quickstart.rst |
* Serving Flask app 'hello' | <mask>
<mask> .. code-block:: text
<mask>
<mask> $ flask --app hello --env development run
<mask> * Serving Flask app 'hello' (lazy loading)
<mask> * Environment: development
<mask> * Debug mode: on
<mask> * Running on http://127.0.0.1:5000 (Press CTRL+C to quit)
<mask> * Restart... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | docs/quickstart.rst |
Deferred Errors on Reload
~~~~~~~~~~~~~~~~~~~~~~~~~ | <mask> 5000. To disable the service, go to System Preferences, Sharing, and
<mask> disable "AirPlay Receiver".
<mask>
<mask>
<mask> Lazy or Eager Loading
<mask> ~~~~~~~~~~~~~~~~~~~~~
<mask>
<mask> When using the ``flask run`` command with the reloader, the server will
<mask> continue to run even if you intr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | docs/server.rst |
<mask> When using the ``flask run`` command with the reloader, the server will
<mask> continue to run even if you introduce syntax errors or other
<mask> initialization errors into the code. Accessing the site will show the
<mask> interactive debugger for the error, rather than crashing the server.
<mask> This fea... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | docs/server.rst | |
<mask> fail immediately and show the traceback rather than waiting until the
<mask> site is accessed. This is intended to make errors more visible initially
<mask> while still allowing the server to handle errors on reload.
<mask>
<mask> To override this behavior and always fail immediately, even on reload,
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | docs/server.rst | |
cli.show_server_banner(self.env, self.debug, self.name) | <mask> options.setdefault("use_reloader", self.debug)
<mask> options.setdefault("use_debugger", self.debug)
<mask> options.setdefault("threaded", True)
<mask>
<mask> cli.show_server_banner(self.env, self.debug, self.name, False)
<mask>
<mask> from werkzeug.serving import... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | src/flask/app.py |
<mask> import traceback
<mask> import typing as t
<mask> from functools import update_wrapper
<mask> from operator import attrgetter
<mask> from threading import Lock
<mask> from threading import Thread
<mask>
<mask> import click
<mask> from click.core import ParameterSource
<mask> from werkzeug.serving impo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | src/flask/cli.py | |
<mask> is_eager=True,
<mask> )
<mask>
<mask>
<mask> class DispatchingApp:
<mask> """Special application that dispatches to a Flask application which
<mask> is imported by name in a background thread. If an error happens
<mask> it is recorded and shown as part of the WSGI handling which in cas... | [
"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/5d8e35653fca0d7ee01519d556c7851089de82ea | src/flask/cli.py | |
def show_server_banner(env, debug, app_import_path): | <mask>
<mask> return loaded # True if at least one file was located and loaded.
<mask>
<mask>
<mask> def show_server_banner(env, debug, app_import_path, eager_loading):
<mask> """Show extra startup messages the first time the server is run,
<mask> ignoring the reloader.
<mask> """
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | src/flask/cli.py |
click.echo(f" * Serving Flask app '{app_import_path}'") | <mask> if is_running_from_reloader():
<mask> return
<mask>
<mask> if app_import_path is not None:
<mask> message = f" * Serving Flask app {app_import_path!r}"
<mask>
<mask> if not eager_loading:
<mask> message += " (lazy loading)"
<mask>
<mask> click.echo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | src/flask/cli.py |
<mask> default=None,
<mask> help="Enable or disable the debugger. By default the debugger "
<mask> "is active if debug is enabled.",
<mask> )
<mask> @click.option(
<mask> "--eager-loading/--lazy-loading",
<mask> default=None,
<mask> help="Enable or disable eager loading. By default eager... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | src/flask/cli.py | |
<mask> host,
<mask> port,
<mask> reload,
<mask> debugger,
<mask> eager_loading,
<mask> with_threads,
<mask> cert,
<mask> extra_files,
<mask> exclude_patterns,
<mask> ):
</s> refactor lazy loading
Remove the `--eager-loading/--lazy-loading` options and the
`DispatchingApp`... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | src/flask/cli.py | |
try:
app = info.load_app()
except Exception as e:
if is_running_from_reloader():
# When reloading, print out the error immediately, but raise
# it later so the debugger or server can handle it.
traceback.print_exc()
err = e
def app(env... | <mask>
<mask> The reloader and debugger are enabled by default with the
<mask> '--env development' or '--debug' options.
<mask> """
<mask> app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
<mask> debug = get_debug_flag()
<mask>
<mask> if reload is None:
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | src/flask/cli.py |
show_server_banner(get_env(), debug, info.app_import_path) | <mask>
<mask> if debugger is None:
<mask> debugger = debug
<mask>
<mask> show_server_banner(get_env(), debug, info.app_import_path, eager_loading)
<mask>
<mask> from werkzeug.serving import run_simple
<mask>
<mask> run_simple(
<mask> host,
</s> refactor lazy loading
Remov... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | src/flask/cli.py |
<mask> from flask import Blueprint
<mask> from flask import current_app
<mask> from flask import Flask
<mask> from flask.cli import AppGroup
<mask> from flask.cli import DispatchingApp
<mask> from flask.cli import find_best_app
<mask> from flask.cli import FlaskGroup
<mask> from flask.cli import get_version
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | tests/test_cli.py | |
<mask> app = obj.load_app()
<mask> assert app.name == "testapp"
<mask>
<mask>
<mask> @pytest.mark.xfail(platform.python_implementation() == "PyPy", reason="flaky on pypy")
<mask> def test_lazy_load_error(monkeypatch):
<mask> """When using lazy loading, the correct exception should be
<mask> re... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep"... | https://github.com/pallets/flask/commit/5d8e35653fca0d7ee01519d556c7851089de82ea | tests/test_cli.py | |
def url_value_preprocessor(self, f):
"""Registers a function as URL value preprocessor for all view
functions of the application. It's called before the view functions
are called and can modify the url values provided.
"""
self.url_value_preprocessors.setdefault(None, []).ap... | <mask> return f
<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
<mask> exception as response.
<mask>
<mask> .. versionadded: 0.3
... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5da1fc22153032923b1560a34a0f346d6517a12d | flask/app.py |
This also triggers the :meth:`url_value_processor` functions before
the actualy :meth:`before_request` functions are called. | <mask> call every as :meth:`before_request` decorated function.
<mask> If any of these function returns a value it's handled as
<mask> if it was the return value from the view and further
<mask> request handling is stopped.
<mask> """
<mask> bp = request.blueprint
... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5da1fc22153032923b1560a34a0f346d6517a12d | flask/app.py |
<mask> If any of these function returns a value it's handled as
<mask> if it was the return value from the view and further
<mask> request handling is stopped.
<mask> """
<mask> funcs = self.before_request_funcs.get(None, ())
<mask> bp = request.blueprint
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5da1fc22153032923b1560a34a0f346d6517a12d | flask/app.py | |
funcs = self.url_value_preprocessors.get(None, ())
if bp is not None and bp in self.url_value_preprocessors:
funcs = chain(funcs, self.url_value_preprocessors[bp])
for func in funcs:
func(request.endpoint, request.values)
funcs = self.before_request_funcs.get(Non... | <mask> This also triggers the :meth:`url_value_processor` functions before
<mask> the actualy :meth:`before_request` functions are called.
<mask> """
<mask> bp = request.blueprint
<mask> if bp is not None and bp in self.before_request_funcs:
<mask> funcs = chain... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5da1fc22153032923b1560a34a0f346d6517a12d | flask/app.py |
object. Flask parses incoming request data for you and gives you
access to it through that global object. Internally Flask makes | <mask>
<mask> .. attribute:: request
<mask>
<mask> To access incoming request data, you can use the global `request`
<mask> object. Flask parses incoming request data for you and gives you
<mask> access to it through that global object. Internally Flask makes
<mask> sure that you always get the c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5dfd2126a6d5210096ec6ba1ead471b79dc8bd17 | docs/api.rst |
threaded environments. Flask provides you with a special object that | <mask> .. currentmodule:: flask
<mask>
<mask> To share data that is valid for one request only from one function to
<mask> another, a global variable is not good enough because it would break in
<mask> threaded environments. Flask provides you with a special object that
<mask> ensures it is only valid for the a... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5dfd2126a6d5210096ec6ba1ead471b79dc8bd17 | docs/api.rst |
``True`` if the signaling system is available. This is the case | <mask> .. versionadded:: 0.6
<mask>
<mask> .. data:: signals.signals_available
<mask>
<mask> ``True`` if the signaling system is available. This is the case
<mask> when `blinker`_ is installed.
<mask>
<mask> The following signals exist in Flask:
<mask>
<mask> .. data:: template_rendered
</s> Fixed... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5dfd2126a6d5210096ec6ba1ead471b79dc8bd17 | docs/api.rst |
This signal is sent when the request is tearing down. This is always
called, even if an exception is caused. Currently functions listening | <mask> got_request_exception.connect(log_security_exception, app)
<mask>
<mask> .. data:: request_tearing_down
<mask>
<mask> This signal is sent when the request is tearing down. This is always
<mask> called, even if an exception is caused. Currently functions listening
<mask> to this signal... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5dfd2126a6d5210096ec6ba1ead471b79dc8bd17 | docs/api.rst |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.