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
.. versionadded:: 0.8 ``TRAP_BAD_REQUEST_KEY_ERRORS``, ``TRAP_HTTP_EXCEPTIONS``
<mask> ``PROPAGATE_EXCEPTIONS``, ``PRESERVE_CONTEXT_ON_EXCEPTION`` <mask> <mask> Configuring from Files <mask> ---------------------- <mask> <mask> Configuration becomes more useful if you can configure from a file, and <mask> ideally that file would be outside of the actual application package so that </s...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7155f11a723695352323d484610b9a1c6798eb69
docs/config.rst
MethodNotAllowed, BadRequest
<mask> <mask> from werkzeug.datastructures import ImmutableDict <mask> from werkzeug.routing import Map, Rule <mask> from werkzeug.exceptions import HTTPException, InternalServerError, \ <mask> MethodNotAllowed <mask> <mask> from .helpers import _PackageBoundObject, url_for, get_flashed_messages, \ <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7155f11a723695352323d484610b9a1c6798eb69
flask/app.py
'MAX_CONTENT_LENGTH': None, 'TRAP_BAD_REQUEST_KEY_ERRORS': False, 'TRAP_HTTP_EXCEPTIONS': False
<mask> 'PERMANENT_SESSION_LIFETIME': timedelta(days=31), <mask> 'USE_X_SENDFILE': False, <mask> 'LOGGER_NAME': None, <mask> 'SERVER_NAME': None, <mask> 'MAX_CONTENT_LENGTH': N...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7155f11a723695352323d484610b9a1c6798eb69
flask/app.py
<mask> exception with the same traceback. <mask> <mask> .. versionadded:: 0.7 <mask> """ <mask> # ensure not to trash sys.exc_info() at that point in case someone <mask> # wants the traceback preserved in handle_http_exception. <mask> if isinstance(e, HTTPExceptio...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7155f11a723695352323d484610b9a1c6798eb69
flask/app.py
# ensure not to trash sys.exc_info() at that point in case someone # wants the traceback preserved in handle_http_exception. Of course # we cannot prevent users from trashing it themselves in a custom # trap_http_exception method so that's their fault then. if isinstance(e, HTTP...
<mask> assert exc_value is e <mask> <mask> blueprint_handlers = () <mask> handlers = self.error_handler_spec.get(request.blueprint) <mask> if handlers is not None: <mask> blueprint_handlers = handlers.get(None, ()) </s> Added HTTP exception trapping. This should fix ...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7155f11a723695352323d484610b9a1c6798eb69
flask/app.py
from werkzeug.exceptions import NotFound, BadRequest
<mask> from contextlib import contextmanager <mask> from functools import update_wrapper <mask> from datetime import datetime <mask> from werkzeug import parse_date, parse_options_header <mask> from werkzeug.exceptions import NotFound <mask> from werkzeug.http import parse_set_header <mask> from jinja2 import Te...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7155f11a723695352323d484610b9a1c6798eb69
tests/flask_tests.py
- Add support for range requests in ``send_file``.
<mask> well as error handlers. <mask> - Disable logger propagation by default for the app logger. <mask> <mask> Version 0.11.2 <mask> -------------- <mask> <mask> Bugfix release, unreleased </s> make use of range requests if available in werkzeug (#2031) * make use of range requests if available in werkzeu...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7186a5aaf571e1d08a617138867998cbea518522
CHANGES
from werkzeug.datastructures import Headers, Range from werkzeug.exceptions import BadRequest, NotFound, \ RequestedRangeNotSatisfiable
<mask> from werkzeug.urls import url_quote <mask> except ImportError: <mask> from urlparse import quote as url_quote <mask> <mask> from werkzeug.datastructures import Headers <mask> from werkzeug.exceptions import BadRequest, NotFound <mask> <mask> # this was moved in 0.7 <mask> try: <mask> from...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7186a5aaf571e1d08a617138867998cbea518522
flask/helpers.py
If `conditional=True` and `filename` is provided, this method will try to upgrade the response stream to support range requests. This will allow the request to be answered with partial content response.
<mask> can turn this off by setting `add_etags=False`. <mask> <mask> Please never pass filenames to this function from user sources; <mask> you should use :func:`send_from_directory` instead. <mask> <mask> .. versionadded:: 0.2 </s> make use of range requests if available in werkzeug (#2031) *...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7186a5aaf571e1d08a617138867998cbea518522
flask/helpers.py
fsize = None
<mask> If a file was passed, this overrides its mtime. <mask> """ <mask> mtime = None <mask> if isinstance(filename_or_fp, string_types): <mask> filename = filename_or_fp <mask> if not os.path.isabs(filename): <mask> filename = os.path.join(current_app.root_path, f...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7186a5aaf571e1d08a617138867998cbea518522
flask/helpers.py
fsize = os.path.getsize(filename) headers['Content-Length'] = fsize
<mask> if current_app.use_x_sendfile and filename: <mask> if file is not None: <mask> file.close() <mask> headers['X-Sendfile'] = filename <mask> headers['Content-Length'] = os.path.getsize(filename) <mask> data = None <mask> else: <mask> if file is No...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7186a5aaf571e1d08a617138867998cbea518522
flask/helpers.py
fsize = os.path.getsize(filename) headers['Content-Length'] = fsize
<mask> else: <mask> if file is None: <mask> file = open(filename, 'rb') <mask> mtime = os.path.getmtime(filename) <mask> headers['Content-Length'] = os.path.getsize(filename) <mask> data = wrap_file(request.environ, file) <mask> <mask> rv = current_ap...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7186a5aaf571e1d08a617138867998cbea518522
flask/helpers.py
if conditional: if callable(getattr(Range, 'to_content_range_header', None)): # Werkzeug supports Range Requests # Remove this test when support for Werkzeug <0.12 is dropped try: rv = rv.make_conditional(request, accept_ranges=True, ...
<mask> except OSError: <mask> warn('Access %s failed, maybe it does not exist, so ignore etags in ' <mask> 'headers' % filename, stacklevel=2) <mask> <mask> if conditional: <mask> rv = rv.make_conditional(request) <mask> # make sure we don't s...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7186a5aaf571e1d08a617138867998cbea518522
flask/helpers.py
# make sure we don't send x-sendfile for servers that # ignore the 304 status code for x-sendfile. if rv.status_code == 304: rv.headers.pop('x-sendfile', None)
<mask> 'headers' % filename, stacklevel=2) <mask> <mask> if conditional: <mask> rv = rv.make_conditional(request) <mask> # make sure we don't send x-sendfile for servers that <mask> # ignore the 304 status code for x-sendfile. <mask> if rv...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7186a5aaf571e1d08a617138867998cbea518522
flask/helpers.py
from werkzeug.datastructures import Range
<mask> import flask <mask> from logging import StreamHandler <mask> from werkzeug.exceptions import BadRequest, NotFound <mask> from werkzeug.http import parse_cache_control_header, parse_options_header <mask> from werkzeug.http import http_date <mask> from flask._compat import StringIO, text_type <mask> </s> ...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7186a5aaf571e1d08a617138867998cbea518522
tests/test_helpers.py
<mask> :license: BSD, see LICENSE for more details. <mask> """ <mask> <mask> from werkzeug.wrappers import Request as RequestBase, Response as ResponseBase <mask> from werkzeug.exceptions import BadRequest, HTTPException <mask> from werkzeug.utils import cached_property <mask> <mask> from .debughelpers im...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71b351173b1440d6ca2dc36284d080fda2a22006
flask/wrappers.py
from .exceptions import JSONBadRequest
<mask> from werkzeug.utils import cached_property <mask> <mask> from .debughelpers import attach_enctype_error_multidict <mask> from .helpers import json, _assert_have_json <mask> from .globals import _request_ctx_stack <mask> <mask> </s> Move JSONHTTPException and JSONBadRequest to new module flask.exceptio...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71b351173b1440d6ca2dc36284d080fda2a22006
flask/wrappers.py
<mask> from .helpers import json, _assert_have_json <mask> from .globals import _request_ctx_stack <mask> <mask> <mask> class JSONHTTPException(HTTPException): <mask> """A base class for HTTP exceptions with ``Content-Type: <mask> application/json``. <mask> <mask> The ``description`` attribute o...
[ "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/71b351173b1440d6ca2dc36284d080fda2a22006
flask/wrappers.py
- Mimetype guessing and ETag generation for file-like objects in ``send_file`` has been removed, as per issue ``#104``. See pull request ``#1849``. - Mimetype guessing in ``send_file`` now fails loudly and doesn't fall back to ``application/octet-stream``. See pull request ``#1988``.
<mask> Version 0.12 <mask> ------------ <mask> <mask> - the cli command now responds to `--version`. <mask> - Mimetype guessing for ``send_file`` has been removed, as per issue ``#104``. <mask> See pull request ``#1849``. <mask> - Make ``flask.safe_join`` able to join multiple paths like ``os.path.join`` <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
CHANGES
.. _upgrading-to-012: Version 0.12 ------------ Changes to send_file ```````````````````` The ``filename`` is no longer automatically inferred from file-like objects. This means that the following code will no longer automatically have ``X-Sendfile`` support, etag generation or MIME-type guessing:: response = s...
<mask> providing the ``--upgrade`` parameter:: <mask> <mask> $ pip install --upgrade Flask <mask> <mask> .. _upgrading-to-10: <mask> <mask> Version 0.11 <mask> ------------ <mask> <mask> 0.11 is an odd release in the Flask release cycle because it was supposed </s> Properly remove f.name usage in sen...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
docs/upgrading.rst
By default it will try to guess the mimetype for you, but you can also explicitly provide one. For extra security you probably want to send certain files as attachment (HTML for instance). The mimetype guessing requires a `filename` or an `attachment_filename` to be provided. ETags will also ...
<mask> you can set the application's :attr:`~Flask.use_x_sendfile` attribute <mask> to ``True`` to directly emit an ``X-Sendfile`` header. This however <mask> requires support of the underlying webserver for ``X-Sendfile``. <mask> <mask> You must explicitly provide the mimetype for the filename o...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
flask/helpers.py
The filename is no longer automatically inferred from file objects. If you want to use automatic mimetype and etag support, pass a filepath via `filename_or_fp` or `attachment_filename`. .. versionchanged:: 0.12 The `attachment_filename` is preferred over `filename` for MIME-type ...
<mask> .. versionchanged:: 0.9 <mask> cache_timeout pulls its default from application config, when None. <mask> <mask> .. versionchanged:: 0.12 <mask> mimetype guessing and etag support removed for file objects. <mask> If no mimetype or attachment_filename is provided, application/o...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
flask/helpers.py
:param mimetype: the mimetype of the file if provided. If a file path is given, auto detection happens as fallback, otherwise an error will be raised.
<mask> which case ``X-Sendfile`` might not work and fall <mask> back to the traditional method. Make sure that the <mask> file pointer is positioned at the start of data to <mask> send before calling :func:`...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
flask/helpers.py
if not os.path.isabs(filename): filename = os.path.join(current_app.root_path, filename)
<mask> if isinstance(filename_or_fp, string_types): <mask> filename = filename_or_fp <mask> file = None <mask> if attachment_filename is None: <mask> attachment_filename = os.path.basename(filename) <mask> else: </s> Properly remove f.name usage in send_file (#1988) *...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
flask/helpers.py
if attachment_filename is None: attachment_filename = os.path.basename(filename)
<mask> filename = filename_or_fp <mask> if not os.path.isabs(filename): <mask> filename = os.path.join(current_app.root_path, filename) <mask> file = None <mask> else: <mask> file = filename_or_fp <mask> filename = None <mask> <mask> if mimetype is N...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
flask/helpers.py
filename = None
<mask> filename = filename_or_fp <mask> file = None <mask> else: <mask> file = filename_or_fp <mask> filename = getattr(file, 'name', None) <mask> <mask> if filename is not None: <mask> if not os.path.isabs(filename): <mask> filename = os.path.join(c...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
flask/helpers.py
<mask> else: <mask> file = filename_or_fp <mask> filename = getattr(file, 'name', None) <mask> <mask> if filename is not None: <mask> if not os.path.isabs(filename): <mask> filename = os.path.join(current_app.root_path, filename) <mask> if mimetype is None and (f...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
flask/helpers.py
if attachment_filename is not None: mimetype = mimetypes.guess_type(attachment_filename)[0] if mimetype is None: if attachment_filename is not None: raise ValueError( 'Unable to infer MIME-type from filename {!r}, please ' ...
<mask> filename = os.path.join(current_app.root_path, filename) <mask> if mimetype is None and (filename or attachment_filename): <mask> mimetype = mimetypes.guess_type(filename or attachment_filename)[0] <mask> if mimetype is None: <mask> mimetype = 'application/octet-stream' ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
flask/helpers.py
raise TypeError('filename unavailable, required for ' 'sending as attachment')
<mask> <mask> headers = Headers() <mask> if as_attachment: <mask> if attachment_filename is None: <mask> if filename is None: <mask> raise TypeError('filename unavailable, required for ' <mask> 'sending as attachment') <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
flask/helpers.py
return flask.send_file(StringIO("party like it's"), last_modified=last_modified, mimetype='text/plain')
<mask> last_modified = datetime.datetime(1999, 1, 1) <mask> <mask> @app.route('/') <mask> def index(): <mask> return flask.send_file(StringIO("party like it's"), last_modified=last_modified) <mask> <mask> c = app.test_client() <mask> rv = c.get('/') <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
tests/test_helpers.py
def test_send_file_object_without_mimetype(self): app = flask.Flask(__name__) with app.test_request_context(): with pytest.raises(ValueError) as excinfo: flask.send_file(StringIO("LOL")) assert 'Unable to infer MIME-type' in str(excinfo) assert '...
<mask> c = app.test_client() <mask> rv = c.get('/') <mask> assert rv.last_modified == last_modified <mask> <mask> def test_send_file_object(self): <mask> app = flask.Flask(__name__) <mask> <mask> with app.test_request_context(): </s> Properly remove f.name usage in...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
tests/test_helpers.py
rv = flask.send_file(f, mimetype='text/html')
<mask> app = flask.Flask(__name__) <mask> <mask> with app.test_request_context(): <mask> with open(os.path.join(app.root_path, 'static/index.html'), mode='rb') as f: <mask> rv = flask.send_file(f) <mask> rv.direct_passthrough = False <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
tests/test_helpers.py
rv = flask.send_file(f, mimetype='text/html')
<mask> app.use_x_sendfile = True <mask> <mask> with app.test_request_context(): <mask> with open(os.path.join(app.root_path, 'static/index.html')) as f: <mask> rv = flask.send_file(f) <mask> assert rv.mimetype == 'text/html' <mask> asse...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
tests/test_helpers.py
assert 'x-sendfile' not in rv.headers
<mask> with app.test_request_context(): <mask> with open(os.path.join(app.root_path, 'static/index.html')) as f: <mask> rv = flask.send_file(f) <mask> assert rv.mimetype == 'text/html' <mask> assert 'x-sendfile' in rv.headers <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
tests/test_helpers.py
rv = flask.send_file(f, mimetype='application/octet-stream')
<mask> <mask> app.use_x_sendfile = False <mask> with app.test_request_context(): <mask> f = StringIO('Test') <mask> rv = flask.send_file(f) <mask> rv.direct_passthrough = False <mask> assert rv.data == b'Test' <mask> assert rv.mimetype...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
tests/test_helpers.py
rv = flask.send_file(f, attachment_filename=f.name)
<mask> def __getattr__(self, name): <mask> return getattr(self._io, name) <mask> f = PyStringIO('Test') <mask> f.name = 'test.txt' <mask> rv = flask.send_file(f) <mask> rv.direct_passthrough = False <mask> assert rv.d...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
tests/test_helpers.py
rv = flask.send_file(f, mimetype='text/html')
<mask> app.use_x_sendfile = True <mask> <mask> with app.test_request_context(): <mask> f = StringIO('Test') <mask> rv = flask.send_file(f) <mask> assert 'x-sendfile' not in rv.headers <mask> rv.close() <mask> <mask> def test_attachment(self)...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
tests/test_helpers.py
rv = flask.send_file(f, as_attachment=True, attachment_filename='index.html')
<mask> def test_attachment(self): <mask> app = flask.Flask(__name__) <mask> with app.test_request_context(): <mask> with open(os.path.join(app.root_path, 'static/index.html')) as f: <mask> rv = flask.send_file(f, as_attachment=True) <mask> value, opt...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/71e10be28665eee6a919045f9e5d8773508dc756
tests/test_helpers.py
mypy==0.910
<mask> jinja2==3.0.1 <mask> # via sphinx <mask> markupsafe==2.0.1 <mask> # via jinja2 <mask> mypy==0.812 <mask> # via -r requirements/typing.in <mask> mypy-extensions==0.4.3 <mask> # via mypy <mask> nodeenv==1.6.0 <mask> # via pre-commit </s> Bump mypy from 0.812 to 0.910 Bumps [mypy](ht...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/72078148c017e2e3e6d6b6716aa8f9f16e0bf2f5
requirements/dev.txt
# mypy
<mask> sphinxcontrib-serializinghtml==1.1.4 <mask> # via sphinx <mask> toml==0.10.2 <mask> # via <mask> # pep517 <mask> # pre-commit <mask> # pytest <mask> # tox <mask> tox==3.23.1 <mask> # via -r requirements/dev.in </s> Bump mypy from 0.812 to 0.910 Bumps [mypy](https:/...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/72078148c017e2e3e6d6b6716aa8f9f16e0bf2f5
requirements/dev.txt
<mask> # pytest <mask> # tox <mask> tox==3.23.1 <mask> # via -r requirements/dev.in <mask> typed-ast==1.4.3 <mask> # via mypy <mask> typing-extensions==3.10.0.0 <mask> # via mypy <mask> urllib3==1.26.5 <mask> # via requests <mask> virtualenv==20.4.6 </s> Bump mypy from 0.812 to 0...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/72078148c017e2e3e6d6b6716aa8f9f16e0bf2f5
requirements/dev.txt
mypy==0.910 # via -r requirements/typing.in
<mask> # pip-compile requirements/typing.in <mask> # <mask> mypy-extensions==0.4.3 <mask> # via mypy <mask> toml==0.10.2 <mask> # via mypy </s> Bump mypy from 0.812 to 0.910 Bumps [mypy](https://github.com/python/mypy) from 0.812 to 0.910. - [Release notes](https://github.com/python/mypy/releases) - ...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/72078148c017e2e3e6d6b6716aa8f9f16e0bf2f5
requirements/typing.txt
toml==0.10.2
<mask> # pip-compile requirements/typing.in <mask> # <mask> mypy-extensions==0.4.3 <mask> # via mypy <mask> mypy==0.812 <mask> # via -r requirements/typing.in <mask> typed-ast==1.4.3 <mask> # via mypy <mask> typing-extensions==3.10.0.0 <mask> # via mypy </s> Bump mypy from 0.812 to 0.910 ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/72078148c017e2e3e6d6b6716aa8f9f16e0bf2f5
requirements/typing.txt
Welcome to Flask's documentation. This documentation is devided into different parts. I would suggest to get started with the :ref:`installation` and then heading over to the :ref:`quickstart`. If you want to dive into all the internal parts of Flask, check out the :ref:`api` documentation. Common patterns are desc...
<mask> Welcome to Flask <mask> ================ <mask> <mask> Welcome to Flask's documentation. <mask> <mask> Contents: <mask> <mask> .. toctree:: <mask> :maxdepth: 2 <mask> <mask> installation </s> And finished documentation for most parts. </s> remove g.db = sqlite3.connect(DATABASE) </s> a...
[ "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/727c701686c18c4a27ca523eb0c5862d497be24e
docs/index.rst
Static Files ------------ Dynamic web applications need static files as well. That's usually where the CSS and JavaScript files are coming from. Ideally your web server is configured to serve them for you, but during development Flask can do that as well. Just create a folder called `static` in your package or next...
<mask> requests are handled like the RFC demands, so you can completely ignore <mask> that part of the HTTP specification. <mask> <mask> Rendering Templates <mask> ------------------- <mask> <mask> Generating HTML from within Python is not fun, and actually pretty <mask> cumbersome because you have to do the ...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/727c701686c18c4a27ca523eb0c5862d497be24e
docs/quickstart.rst
Templates are especially useful if inheritance is used. If you want to know how that works, head over to the :ref:`template-inheritance` pattern documentation. Basically template inheritance makes it possible to keep certain elements on each page (like header, navigation and footer).
<mask> Inside templates you also have access to the :class:`~flask.request`, <mask> :class:`~flask.session` and :class:`~flask.g` objects as well as the <mask> :func:`~flask.get_flashed_messages` function. <mask> <mask> Automatic escaping is enabled, so if name contains HTML it will be escaped <mask> automatical...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/727c701686c18c4a27ca523eb0c5862d497be24e
docs/quickstart.rst
g.db = connect_db()
<mask> def before_request(): <mask> """Make sure we are connected to the database each request and look <mask> up the current user so that we know he's there. <mask> """ <mask> g.db = sqlite3.connect(DATABASE) <mask> if 'user_id' in session: <mask> g.user = query_db('select * from use...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/727c701686c18c4a27ca523eb0c5862d497be24e
examples/minitwit/minitwit.py
#: this reflects the ``'_permanent'`` key in the dict.
<mask> <mask> def _set_permanent(self, value): <mask> self['_permanent'] = bool(value) <mask> <mask> permanent = property(_get_permanent, _set_permanent) <mask> del _get_permanent, _set_permanent <mask> <mask> #: some session backends can tell you if a session is new, but that is <ma...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7290981cef49058b9c53f8a4465cf85537c0d22d
flask/sessions.py
#: some session backends can tell you if a session is new, but that is #: not necessarily guaranteed. Use with caution.
<mask> del _get_permanent, _set_permanent <mask> <mask> new = False <mask> <mask> #: for some backends this will always be `True`, but some backends will <mask> #: default this to false and detect changes in the dictionary for as </s> More docstrings for the session mixin
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7290981cef49058b9c53f8a4465cf85537c0d22d
flask/sessions.py
#: for some backends this will always be `True`, but some backends will #: default this to false and detect changes in the dictionary for as #: long as changes do not happen on mutable structures in the session.
<mask> <mask> #: some session backends can tell you if a session is new, but that is <mask> #: not necessarily guaranteed. Use with caution. <mask> new = False <mask> modified = True <mask> <mask> <mask> class SecureCookieSession(SecureCookie, SessionMixin): <mask> """Expands the sessio...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7290981cef49058b9c53f8a4465cf85537c0d22d
flask/sessions.py
import click
<mask> <mask> import os <mask> import sys <mask> from threading import Lock <mask> from datetime import timedelta <mask> from itertools import chain <mask> from functools import update_wrapper </s> Simplified click integration a bit </s> remove from .cli import make_default_cli </s> add </s> remove s...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7321a480ea60ee212b06cd6698e1e3ab62b5e7f5
flask/app.py
<mask> from .templating import DispatchingJinjaLoader, Environment, \ <mask> _default_template_ctx_processor <mask> from .signals import request_started, request_finished, got_request_exception, \ <mask> request_tearing_down, appcontext_tearing_down <mask> from .cli import make_default_cli <mask> from ....
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7321a480ea60ee212b06cd6698e1e3ab62b5e7f5
flask/app.py
self.cli = click.Group(self)
<mask> #: application has been discovered. The default commands are <mask> #: provided by Flask itself and can be overridden. <mask> #: <mask> #: This is an instance of a :class:`click.Group` object. <mask> self.cli = make_default_cli(self) <mask> <mask> def _get_err...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7321a480ea60ee212b06cd6698e1e3ab62b5e7f5
flask/app.py
<mask> rv = self._load_unlocked() <mask> return rv(environ, start_response) <mask> <mask> <mask> def _no_such_app(): <mask> raise NoAppException('Could not locate Flask application. ' <mask> 'You did not provide FLASK_APP or the ' <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7321a480ea60ee212b06cd6698e1e3ab62b5e7f5
flask/cli.py
raise NoAppException('Could not locate Flask application. ' 'You did not provide FLASK_APP or the ' '--app parameter.')
<mask> if self.create_app is not None: <mask> rv = self.create_app(self) <mask> else: <mask> if self.app_import_path is None: <mask> _no_such_app() <mask> rv = locate_app(self.app_import_path) <mask> if self.debug is not None: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7321a480ea60ee212b06cd6698e1e3ab62b5e7f5
flask/cli.py
cli = FlaskGroup(help="""\ This shell command acts as general utility script for Flask applications.
<mask> ) <mask> code.interact(banner=banner, local=app.make_shell_context()) <mask> <mask> <mask> def make_default_cli(app): <mask> """Creates the default click object for the app itself. Currently <mask> there are no default commands registered because all builtin commands <mask> are reg...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7321a480ea60ee212b06cd6698e1e3ab62b5e7f5
flask/cli.py
It loads the application configured (either through the FLASK_APP environment variable or the --app parameter) and then provides commands either provided by the application or Flask itself.
<mask> This shell command acts as general utility script for Flask applications. <mask> <mask> <mask> The most useful commands are the "run" and "shell" command. <mask> <mask> Example usage: </s> Simplified click integration a bit </s> remove It loads the application configured (either through the FLASK_A...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7321a480ea60ee212b06cd6698e1e3ab62b5e7f5
flask/cli.py
The most useful commands are the "run" and "shell" command.
<mask> """ <mask> return click.Group() <mask> <mask> <mask> @click.group(cls=FlaskGroup) <mask> def cli(**params): <mask> """ <mask> This shell command acts as general utility script for Flask applications. <mask> <mask> It loads the application configured (either through the FLASK_APP ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7321a480ea60ee212b06cd6698e1e3ab62b5e7f5
flask/cli.py
Example usage:
<mask> def cli(**params): <mask> """ <mask> This shell command acts as general utility script for Flask applications. <mask> <mask> It loads the application configured (either through the FLASK_APP environment <mask> variable or the --app parameter) and then provides commands either provided <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7321a480ea60ee212b06cd6698e1e3ab62b5e7f5
flask/cli.py
flask --app=hello --debug run """)
<mask> It loads the application configured (either through the FLASK_APP environment <mask> variable or the --app parameter) and then provides commands either provided <mask> by the application or Flask itself. <mask> <mask> The most useful commands are the "run" and "shell" command. <mask> <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7321a480ea60ee212b06cd6698e1e3ab62b5e7f5
flask/cli.py
rv = app.test_client().get('/') self.assert_equal(rv.data, 'Foo')
<mask> @app.route('/', subdomain='foo') <mask> def subdomain(): <mask> return 'Foo SubDomain' <mask> <mask> try: <mask> rv = app.test_client().get('/') <mask> self.assert_equal(rv.data, 'Foo') <mask> except ValueError, e: <mask> r...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7331ae3df58bdf322122010e598b7e7bb793daea
flask/testsuite/basic.py
rv = app.test_client().get('/', 'http://localhost.localdomain:5000') self.assert_equal(rv.data, 'Foo')
<mask> raise ValueError( <mask> "No ValueError exception should have been raised \"%s\"" % e <mask> ) <mask> <mask> try: <mask> rv = app.test_client().get('/', 'http://localhost.localdomain:5000') <mask> self.assert_equal(rv.data, 'Foo') <...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7331ae3df58bdf322122010e598b7e7bb793daea
flask/testsuite/basic.py
rv = app.test_client().get('/', 'https://localhost.localdomain:5000') self.assert_equal(rv.data, 'Foo')
<mask> raise ValueError( <mask> "No ValueError exception should have been raised \"%s\"" % e <mask> ) <mask> <mask> try: <mask> rv = app.test_client().get('/', 'https://localhost.localdomain:5000') <mask> self.assert_equal(rv.data, 'Foo') ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7331ae3df58bdf322122010e598b7e7bb793daea
flask/testsuite/basic.py
app.config.update(SERVER_NAME='localhost.localdomain') rv = app.test_client().get('/', 'https://localhost.localdomain') self.assert_equal(rv.data, 'Foo')
<mask> raise ValueError( <mask> "No ValueError exception should have been raised \"%s\"" % e <mask> ) <mask> <mask> try: <mask> app.config.update(SERVER_NAME='localhost.localdomain') <mask> rv = app.test_client().get('/', 'https://localhost...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7331ae3df58bdf322122010e598b7e7bb793daea
flask/testsuite/basic.py
# Werkzeug 0.8 self.assert_equal(rv.status_code, 404)
<mask> <mask> try: <mask> app.config.update(SERVER_NAME='localhost.localdomain:443') <mask> rv = app.test_client().get('/', 'https://localhost.localdomain') <mask> self.assert_equal(rv.data, 'Foo') <mask> except ValueError, e: <mask> self.assert_eq...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7331ae3df58bdf322122010e598b7e7bb793daea
flask/testsuite/basic.py
# Werkzeug 0.7
<mask> rv = app.test_client().get('/', 'https://localhost.localdomain') <mask> # Werkzeug 0.8 <mask> self.assert_equal(rv.status_code, 404) <mask> except ValueError, e: <mask> self.assert_equal(str(e), "the server name provided " + <mask> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7331ae3df58bdf322122010e598b7e7bb793daea
flask/testsuite/basic.py
rv = app.test_client().get('/', 'http://foo.localhost') # Werkzeug 0.8 self.assert_equal(rv.status_code, 404)
<mask> "server name from the WSGI environment ('localhost.localdomain')") <mask> <mask> try: <mask> app.config.update(SERVER_NAME='localhost.localdomain') <mask> app.test_client().get('/', 'http://foo.localhost') <mask> except ValueError, e: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7331ae3df58bdf322122010e598b7e7bb793daea
flask/testsuite/basic.py
# Werkzeug 0.7
<mask> rv = app.test_client().get('/', 'http://foo.localhost') <mask> # Werkzeug 0.8 <mask> self.assert_equal(rv.status_code, 404) <mask> except ValueError, e: <mask> self.assert_equal(str(e), "the server name provided " + \ <mask> "('loc...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7331ae3df58bdf322122010e598b7e7bb793daea
flask/testsuite/basic.py
rv = app.test_client().get('/', 'http://foo.localhost.localdomain') self.assert_equal(rv.data, 'Foo SubDomain')
<mask> self.assert_equal(str(e), "the server name provided " + \ <mask> "('localhost.localdomain') does not match the " + \ <mask> "server name from the WSGI environment ('foo.localhost')") <mask> <mask> try: <mask> rv = app.test_client().ge...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7331ae3df58bdf322122010e598b7e7bb793daea
flask/testsuite/basic.py
<mask> :copyright: (c) 2010 by Armin Ronacher. <mask> :license: BSD, see LICENSE for more details. <mask> """ <mask> from __future__ import with_statement <mask> import re <mask> import time <mask> import sqlite3 <mask> from hashlib import md5 <mask> from datetime import datetime <mask> from contextli...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/73a47a0db1a181bb305684115d3dacded0c5a58b
examples/minitwit/minitwit.py
<mask> messages as well as all the messages of followed users. <mask> """ <mask> if not g.user: <mask> return redirect(url_for('public_timeline')) <mask> offset = request.args.get('offset', type=int) <mask> return render_template('timeline.html', messages=query_db(''' <mask> s...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/73a47a0db1a181bb305684115d3dacded0c5a58b
examples/minitwit/minitwit.py
followed = False
<mask> profile_user = query_db('select * from user where username = ?', <mask> [username], one=True) <mask> if profile_user is None: <mask> abort(404) <mask> followd = False <mask> if g.user: <mask> followed = query_db('''select 1 from follower where <...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/73a47a0db1a181bb305684115d3dacded0c5a58b
examples/minitwit/minitwit.py
$ virtualenv venv New python executable in venv/bin/python
<mask> folder within:: <mask> <mask> $ mkdir myproject <mask> $ cd myproject <mask> $ virtualenv env <mask> New python executable in env/bin/python <mask> Installing setuptools............done. <mask> <mask> Now, whenever you want to work on a project, you only have to activate the <mask...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/73a859533525febe42c0645ec25eeaa049123973
docs/installation.rst
$ source venv/bin/activate
<mask> <mask> Now, whenever you want to work on a project, you only have to activate the <mask> corresponding environment. On OS X and Linux, do the following:: <mask> <mask> $ . env/bin/activate <mask> <mask> (Note the space between the dot and the script name. The dot means that this <mask> script sh...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/73a859533525febe42c0645ec25eeaa049123973
docs/installation.rst
$ venv\scripts\activate
<mask> not work in your shell, try replacing the dot with ``source``.) <mask> <mask> If you are a Windows user, the following command is for you:: <mask> <mask> $ env\scripts\activate <mask> <mask> Either way, you should now be using your virtualenv (notice how the prompt of <mask> your shell has changed...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/73a859533525febe42c0645ec25eeaa049123973
docs/installation.rst
$ pip install Flask
<mask> <mask> Now you can just enter the following command to get Flask activated in your <mask> virtualenv:: <mask> <mask> $ easy_install Flask <mask> <mask> A few seconds later and you are good to go. <mask> <mask> <mask> System-Wide Installation </s> vent and no more . </s> remove $ env\scrip...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/73a859533525febe42c0645ec25eeaa049123973
docs/installation.rst
file will appear in your application URL e.g. example.com/yourapplication.fcgi/news/. There are few ways to configure your application so that yourapplication.fcgi does not appear in the URL. A preferable way is to use the ScriptAlias and SetHandler configuration directives to route requests to the FastCGI server. The ...
<mask> Configuring Apache <mask> ------------------ <mask> <mask> The example above is good enough for a basic Apache deployment but your `.fcgi` <mask> file will appear in your application URL <mask> e.g. example.com/yourapplication.fcgi/news/. There are few ways to configure <mask> your application so that yo...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/73b4a52ca525dc2a671c6966ee3c403d848ba768
docs/deploying/fastcgi.rst
ServerName webapp1.mydomain.com DocumentRoot /var/www/html/yourapplication AddHandler fastcgi-script fcgi ScriptAlias / /var/www/html/yourapplication/app.fcgi/ <Location /> SetHandler fastcgi-script </Location>
<mask> your application so that yourapplication.fcgi does not appear in the URL. A <mask> preferable way is to use the ScriptAlias configuration directive:: <mask> <mask> <VirtualHost *> <mask> ServerName example.com <mask> ScriptAlias / /path/to/yourapplication.fcgi/ <mask> </VirtualHos...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/73b4a52ca525dc2a671c6966ee3c403d848ba768
docs/deploying/fastcgi.rst
These processes will be managed by Apache. If you're using an standalone FastCGI server, you can use the FastCgiExternalServer directive instead. Note that in the following the path is not real, it's simply used as an identifier to other directives such as AliasMatch: FastCgiServer /var/www/html/yourapplication -h...
<mask> </Location> <mask> </VirtualHost> <mask> <mask> If you cannot set ScriptAlias, for example on an shared web host, you can use <mask> WSGI middleware to remove yourapplication.fcgi from the URLs. Set .htaccess:: <mask> <mask> <IfModule mod_fcgid.c> <mask> AddHandler fcgid-script ....
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/73b4a52ca525dc2a671c6966ee3c403d848ba768
docs/deploying/fastcgi.rst
before each request, even if outside of a module.
<mask> return f <mask> <mask> def before_app_request(self, f): <mask> """Like :meth:`Flask.before_request`. Such a function is executed <mask> before each request. <mask> """ <mask> self._record(lambda s: s.app.before_request_funcs <mask> .setdefault(Non...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/745638e774063de206aae930df71789de13e7c73
flask.py
is executed after each request, even if outside of the module.
<mask> return f <mask> <mask> def after_app_request(self, f): <mask> """Like :meth:`Flask.after_request` but for a module. Such a function <mask> is executed after each request. <mask> """ <mask> self._record(lambda s: s.app.after_request_funcs <mask> .s...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/745638e774063de206aae930df71789de13e7c73
flask.py
def context_processor(self, f): """Like :meth:`Flask.context_processor` but for a modul. This function is only executed for requests handled by a module. """ self._record(lambda s: s.app.template_context_processors .setdefault(self.name, []).append(f)) return f ...
<mask> return f <mask> <mask> def _record(self, func): <mask> self._register_events.append(func) <mask> <mask> <mask> class Flask(_PackageBoundObject): </s> Added missing decorators for module wide context processors. This fixes #25. </s> remove is executed after each request. <...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/745638e774063de206aae930df71789de13e7c73
flask.py
- Replace the previously undocumented ``setuptools`` dependency in the CLI with ``importlib.metadata``. :issue:`4419`
<mask> - ``copy_current_request_context`` can decorate async functions. <mask> :pr:`4303` <mask> <mask> <mask> Version 2.0.3 <mask> ------------- <mask> <mask> Unreleased </s> cli: use importlib.metadata instead of pkg_resources </s> remove for ep in pkg_resources.iter_entry_points("flask.comm...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/751d85f3de3f726446bb12e4ddfae885a6645ba1
CHANGES.rst
"importlib-metadata; python_version < '3.10'",
<mask> "Jinja2 >= 3.0", <mask> "itsdangerous >= 2.0", <mask> "click >= 8.0", <mask> ], <mask> extras_require={ <mask> "async": ["asgiref >= 3.2"], <mask> "dotenv": ["python-dotenv"], <mask> }, </s> cli: use importlib.metadata instead of pkg_resources </s> rem...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/751d85f3de3f726446bb12e4ddfae885a6645ba1
setup.py
if sys.version_info >= (3, 10): from importlib import metadata else: # Use a backport on Python < 3.10. # # We technically have importlib.metadata on 3.8+, # but the API changed in 3.10, so use the backport # for consistency. import importlib_metadata as metadata # type: ignore
<mask> except ImportError: <mask> ssl = None # type: ignore <mask> <mask> <mask> class NoAppException(click.UsageError): <mask> """Raised if an application cannot be found or loaded.""" <mask> <mask> <mask> def find_best_app(module): </s> cli: use importlib.metadata instead of pkg_resources </s> ...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/751d85f3de3f726446bb12e4ddfae885a6645ba1
src/flask/cli.py
<mask> <mask> def _load_plugin_commands(self): <mask> if self._loaded_plugin_commands: <mask> return <mask> try: <mask> import pkg_resources <mask> except ImportError: <mask> self._loaded_plugin_commands = True <mask> return <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/751d85f3de3f726446bb12e4ddfae885a6645ba1
src/flask/cli.py
for ep in metadata.entry_points(group="flask.commands"):
<mask> except ImportError: <mask> self._loaded_plugin_commands = True <mask> return <mask> <mask> for ep in pkg_resources.iter_entry_points("flask.commands"): <mask> self.add_command(ep.load(), ep.name) <mask> self._loaded_plugin_commands = True <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/751d85f3de3f726446bb12e4ddfae885a6645ba1
src/flask/cli.py
- added external URL support.
<mask> - :meth:`~flask.Flask.add_url_rule` can now also register a <mask> view function. <mask> - server listens on 127.0.0.1 by default now to fix issues with chrome. <mask> <mask> Version 0.1 <mask> ----------- <mask> <mask> First public preview release. </s> Added _external support to url_for </s> remov...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/75461c1467bbb2d83ee787bb13f4a338a4b8ad3e
CHANGES
:param _external: if set to `True`, an absolute URL is generated.
<mask> :param endpoint: the endpoint of the URL (name of the function) <mask> :param values: the variable arguments of the URL rule <mask> """ <mask> external = values.pop('_external', False) <mask> return _request_ctx_stack.top.url_adapter.build(endpoint, values, <mask> ...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/75461c1467bbb2d83ee787bb13f4a338a4b8ad3e
flask.py
external = values.pop('_external', False) return _request_ctx_stack.top.url_adapter.build(endpoint, values, force_external=external)
<mask> <mask> :param endpoint: the endpoint of the URL (name of the function) <mask> :param values: the variable arguments of the URL rule <mask> """ <mask> return _request_ctx_stack.top.url_adapter.build(endpoint, values) <mask> <mask> <mask> def get_template_attribute(template_name, attribu...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/75461c1467bbb2d83ee787bb13f4a338a4b8ad3e
flask.py
assert flask.url_for('hello', name='test x', _external=True) \ == 'http://localhost/hello/test%20x'
<mask> def hello(): <mask> pass <mask> with app.test_request_context(): <mask> assert flask.url_for('hello', name='test x') == '/hello/test%20x' <mask> <mask> def test_custom_converters(self): <mask> from werkzeug.routing import BaseConverter <mask> c...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/75461c1467bbb2d83ee787bb13f4a338a4b8ad3e
tests/flask_tests.py
- autoescaping is no longer active for all templates. Instead it is only active for ``.html``, ``.htm``, ``.xml`` and ``.xhtml``. Inside templates this behaviour can be changed with the ``autoescape`` tag.
<mask> specify the server name. The server name can now be set with <mask> the `SERVER_NAME` config key. <mask> <mask> Version 0.4 <mask> ----------- <mask> </s> Started working on refactoring Jinja integration </s> remove self.jinja_env = Environment(loader=self.create_jinja_loader(), ...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7599046d042d1bb3f2db6cdcd6458338802901c4
CHANGES
.. versionchanged:: 0.5 Autoescaping is no longer enabled for all templates. The following extensions for templates trigger autoescaping: ``.html``, ``.htm``, ``.xml``, ``.xhtml``. Templates loaded from string will have autoescaping disabled.
<mask> Markup(u'&lt;blink&gt;hacker&lt;/blink&gt;') <mask> >>> Markup('<em>Marked up</em> &raquo; HTML').striptags() <mask> u'Marked up \xbb HTML' <mask> <mask> .. [#] Unsure what that :class:`~flask.g` object is? It's something you <mask> can store information on yourself, check the documentation of that <m...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7599046d042d1bb3f2db6cdcd6458338802901c4
docs/quickstart.rst
def _select_autoescape(filename): """Returns `True` if autoescaping should be active for the given template name. """ if filename is None: return False return filename.endswith(('.html', '.htm', '.xml', '.xhtml'))
<mask> def __repr__(self): <mask> return '<%s %s>' % (self.__class__.__name__, dict.__repr__(self)) <mask> <mask> <mask> class Flask(_PackageBoundObject): <mask> """The flask object implements a WSGI application and acts as the central <mask> object. It is passed the name of the module or ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7599046d042d1bb3f2db6cdcd6458338802901c4
flask.py
autoescape=_select_autoescape,
<mask> ) <mask> <mask> #: Options that are passed directly to the Jinja2 environment. <mask> jinja_options = ImmutableDict( <mask> autoescape=True, <mask> extensions=['jinja2.ext.autoescape', 'jinja2.ext.with_'] <mask> ) <mask> <mask> #: Default configuration parameters. ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7599046d042d1bb3f2db6cdcd6458338802901c4
flask.py
self.jinja_env = self.create_jinja_environment() self.init_jinja_globals()
<mask> <mask> #: The Jinja2 environment. It is created from the <mask> #: :attr:`jinja_options` and the loader that is returned <mask> #: by the :meth:`create_jinja_loader` function. <mask> self.jinja_env = Environment(loader=self.create_jinja_loader(), <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7599046d042d1bb3f2db6cdcd6458338802901c4
flask.py
def create_jinja_environment(self): """Creates the Jinja2 environment based on :attr:`jinja_options` and :meth:`create_jinja_loader`. .. versionadded:: 0.5 """ return Environment(loader=self.create_jinja_loader(), **self.jinja_options)
<mask> self._logger = logger <mask> return logger <mask> <mask> def create_jinja_loader(self): <mask> """Creates the Jinja loader. By default just a package loader for <mask> the configured package is returned that looks up templates in the <mask> `templates`...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7599046d042d1bb3f2db6cdcd6458338802901c4
flask.py
def init_jinja_globals(self): """Callde directly after the environment was created to inject some defaults (like `url_for`, `get_flashed_messages` and the `tojson` filter. .. versionadded:: 0.5 """ self.jinja_env.globals.update( url_for=url_for, ...
<mask> if pkg_resources is None: <mask> return FileSystemLoader(os.path.join(self.root_path, 'templates')) <mask> return PackageLoader(self.import_name) <mask> <mask> def update_template_context(self, context): <mask> """Update the template context with some commonly used ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7599046d042d1bb3f2db6cdcd6458338802901c4
flask.py
def test_no_escaping(self): app = flask.Flask(__name__) with app.test_request_context(): assert flask.render_template_string('{{ foo }}', foo='<test>') == '<test>' assert flask.render_template('mail.txt', foo='<test>') \ == '<test> Mail'
<mask> ] <mask> <mask> def test_macros(self): <mask> app = flask.Flask(__name__) <mask> with app.test_request_context(): <mask> macro = flask.get_template_attribute('_macro.html', 'hello') </s> Started working on refactoring Jinja integration </s> remove self.jinj...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/7599046d042d1bb3f2db6cdcd6458338802901c4
tests/flask_tests.py
from threading import Thread, Condition
<mask> import flask <mask> import pickle <mask> import unittest <mask> from datetime import datetime <mask> from threading import Thread <mask> from time import sleep <mask> from flask.testsuite import FlaskTestCase, emits_module_deprecation_warning <mask> from flask._compat import text_type <mask> from werkze...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/75f2af7a6afdf620d7afdccee876b06f8c39373b
flask/testsuite/basic.py