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
- env: TOXENV=docs-html - env: TOXENV=devel,lowest,codecov
<mask> language: python <mask> <mask> matrix: <mask> include: <mask> - python: 3.7 <mask> env: TOXENV=py,simplejson,devel,lowest,codecov <mask> - python: 3.7 <mask> env: TOXENV=docs-html <mask> - python: 3.6 <mask> env: TOXENV=py,simplejson,devel,lowest,codecov <mask> - p...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561
.travis.yml
env: TOXENV=py3,codecov
<mask> - python: nightly <mask> env: TOXENV=py <mask> - os: osx <mask> language: generic <mask> env: TOXENV=py3,py2,codecov <mask> cache: <mask> pip: false <mask> directories: <mask> - $HOME/Library/Caches/Homebrew <mask> - $HOME/Library/Cach...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561
.travis.yml
<mask> - os: osx <mask> language: generic <mask> env: TOXENV=py3,py2,codecov <mask> cache: <mask> pip: false <mask> directories: <mask> - $HOME/Library/Caches/Homebrew <mask> - $HOME/Library/Caches/pip <mask> allow_failures: <mask> - python: pypy...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561
.travis.yml
<mask> directories: <mask> - $HOME/Library/Caches/Homebrew <mask> - $HOME/Library/Caches/pip <mask> allow_failures: <mask> - python: pypy3 <mask> - python: nightly <mask> - os: osx <mask> fast_finish: true <mask> <mask> before_install: </s> use specific pypy versi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561
.travis.yml
- python: pypy3.5-6.0
<mask> - $HOME/Library/Caches/pip <mask> allow_failures: <mask> - python: nightly <mask> - os: osx <mask> fast_finish: true <mask> <mask> before_install: <mask> - | <mask> if [[ $TRAVIS_OS_NAME == 'osx' ]]; then </s> use specific pypy versions for travis xenial remove 3.6 from app...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561
.travis.yml
<mask> before_install: <mask> - | <mask> if [[ $TRAVIS_OS_NAME == 'osx' ]]; then <mask> brew upgrade python <mask> brew install python@2; <mask> export PATH="/usr/local/opt/python/libexec/bin:${PATH}" <mask> fi <mask> <mask> install: <mask> - pip install tox </s> use specific p...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561
.travis.yml
directories: - $HOME/.cache/pip - $HOME/.cache/pre-commit
<mask> script: <mask> - tox <mask> <mask> cache: <mask> - pip <mask> <mask> branches: <mask> only: <mask> - master <mask> - /^.*-maintenance$/ </s> use specific pypy versions for travis xenial remove 3.6 from appveyor, reduce in tox remove deprecated travis feature "sudo: false" split docs an...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561
.travis.yml
- /^\d+(\.\d+)*-maintenance$/ - /^\d+(\.\d+)*(\.x)?$/
<mask> <mask> branches: <mask> only: <mask> - master <mask> - /^.*-maintenance$/ <mask> <mask> notifications: <mask> email: false </s> use specific pypy versions for travis xenial remove 3.6 from appveyor, reduce in tox remove deprecated travis feature "sudo: false" split docs and devel,lowest tr...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561
.travis.yml
py{37,27,py}-simplejson py{37,27,py}-devel py{37,27,py}-lowest
<mask> [tox] <mask> envlist = <mask> py{37,36,35,34,27,py} <mask> py{37,36,27,py}-simplejson <mask> py{37,36,27,py}-devel <mask> py{37,36,27,py}-lowest <mask> docs-html <mask> coverage-report <mask> <mask> [testenv] <mask> passenv = LANG </s> use specific pypy versions for travis xe...
[ "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a14c6d67d09d2a27c1d4685415d8ab0d6448561
tox.ini
class TaggedJSONSerializer(object): """A customized JSON serializer that supports a few extra types that we take for granted when serializing (tuples, markup objects, datetime). """ def __init__(self): self.conversions = [ { 'check': lambda value: self._is_dict_with_...
<mask> #: The default mixin implementation just hardcodes ``True`` in. <mask> modified = True <mask> <mask> <mask> def _tag(value): <mask> if isinstance(value, tuple): <mask> return {' t': [_tag(x) for x in value]} <mask> elif isinstance(value, uuid.UUID): <mask> return {' u':...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a8a60815294eb9d5db0c2d451c6c9d959c7c499
flask/sessions.py
<mask> raise UnexpectedUnicodeError(u'A byte string with ' <mask> u'non-ASCII data was passed to the session system ' <mask> u'which can only store unicode strings. Consider ' <mask> u'base64 encoding your string (String was %r)' % value) <mask> retu...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a8a60815294eb9d5db0c2d451c6c9d959c7c499
flask/sessions.py
def _tag_dict_used_with_key(self, value): k, v = next(iteritems(value)) return {'%s__' % k: v} def _tag(self, value): for tag_ops in self.conversions: if tag_ops['check'](value): tag = tag_ops.get('key') if tag: return {tag...
<mask> u'base64 encoding your string (String was %r)' % value) <mask> return value <mask> <mask> <mask> class TaggedJSONSerializer(object): <mask> """A customized JSON serializer that supports a few extra types that <mask> we take for granted when serializing (tuples, markup objects...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a8a60815294eb9d5db0c2d451c6c9d959c7c499
flask/sessions.py
return json.dumps(self._tag(value), separators=(',', ':'))
<mask> we take for granted when serializing (tuples, markup objects, datetime). <mask> """ <mask> <mask> def dumps(self, value): <mask> return json.dumps(_tag(value), separators=(',', ':')) <mask> <mask> LOADS_MAP = { <mask> ' t': tuple, <mask> ' u': uuid.UUID, <mask>...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a8a60815294eb9d5db0c2d451c6c9d959c7c499
flask/sessions.py
return json.loads(value, object_hook=self._untag)
<mask> ' d': parse_date, <mask> } <mask> <mask> def loads(self, value): <mask> def object_hook(obj): <mask> if len(obj) != 1: <mask> return obj <mask> the_key, the_value = next(iteritems(obj)) <mask> # Check the key for a correspondin...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a8a60815294eb9d5db0c2d451c6c9d959c7c499
flask/sessions.py
flask.session['spacefirst'] = {' t': 'not-a-tuple'} flask.session['withunderscores'] = {' t__': 'not-a-tuple'} flask.session['notadict'] = {' di': 'not-a-dict'}
<mask> flask.session['u'] = the_uuid <mask> flask.session['dt'] = now <mask> flask.session['b'] = b'\xff' <mask> flask.session['t'] = (1, 2, 3) <mask> return response <mask> <mask> @app.route('/') <mask> def dump_session_contents(): <mask> return pickle....
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a8a60815294eb9d5db0c2d451c6c9d959c7c499
tests/test_basic.py
assert rv['spacefirst'] == {' t': 'not-a-tuple'} assert rv['withunderscores'] == {' t__': 'not-a-tuple'} assert rv['notadict'] == {' di': 'not-a-dict'}
<mask> assert type(rv['b']) == bytes <mask> assert rv['t'] == (1, 2, 3) <mask> <mask> <mask> def test_session_cookie_setting(): <mask> app = flask.Flask(__name__) </s> Move object_hook outside loads method so class can be extend and reused </s> remove def _tag(value): if isinstance(value, tuple...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8a8a60815294eb9d5db0c2d451c6c9d959c7c499
tests/test_basic.py
" passed to the app factory function in Flask 2.1.",
<mask> <mask> if "script_info" in sig.parameters: <mask> warnings.warn( <mask> "The 'script_info' argument is deprecated and will not be" <mask> " passed to the app factory function in 2.1.", <mask> DeprecationWarning, <mask> ) <mask> kwargs["scri...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/cli.py
" single argument to the app factory function in Flask" " 2.1.",
<mask> and next(iter(sig.parameters.values())).default is inspect.Parameter.empty <mask> ): <mask> warnings.warn( <mask> "Script info is deprecated and will not be passed as the" <mask> " single argument to the app factory function in 2.1.", <mask> Deprecati...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/cli.py
"The 'attachment_filename' parameter has been renamed to" " 'download_name'. The old name will be removed in Flask" " 2.1.",
<mask> **kwargs, <mask> ): <mask> if attachment_filename is not None: <mask> warnings.warn( <mask> "The 'attachment_filename' parameter has been renamed to 'download_name'." <mask> " The old name will be removed in Flask 2.1.", <mask> DeprecationWarning, <mask...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/helpers.py
"The 'cache_timeout' parameter has been renamed to" " 'max_age'. The old name will be removed in Flask 2.1.",
<mask> download_name = attachment_filename <mask> <mask> if cache_timeout is not None: <mask> warnings.warn( <mask> "The 'cache_timeout' parameter has been renamed to 'max_age'. The old name" <mask> " will be removed in Flask 2.1.", <mask> DeprecationWarni...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/helpers.py
"The 'add_etags' parameter has been renamed to 'etag'. The" " old name will be removed in Flask 2.1.",
<mask> max_age = cache_timeout <mask> <mask> if add_etags is not None: <mask> warnings.warn( <mask> "The 'add_etags' parameter has been renamed to 'etag'. The old name will be" <mask> " removed in Flask 2.1.", <mask> DeprecationWarning, <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/helpers.py
.. versionchanged:: 2.0
<mask> ``max_age`` replaces the ``cache_timeout`` parameter. <mask> ``conditional`` is enabled and ``max_age`` is not set by <mask> default. <mask> <mask> .. versionchanged:: 2.0.0 <mask> ``etag`` replaces the ``add_etags`` parameter. It can be a <mask> string to use ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/helpers.py
" Flask 2.1. Use 'werkzeug.utils.safe_join' instead.",
<mask> :return: A safe path, otherwise ``None``. <mask> """ <mask> warnings.warn( <mask> "'flask.helpers.safe_join' is deprecated and will be removed in" <mask> " 2.1. Use 'werkzeug.utils.safe_join' instead.", <mask> DeprecationWarning, <mask> stacklevel=2, <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/helpers.py
``encoding`` is deprecated and will be removed in Flask 2.1.
<mask> or defaults. <mask> :param kwargs: Extra arguments passed to :func:`json.dumps`. <mask> <mask> .. versionchanged:: 2.0 <mask> ``encoding`` is deprecated and will be removed in 2.1. <mask> <mask> .. versionchanged:: 1.0.3 <mask> ``app`` can be passed directly, rather ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/json/__init__.py
"'encoding' is deprecated and will be removed in Flask 2.1.",
<mask> rv = _json.dumps(obj, **kwargs) <mask> <mask> if encoding is not None: <mask> warnings.warn( <mask> "'encoding' is deprecated and will be removed in 2.1.", <mask> DeprecationWarning, <mask> stacklevel=2, <mask> ) <mask> <mask> if isi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/json/__init__.py
deprecated and will be removed in Flask 2.1.
<mask> :param kwargs: Extra arguments passed to :func:`json.dump`. <mask> <mask> .. versionchanged:: 2.0 <mask> Writing to a binary file, and the ``encoding`` argument, is <mask> deprecated and will be removed in 2.1. <mask> """ <mask> _dump_arg_defaults(kwargs, app=app) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/json/__init__.py
" deprecated and will be removed in Flask 2.1.",
<mask> <mask> if show_warning: <mask> warnings.warn( <mask> "Writing to a binary file, and the 'encoding' argument, is" <mask> " deprecated and will be removed in 2.1.", <mask> DeprecationWarning, <mask> stacklevel=2, <mask> ) <mask> <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/json/__init__.py
``encoding`` is deprecated and will be removed in Flask 2.1. The data must be a string or UTF-8 bytes.
<mask> or defaults. <mask> :param kwargs: Extra arguments passed to :func:`json.loads`. <mask> <mask> .. versionchanged:: 2.0 <mask> ``encoding`` is deprecated and will be removed in 2.1. The data <mask> must be a string or UTF-8 bytes. <mask> <mask> .. versionchanged:: 1.0...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/json/__init__.py
"'encoding' is deprecated and will be removed in Flask 2.1." " The data must be a string or UTF-8 bytes.",
<mask> encoding = kwargs.pop("encoding", None) <mask> <mask> if encoding is not None: <mask> warnings.warn( <mask> "'encoding' is deprecated and will be removed in 2.1. The" <mask> " data must be a string or UTF-8 bytes.", <mask> DeprecationWarning, <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/json/__init__.py
``encoding`` is deprecated and will be removed in Flask 2.1. The file must be text mode, or binary mode with UTF-8 bytes.
<mask> or defaults. <mask> :param kwargs: Extra arguments passed to :func:`json.load`. <mask> <mask> .. versionchanged:: 2.0 <mask> ``encoding`` is deprecated and will be removed in 2.1. The file <mask> must be text mode, or binary mode with UTF-8 bytes. <mask> """ <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/json/__init__.py
"'encoding' is deprecated and will be removed in Flask 2.1." " The file must be text mode, or binary mode with UTF-8" " bytes.",
<mask> encoding = kwargs.pop("encoding", None) <mask> <mask> if encoding is not None: <mask> warnings.warn( <mask> "'encoding' is deprecated and will be removed in 2.1. The" <mask> " file must be text mode, or binary mode with UTF-8 bytes.", <mask> Deprecation...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/json/__init__.py
.. versionadded:: 2.0
<mask> :param root_path: The path that static, template, and resource files <mask> are relative to. Typically not set, it is discovered based on <mask> the ``import_name``. <mask> <mask> .. versionadded:: 2.0.0 <mask> """ <mask> <mask> name: str <mask> _static_folder = Non...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8ab4967703c2f5c500174f46b672d80e32f55d85
src/flask/scaffold.py
import warnings
<mask> import io <mask> import json as _json <mask> import uuid <mask> from datetime import date <mask> from datetime import datetime <mask> <mask> from markupsafe import Markup <mask> from werkzeug.http import http_date </s> deprecate JSON encoding options make consistent with built-in json module </s> remo...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
from markupsafe import Markup
<mask> import uuid <mask> from datetime import date <mask> from datetime import datetime <mask> <mask> from jinja2 import Markup <mask> from werkzeug.http import http_date <mask> <mask> from ..globals import current_app <mask> from ..globals import request <mask> </s> deprecate JSON encoding options make...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
<mask> # Python < 3.7 <mask> dataclasses = None <mask> <mask> <mask> __all__ = [ <mask> "dump", <mask> "dumps", <mask> "load", <mask> "loads", <mask> "htmlsafe_dump", <mask> "htmlsafe_dumps", <mask> "JSONDecoder", <mask> "JSONEncoder", <mask> "jsonify", <mask...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
return super().default(self, o)
<mask> if dataclasses and dataclasses.is_dataclass(o): <mask> return dataclasses.asdict(o) <mask> if hasattr(o, "__html__"): <mask> return str(o.__html__()) <mask> return _json.JSONEncoder.default(self, o) <mask> <mask> <mask> class JSONDecoder(_json.JSONDecoder...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
cls = bp.json_encoder if bp and bp.json_encoder else app.json_encoder kwargs.setdefault("cls", cls) kwargs.setdefault("ensure_ascii", app.config["JSON_AS_ASCII"])
<mask> app = current_app <mask> <mask> if app: <mask> bp = app.blueprints.get(request.blueprint) if request else None <mask> kwargs.setdefault( <mask> "cls", bp.json_encoder if bp and bp.json_encoder else app.json_encoder <mask> ) <mask> <mask> if not a...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
cls = bp.json_decoder if bp and bp.json_decoder else app.json_decoder kwargs.setdefault("cls", cls)
<mask> app = current_app <mask> <mask> if app: <mask> bp = app.blueprints.get(request.blueprint) if request else None <mask> kwargs.setdefault( <mask> "cls", bp.json_decoder if bp and bp.json_decoder else app.json_decoder <mask> ) <mask> else: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
if encoding is not None: warnings.warn( "'encoding' is deprecated and will be removed in 2.1.", DeprecationWarning, stacklevel=2, ) if isinstance(rv, str): return rv.encode(encoding)
<mask> _dump_arg_defaults(kwargs, app=app) <mask> encoding = kwargs.pop("encoding", None) <mask> rv = _json.dumps(obj, **kwargs) <mask> <mask> if encoding is not None and isinstance(rv, str): <mask> rv = rv.encode(encoding) <mask> <mask> return rv <mask> <mask> <mask> def dump...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
show_warning = encoding is not None
<mask> def dump(obj, fp, app=None, **kwargs): <mask> """Like :func:`dumps` but writes into a file object.""" <mask> _dump_arg_defaults(kwargs, app=app) <mask> encoding = kwargs.pop("encoding", None) <mask> <mask> try: <mask> fp.write("") <mask> except TypeError: <mask> show...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
try: fp.write("") except TypeError: show_warning = True fp = io.TextIOWrapper(fp, encoding or "utf-8") if show_warning: warnings.warn( "Writing to a binary file, and the 'encoding' argument, is" " deprecated and will be removed in 2.1.", D...
<mask> """Like :func:`dumps` but writes into a file object.""" <mask> _dump_arg_defaults(kwargs, app=app) <mask> encoding = kwargs.pop("encoding", None) <mask> <mask> if encoding is not None: <mask> fp = _wrap_writer_for_text(fp, encoding) <mask> <mask> _json.dump(obj, fp, **kwargs...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
if encoding is not None: warnings.warn( "'encoding' is deprecated and will be removed in 2.1. The" " data must be a string or UTF-8 bytes.", DeprecationWarning, stacklevel=2, ) if isinstance(s, bytes): s = s.decode(encoding)
<mask> """ <mask> _load_arg_defaults(kwargs, app=app) <mask> encoding = kwargs.pop("encoding", None) <mask> <mask> if encoding is not None and isinstance(s, bytes): <mask> s = s.decode(encoding) <mask> <mask> return _json.loads(s, **kwargs) <mask> <mask> <mask> def load(fp, ap...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
if encoding is not None: warnings.warn( "'encoding' is deprecated and will be removed in 2.1. The" " file must be text mode, or binary mode with UTF-8 bytes.", DeprecationWarning, stacklevel=2, ) if isinstance(fp.read(0), bytes): f...
<mask> def load(fp, app=None, **kwargs): <mask> """Like :func:`loads` but reads from a file object.""" <mask> _load_arg_defaults(kwargs, app=app) <mask> encoding = kwargs.pop("encoding", None) <mask> fp = _wrap_reader_for_text(fp, encoding or "utf-8") <mask> return _json.load(fp, **kwargs) <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
fp.write(htmlsafe_dumps(obj, **kwargs))
<mask> <mask> <mask> def htmlsafe_dump(obj, fp, **kwargs): <mask> """Like :func:`htmlsafe_dumps` but writes into a file object.""" <mask> fp.write(str(htmlsafe_dumps(obj, **kwargs))) <mask> <mask> <mask> def jsonify(*args, **kwargs): <mask> """This function wraps :func:`dumps` to add a few enha...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
src/flask/json/__init__.py
<mask> def test_template_escaping(self, app, req_ctx): <mask> render = flask.render_template_string <mask> rv = flask.json.htmlsafe_dumps("</script>") <mask> assert rv == '"\\u003c/script\\u003e"' <mask> assert type(rv) is str <mask> rv = render('{{ "</script>"|tojson }...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b5f760b7285c863d5c7a4ee10adb5eb7ac60a05
tests/test_helpers.py
$ uwsgi -s /tmp/uwsgi.sock --manage-script-name --mount /yourapplication=myapp:app
<mask> Given a flask application in myapp.py, use the following command: <mask> <mask> .. sourcecode:: text <mask> <mask> $ uwsgi -s /tmp/uwsgi.sock --module myapp --callable app <mask> <mask> Or, if you prefer: <mask> <mask> .. sourcecode:: text <mask> </s> Update uwsgi/nginx deployment documentati...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b9cb6caa71c2db1a9c2ebd66f77ffe8b6306623
docs/deploying/uwsgi.rst
$ uwsgi -s /tmp/uwsgi.sock --manage-script-name --mount /yourapplication=myapp:app The ``--manage-script-name`` will move the handling of ``SCRIPT_NAME`` to uwsgi, since its smarter about that. It is used together with the ``--mount`` directive which will make requests to ``/yourapplication`` be directed to ``myap...
<mask> Or, if you prefer: <mask> <mask> .. sourcecode:: text <mask> <mask> $ uwsgi -s /tmp/uwsgi.sock -w myapp:app <mask> <mask> Configuring nginx <mask> ----------------- <mask> <mask> A basic flask uWSGI configuration for nginx looks like this:: </s> Update uwsgi/nginx deployment documentation Ins...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b9cb6caa71c2db1a9c2ebd66f77ffe8b6306623
docs/deploying/uwsgi.rst
A basic flask nginx configuration looks like this::
<mask> <mask> Configuring nginx <mask> ----------------- <mask> <mask> A basic flask uWSGI configuration for nginx looks like this:: <mask> <mask> location = /yourapplication { rewrite ^ /yourapplication/; } <mask> location /yourapplication { try_files $uri @yourapplication; } <mask> location @y...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b9cb6caa71c2db1a9c2ebd66f77ffe8b6306623
docs/deploying/uwsgi.rst
uwsgi_pass unix:/tmp/yourapplication.sock;
<mask> location = /yourapplication { rewrite ^ /yourapplication/; } <mask> location /yourapplication { try_files $uri @yourapplication; } <mask> location @yourapplication { <mask> include uwsgi_params; <mask> uwsgi_param SCRIPT_NAME /yourapplication; <mask> uwsgi_modifier1 30; <mask...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b9cb6caa71c2db1a9c2ebd66f77ffe8b6306623
docs/deploying/uwsgi.rst
to have it in the URL root its a bit simpler::
<mask> uwsgi_pass unix:/tmp/uwsgi.sock; <mask> } <mask> <mask> This configuration binds the application to ``/yourapplication``. If you want <mask> to have it in the URL root it's a bit simpler because you don't have to tell <mask> it the WSGI ``SCRIPT_NAME`` or set the uwsgi modifier to make use of i...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b9cb6caa71c2db1a9c2ebd66f77ffe8b6306623
docs/deploying/uwsgi.rst
uwsgi_pass unix:/tmp/yourapplication.sock;
<mask> <mask> location / { try_files $uri @yourapplication; } <mask> location @yourapplication { <mask> include uwsgi_params; <mask> uwsgi_pass unix:/tmp/uwsgi.sock; <mask> } <mask> <mask> .. _nginx: http://nginx.org/ <mask> .. _lighttpd: http://www.lighttpd.net/ <mask> .. _chero...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8b9cb6caa71c2db1a9c2ebd66f77ffe8b6306623
docs/deploying/uwsgi.rst
- Show a better error message when the view return type is not supported. :issue:`3214`
<mask> ``flask`` command. :issue:`1357`. <mask> - When using the test client as a context manager (``with client:``), <mask> all preserved request contexts are popped when the block exits, <mask> ensuring nested contexts are cleaned up correctly. :pr:`3157` <mask> <mask> .. _#2935: https://github.c...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb71852849907d1b67ba7514cf1812348e11b44
CHANGES.rst
from werkzeug.wrappers import BaseResponse
<mask> MethodNotAllowed, <mask> default_exceptions, <mask> ) <mask> from werkzeug.routing import BuildError, Map, RequestRedirect, RoutingException, Rule <mask> <mask> from . import cli, json <mask> from ._compat import integer_types, reraise, string_types, text_type <mask> from .config import Config, ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb71852849907d1b67ba7514cf1812348e11b44
flask/app.py
elif isinstance(rv, BaseResponse) or callable(rv):
<mask> rv = self.response_class(rv, status=status, headers=headers) <mask> status = headers = None <mask> elif isinstance(rv, dict): <mask> rv = jsonify(rv) <mask> else: <mask> # evaluate a WSGI callable, or coerce a different...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb71852849907d1b67ba7514cf1812348e11b44
flask/app.py
" response. The return type must be a string, dict, tuple,"
<mask> rv = self.response_class.force_type(rv, request.environ) <mask> except TypeError as e: <mask> new_error = TypeError( <mask> "{e}\nThe view function did not return a valid" <mask> " response. The return ty...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb71852849907d1b67ba7514cf1812348e11b44
flask/app.py
else: raise TypeError( "The view function did not return a valid" " response. The return type must be a string, dict, tuple," " Response instance, or WSGI callable, but it was a" " {rv.__class__.__name__}.".forma...
<mask> ) <mask> reraise(TypeError, new_error, sys.exc_info()[2]) <mask> <mask> # prefer the status if it was provided <mask> if status is not None: <mask> if isinstance(status, (text_type, bytes, bytearray)): </s> Better error message when view...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb71852849907d1b67ba7514cf1812348e11b44
flask/app.py
with app.open_resource('schema.sql', mode='r') as f:
<mask> `flaskr.py`:: <mask> <mask> def init_db(): <mask> with closing(connect_db()) as db: <mask> with app.open_resource('schema.sql') as f: <mask> db.cursor().executescript(f.read()) <mask> db.commit() <mask> <mask> The :func:`~contextlib.closing` helper f...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
docs/tutorial/dbinit.rst
with app.open_resource('schema.sql', mode='r') as f:
<mask> def init_db(): <mask> """Creates the database tables.""" <mask> with app.app_context(): <mask> db = get_db() <mask> with app.open_resource('schema.sql') as f: <mask> db.cursor().executescript(f.read()) <mask> db.commit() <mask> <mask> <mask> def get_db(): ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/flaskr/flaskr.py
assert b'No entries here so far' in rv.data
<mask> <mask> def test_empty_db(self): <mask> """Start with a blank database.""" <mask> rv = self.app.get('/') <mask> assert 'No entries here so far' in rv.data <mask> <mask> def test_login_logout(self): <mask> """Make sure login and logout works""" <mask> rv =...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/flaskr/flaskr_tests.py
assert b'You were logged in' in rv.data
<mask> def test_login_logout(self): <mask> """Make sure login and logout works""" <mask> rv = self.login(flaskr.app.config['USERNAME'], <mask> flaskr.app.config['PASSWORD']) <mask> assert 'You were logged in' in rv.data <mask> rv = self.logout() <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/flaskr/flaskr_tests.py
assert b'You were logged out' in rv.data
<mask> rv = self.login(flaskr.app.config['USERNAME'], <mask> flaskr.app.config['PASSWORD']) <mask> assert 'You were logged in' in rv.data <mask> rv = self.logout() <mask> assert 'You were logged out' in rv.data <mask> rv = self.login(flaskr.app.confi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/flaskr/flaskr_tests.py
assert b'Invalid username' in rv.data
<mask> rv = self.logout() <mask> assert 'You were logged out' in rv.data <mask> rv = self.login(flaskr.app.config['USERNAME'] + 'x', <mask> flaskr.app.config['PASSWORD']) <mask> assert 'Invalid username' in rv.data <mask> rv = self.login(flaskr.app.c...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/flaskr/flaskr_tests.py
assert b'Invalid password' in rv.data
<mask> flaskr.app.config['PASSWORD']) <mask> assert 'Invalid username' in rv.data <mask> rv = self.login(flaskr.app.config['USERNAME'], <mask> flaskr.app.config['PASSWORD'] + 'x') <mask> assert 'Invalid password' in rv.data <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/flaskr/flaskr_tests.py
assert b'No entries here so far' not in rv.data assert b'&lt;Hello&gt;' in rv.data assert b'<strong>HTML</strong> allowed here' in rv.data
<mask> rv = self.app.post('/add', data=dict( <mask> title='<Hello>', <mask> text='<strong>HTML</strong> allowed here' <mask> ), follow_redirects=True) <mask> assert 'No entries here so far' not in rv.data <mask> assert '&lt;Hello&gt;' in rv.data <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/flaskr/flaskr_tests.py
with app.open_resource('schema.sql', mode='r') as f:
<mask> def init_db(): <mask> """Creates the database tables.""" <mask> with app.app_context(): <mask> db = get_db() <mask> with app.open_resource('schema.sql') as f: <mask> db.cursor().executescript(f.read()) <mask> db.commit() <mask> <mask> <mask> def query_db(qu...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit.py
assert b'Your message was recorded' in rv.data
<mask> """Records a message""" <mask> rv = self.app.post('/add_message', data={'text': text}, <mask> follow_redirects=True) <mask> if text: <mask> assert 'Your message was recorded' in rv.data <mask> return rv <mask> <mask> # t...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'You were successfully registered ' \ b'and can login now' in rv.data
<mask> <mask> def test_register(self): <mask> """Make sure registering works""" <mask> rv = self.register('user1', 'default') <mask> assert 'You were successfully registered ' \ <mask> 'and can login now' in rv.data <mask> rv = self.register('user1', 'default')...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'The username is already taken' in rv.data
<mask> rv = self.register('user1', 'default') <mask> assert 'You were successfully registered ' \ <mask> 'and can login now' in rv.data <mask> rv = self.register('user1', 'default') <mask> assert 'The username is already taken' in rv.data <mask> rv = self.reg...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'You have to enter a username' in rv.data
<mask> 'and can login now' in rv.data <mask> rv = self.register('user1', 'default') <mask> assert 'The username is already taken' in rv.data <mask> rv = self.register('', 'default') <mask> assert 'You have to enter a username' in rv.data <mask> rv = self.regi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'You have to enter a password' in rv.data
<mask> assert 'The username is already taken' in rv.data <mask> rv = self.register('', 'default') <mask> assert 'You have to enter a username' in rv.data <mask> rv = self.register('meh', '') <mask> assert 'You have to enter a password' in rv.data <mask> rv = self.re...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'The two passwords do not match' in rv.data
<mask> assert 'You have to enter a username' in rv.data <mask> rv = self.register('meh', '') <mask> assert 'You have to enter a password' in rv.data <mask> rv = self.register('meh', 'x', 'y') <mask> assert 'The two passwords do not match' in rv.data <mask> rv = self...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'You have to enter a valid email address' in rv.data
<mask> assert 'You have to enter a password' in rv.data <mask> rv = self.register('meh', 'x', 'y') <mask> assert 'The two passwords do not match' in rv.data <mask> rv = self.register('meh', 'foo', email='broken') <mask> assert 'You have to enter a valid email address' in rv....
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'You were logged in' in rv.data
<mask> <mask> def test_login_logout(self): <mask> """Make sure logging in and logging out works""" <mask> rv = self.register_and_login('user1', 'default') <mask> assert 'You were logged in' in rv.data <mask> rv = self.logout() <mask> assert 'You were logged out' in rv...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'You were logged out' in rv.data
<mask> """Make sure logging in and logging out works""" <mask> rv = self.register_and_login('user1', 'default') <mask> assert 'You were logged in' in rv.data <mask> rv = self.logout() <mask> assert 'You were logged out' in rv.data <mask> rv = self.login('user1', 'wr...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'Invalid password' in rv.data
<mask> assert 'You were logged in' in rv.data <mask> rv = self.logout() <mask> assert 'You were logged out' in rv.data <mask> rv = self.login('user1', 'wrongpassword') <mask> assert 'Invalid password' in rv.data <mask> rv = self.login('user2', 'wrongpassword') <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'Invalid username' in rv.data
<mask> assert 'You were logged out' in rv.data <mask> rv = self.login('user1', 'wrongpassword') <mask> assert 'Invalid password' in rv.data <mask> rv = self.login('user2', 'wrongpassword') <mask> assert 'Invalid username' in rv.data <mask> <mask> def test_message_reco...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'test message 1' in rv.data assert b'&lt;test message 2&gt;' in rv.data
<mask> self.register_and_login('foo', 'default') <mask> self.add_message('test message 1') <mask> self.add_message('<test message 2>') <mask> rv = self.app.get('/') <mask> assert 'test message 1' in rv.data <mask> assert '&lt;test message 2&gt;' in rv.data <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'the message by foo' in rv.data assert b'the message by bar' in rv.data
<mask> self.logout() <mask> self.register_and_login('bar', 'default') <mask> self.add_message('the message by bar') <mask> rv = self.app.get('/public') <mask> assert 'the message by foo' in rv.data <mask> assert 'the message by bar' in rv.data <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'the message by foo' not in rv.data assert b'the message by bar' in rv.data
<mask> assert 'the message by bar' in rv.data <mask> <mask> # bar's timeline should just show bar's message <mask> rv = self.app.get('/') <mask> assert 'the message by foo' not in rv.data <mask> assert 'the message by bar' in rv.data <mask> <mask> # now let's fo...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'You are now following &#34;foo&#34;' in rv.data
<mask> assert 'the message by bar' in rv.data <mask> <mask> # now let's follow foo <mask> rv = self.app.get('/foo/follow', follow_redirects=True) <mask> assert 'You are now following &#34;foo&#34;' in rv.data <mask> <mask> # we should now see foo's message <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'the message by foo' in rv.data assert b'the message by bar' in rv.data
<mask> assert 'You are now following &#34;foo&#34;' in rv.data <mask> <mask> # we should now see foo's message <mask> rv = self.app.get('/') <mask> assert 'the message by foo' in rv.data <mask> assert 'the message by bar' in rv.data <mask> <mask> # but on the us...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'the message by foo' not in rv.data assert b'the message by bar' in rv.data
<mask> assert 'the message by bar' in rv.data <mask> <mask> # but on the user's page we only want the user's message <mask> rv = self.app.get('/bar') <mask> assert 'the message by foo' not in rv.data <mask> assert 'the message by bar' in rv.data <mask> rv = self.a...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'the message by foo' in rv.data assert b'the message by bar' not in rv.data
<mask> rv = self.app.get('/bar') <mask> assert 'the message by foo' not in rv.data <mask> assert 'the message by bar' in rv.data <mask> rv = self.app.get('/foo') <mask> assert 'the message by foo' in rv.data <mask> assert 'the message by bar' not in rv.data <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'You are no longer following &#34;foo&#34;' in rv.data
<mask> assert 'the message by bar' not in rv.data <mask> <mask> # now unfollow and check if that worked <mask> rv = self.app.get('/foo/unfollow', follow_redirects=True) <mask> assert 'You are no longer following &#34;foo&#34;' in rv.data <mask> rv = self.app.get('/') <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
assert b'the message by foo' not in rv.data assert b'the message by bar' in rv.data
<mask> # now unfollow and check if that worked <mask> rv = self.app.get('/foo/unfollow', follow_redirects=True) <mask> assert 'You are no longer following &#34;foo&#34;' in rv.data <mask> rv = self.app.get('/') <mask> assert 'the message by foo' not in rv.data <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
examples/minitwit/minitwit_tests.py
:param mode: resource file opening mode, default is 'rb'.
<mask> :param resource: the name of the resource. To access resources within <mask> subfolders use forward slashes as separator. <mask> """ <mask> return open(os.path.join(self.instance_path, resource), mode) <mask> <mask> def create_jinja_environment(self): ...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
flask/app.py
:param mode: resource file opening mode, default is 'rb'.
<mask> <mask> :param resource: the name of the resource. To access resources within <mask> subfolders use forward slashes as separator. <mask> """ <mask> if mode not in ('r', 'rb'): <mask> raise ValueError('Resources can only be opened for reading') ...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bb972e5ae647650457bc4e94ff51cb5e34951dd
flask/helpers.py
<mask> <mask> :copyright: (c) 2015 by the Flask Team, see AUTHORS for more details. <mask> :license: BSD, see LICENSE for more details. <mask> """ <mask> import flask <mask> import gc <mask> import os <mask> import sys <mask> import pkgutil <mask> import pytest </s> reset standard os env after each ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bdf820e9b9c166883ef9717e127ba46ebe43cae
tests/conftest.py
<mask> """ <mask> import flask <mask> import gc <mask> import os <mask> import sys <mask> import pkgutil <mask> import pytest <mask> import textwrap <mask> from flask import Flask as _Flask <mask> </s> reset standard os env after each test </s> remove import pytest </s> add import sys </s> remove import fl...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bdf820e9b9c166883ef9717e127ba46ebe43cae
tests/conftest.py
import sys
<mask> import gc <mask> import os <mask> import sys <mask> import pkgutil <mask> import pytest <mask> import textwrap <mask> from flask import Flask as _Flask <mask> <mask> <mask> class Flask(_Flask): </s> reset standard os env after each test </s> remove import sys </s> add </s> remove import flask </s...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bdf820e9b9c166883ef9717e127ba46ebe43cae
tests/conftest.py
import pytest from _pytest import monkeypatch import flask
<mask> import sys <mask> import textwrap <mask> from flask import Flask as _Flask <mask> <mask> <mask> @pytest.fixture(scope='session', autouse=True) </s> reset standard os env after each test </s> remove import sys </s> add </s> remove import pytest </s> add import sys </s> remove import flask </s> add <...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bdf820e9b9c166883ef9717e127ba46ebe43cae
tests/conftest.py
from flask.cli import ( AppGroup, FlaskGroup, NoAppException, ScriptInfo, dotenv, find_best_app, get_version, load_dotenv, locate_app, prepare_import,
<mask> from _pytest.monkeypatch import notset <mask> from click.testing import CliRunner <mask> <mask> from flask import Flask, current_app <mask> from flask.cli import AppGroup, FlaskGroup, NoAppException, ScriptInfo, dotenv, \ <mask> find_best_app, get_version, load_dotenv, locate_app, prepare_import, \ <...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bdf820e9b9c166883ef9717e127ba46ebe43cae
tests/test_cli.py
)
<mask> from flask.cli import ( <mask> AppGroup, FlaskGroup, NoAppException, ScriptInfo, dotenv, <mask> find_best_app, get_version, load_dotenv, locate_app, prepare_import, <mask> with_appcontext <mask> <mask> cwd = os.getcwd() <mask> test_path = os.path.abspath(os.path.join( <mask> os.path.dirn...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bdf820e9b9c166883ef9717e127ba46ebe43cae
tests/test_cli.py
<mask> os.path.dirname(__file__), 'test_apps' <mask> )) <mask> <mask> <mask> @pytest.fixture(autouse=True) <mask> def manage_os_environ(monkeypatch): <mask> # can't use monkeypatch.delitem since we don't want to restore a value <mask> os.environ.pop('FLASK_APP', None) <mask> os.environ.pop('F...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8bdf820e9b9c166883ef9717e127ba46ebe43cae
tests/test_cli.py
- Relax type annotation for ``after_request`` functions. :issue:`4600`
<mask> <mask> - Inline some optional imports that are only used for certain CLI <mask> commands. :pr:`4606` <mask> <mask> <mask> Version 2.1.2 <mask> ------------- <mask> </s> use bound typevar to accept Flask and Werkzeug Response classes </s> remove from werkzeug.wrappers.response import Respon...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8cb950671f39c64707b6aaebfc60d7a8f1157da5
CHANGES.rst
from werkzeug.wrappers import Response # noqa: F401
<mask> <mask> if t.TYPE_CHECKING: <mask> from _typeshed.wsgi import WSGIApplication # noqa: F401 <mask> from werkzeug.datastructures import Headers # noqa: F401 <mask> from werkzeug.wrappers.response import Response # noqa: F401 <mask> <mask> # The possible types that are directly convertible or...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8cb950671f39c64707b6aaebfc60d7a8f1157da5
src/flask/typing.py
# Allow any subclass of werkzeug.Response, such as the one from Flask, # as a callback argument. Using werkzeug.Response directly makes a # callback annotated with flask.Response fail type checking. ResponseClass = t.TypeVar("ResponseClass", bound="Response")
<mask> "WSGIApplication", <mask> ] <mask> <mask> AppOrBlueprintKey = t.Optional[str] # The App key is None, whereas blueprints are named <mask> AfterRequestCallable = t.Callable[[ResponseClass], ResponseClass] <mask> BeforeFirstRequestCallable = t.Callable[[], None] <mask> BeforeRequestCallable = t.Callabl...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8cb950671f39c64707b6aaebfc60d7a8f1157da5
src/flask/typing.py
AfterRequestCallable = t.Callable[[ResponseClass], ResponseClass]
<mask> "WSGIApplication", <mask> ] <mask> <mask> AppOrBlueprintKey = t.Optional[str] # The App key is None, whereas blueprints are named <mask> AfterRequestCallable = t.Callable[["Response"], "Response"] <mask> BeforeFirstRequestCallable = t.Callable[[], None] <mask> BeforeRequestCallable = t.Callable[[], ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8cb950671f39c64707b6aaebfc60d7a8f1157da5
src/flask/typing.py
- Subdomain matching is disabled by default now. It can be turned on by passing ``subdomain_matching=True`` to the Flask constructor.
<mask> attribute on the session cookie. (`#2607`_) <mask> - Added :meth:`~flask.Flask.test_cli_runner` to create a Click runner <mask> that can invoke Flask CLI commands for testing. (`#2636`_) <mask> <mask> .. _pallets/meta#24: https://github.com/pallets/meta/issues/24 <mask> .. _#1421: https://github.com/p...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8cec2010c0564bbd6e1f9cd8881404f70178247f
CHANGES.rst
.. versionadded:: 1.0 The `subdomain_matching` parameter was added. Subdomain matching needs to be enabled manually now. Setting `SERVER_NAME` does not implicitly enable it.
<mask> <mask> .. versionadded:: 0.13 <mask> The `host_matching` and `static_host` parameters were added. <mask> <mask> :param import_name: the name of the application package <mask> :param static_url_path: can be used to specify a different path for the <mask> sta...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8cec2010c0564bbd6e1f9cd8881404f70178247f
flask/app.py