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
filepath = loader.get_filename(import_name) # type: ignore
<mask> if loader is None or import_name == "__main__": <mask> return os.getcwd() <mask> <mask> if hasattr(loader, "get_filename"): <mask> filepath = loader.get_filename(import_name) <mask> else: <mask> # Fall back to imports. <mask> __import__(import_name) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/scaffold.py
def find_package(import_name: str):
<mask> <mask> return package_path <mask> <mask> <mask> def find_package(import_name): <mask> """Find the prefix that a package is installed under, and the path <mask> that it would be imported from. <mask> <mask> The prefix is the directory containing the standard directory <mask> hier...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/scaffold.py
import typing as t
<mask> import hashlib <mask> import warnings <mask> from collections.abc import MutableMapping <mask> from datetime import datetime <mask> <mask> from itsdangerous import BadSignature <mask> from itsdangerous import URLSafeTimedSerializer </s> Add initial type hints This should make it easier for users to cor...
[ "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
if t.TYPE_CHECKING: from .app import Flask from .wrappers import Request, Response
<mask> from .helpers import is_ip <mask> from .json.tag import TaggedJSONSerializer <mask> <mask> <mask> class SessionMixin(MutableMapping): <mask> """Expands a basic dictionary with session attributes.""" <mask> </s> Add initial type hints This should make it easier for users to correctly use Flask. Th...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def permanent(self) -> bool:
<mask> class SessionMixin(MutableMapping): <mask> """Expands a basic dictionary with session attributes.""" <mask> <mask> @property <mask> def permanent(self): <mask> """This reflects the ``'_permanent'`` key in the dict.""" <mask> return self.get("_permanent", False) <mask> <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def permanent(self, value: bool) -> None:
<mask> """This reflects the ``'_permanent'`` key in the dict.""" <mask> return self.get("_permanent", False) <mask> <mask> @permanent.setter <mask> def permanent(self, value): <mask> self["_permanent"] = bool(value) <mask> <mask> #: Some implementations can detect whether a...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def __init__(self, initial: t.Any = None) -> None: def on_update(self) -> None:
<mask> #: header, which allows caching proxies to cache different pages for <mask> #: different users. <mask> accessed = False <mask> <mask> def __init__(self, initial=None): <mask> def on_update(self): <mask> self.modified = True <mask> self.accessed = True <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def __getitem__(self, key: str) -> t.Any:
<mask> self.accessed = True <mask> <mask> super().__init__(initial, on_update) <mask> <mask> def __getitem__(self, key): <mask> self.accessed = True <mask> return super().__getitem__(key) <mask> <mask> def get(self, key, default=None): <mask> self.accesse...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def get(self, key: str, default: t.Any = None) -> t.Any:
<mask> def __getitem__(self, key): <mask> self.accessed = True <mask> return super().__getitem__(key) <mask> <mask> def get(self, key, default=None): <mask> self.accessed = True <mask> return super().get(key, default) <mask> <mask> def setdefault(self, key, default...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def setdefault(self, key: str, default: t.Any = None) -> t.Any:
<mask> def get(self, key, default=None): <mask> self.accessed = True <mask> return super().get(key, default) <mask> <mask> def setdefault(self, key, default=None): <mask> self.accessed = True <mask> return super().setdefault(key, default) <mask> <mask> <mask> class N...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def _fail(self, *args: t.Any, **kwargs: t.Any) -> t.NoReturn:
<mask> available. Will still allow read-only access to the empty session <mask> but fail on setting. <mask> """ <mask> <mask> def _fail(self, *args, **kwargs): <mask> raise RuntimeError( <mask> "The session is unavailable because no secret " <mask> "key was set....
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
__setitem__ = __delitem__ = clear = pop = popitem = update = setdefault = _fail # type: ignore # noqa: B950
<mask> "key was set. Set the secret_key on the " <mask> "application to something unique and secret." <mask> ) <mask> <mask> __setitem__ = __delitem__ = clear = pop = popitem = update = setdefault = _fail <mask> del _fail <mask> <mask> <mask> class SessionInterface: ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def make_null_session(self, app: "Flask") -> NullSession:
<mask> #: <mask> #: .. versionadded:: 0.10 <mask> pickle_based = False <mask> <mask> def make_null_session(self, app): <mask> """Creates a null session which acts as a replacement object if the <mask> real session support could not be loaded due to a configuration <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def is_null_session(self, obj: object) -> bool:
<mask> This creates an instance of :attr:`null_session_class` by default. <mask> """ <mask> return self.null_session_class() <mask> <mask> def is_null_session(self, obj): <mask> """Checks if a given object is a null session. Null sessions are <mask> not asked to be s...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def get_cookie_name(self, app: "Flask") -> str:
<mask> by default. <mask> """ <mask> return isinstance(obj, self.null_session_class) <mask> <mask> def get_cookie_name(self, app): <mask> """Returns the name of the session cookie. <mask> <mask> Uses ``app.session_cookie_name`` which is set to ``SESSION_COOKIE_NAME`...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def get_cookie_domain(self, app: "Flask") -> t.Optional[str]:
<mask> Uses ``app.session_cookie_name`` which is set to ``SESSION_COOKIE_NAME`` <mask> """ <mask> return app.session_cookie_name <mask> <mask> def get_cookie_domain(self, app): <mask> """Returns the domain that should be set for the session cookie. <mask> <mask> Use...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def get_cookie_path(self, app: "Flask") -> str:
<mask> <mask> app.config["SESSION_COOKIE_DOMAIN"] = rv <mask> return rv <mask> <mask> def get_cookie_path(self, app): <mask> """Returns the path for which the cookie should be valid. The <mask> default implementation uses the value from the ``SESSION_COOKIE_PATH`` <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def get_cookie_httponly(self, app: "Flask") -> bool:
<mask> uses ``/`` if it's ``None``. <mask> """ <mask> return app.config["SESSION_COOKIE_PATH"] or app.config["APPLICATION_ROOT"] <mask> <mask> def get_cookie_httponly(self, app): <mask> """Returns True if the session cookie should be httponly. This <mask> currently j...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def get_cookie_secure(self, app: "Flask") -> bool:
<mask> config var. <mask> """ <mask> return app.config["SESSION_COOKIE_HTTPONLY"] <mask> <mask> def get_cookie_secure(self, app): <mask> """Returns True if the cookie should be secure. This currently <mask> just returns the value of the ``SESSION_COOKIE_SECURE`` sett...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def get_cookie_samesite(self, app: "Flask") -> str:
<mask> just returns the value of the ``SESSION_COOKIE_SECURE`` setting. <mask> """ <mask> return app.config["SESSION_COOKIE_SECURE"] <mask> <mask> def get_cookie_samesite(self, app): <mask> """Return ``'Strict'`` or ``'Lax'`` if the cookie should use the <mask> ``Same...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def get_expiration_time( self, app: "Flask", session: SessionMixin ) -> t.Optional[datetime]:
<mask> the :data:`SESSION_COOKIE_SAMESITE` setting. <mask> """ <mask> return app.config["SESSION_COOKIE_SAMESITE"] <mask> <mask> def get_expiration_time(self, app, session): <mask> """A helper method that returns an expiration date for the session <mask> or ``None`` i...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
return None
<mask> """ <mask> if session.permanent: <mask> return datetime.utcnow() + app.permanent_session_lifetime <mask> <mask> def should_set_cookie(self, app: "Flask", session: SessionMixin) -> bool: <mask> """Used by session backends to determine if a ``Set-Cookie`` header <mas...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def should_set_cookie(self, app: "Flask", session: SessionMixin) -> bool:
<mask> """ <mask> if session.permanent: <mask> return datetime.utcnow() + app.permanent_session_lifetime <mask> <mask> def should_set_cookie(self, app, session): <mask> """Used by session backends to determine if a ``Set-Cookie`` header <mask> should be set for th...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def open_session( self, app: "Flask", request: "Request" ) -> t.Optional[SessionMixin]:
<mask> return session.modified or ( <mask> session.permanent and app.config["SESSION_REFRESH_EACH_REQUEST"] <mask> ) <mask> <mask> def open_session(self, app, request): <mask> """This method has to be implemented and must either return ``None`` <mask> in case the ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def save_session( self, app: "Flask", session: SessionMixin, response: "Response" ) -> None:
<mask> interface + the methods and attributes on :class:`SessionMixin`. <mask> """ <mask> raise NotImplementedError() <mask> <mask> def save_session(self, app, session, response): <mask> """This is called for actual sessions returned by :meth:`open_session` <mask> at ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def get_signing_serializer( self, app: "Flask" ) -> t.Optional[URLSafeTimedSerializer]:
<mask> #: such as datetime objects or tuples. <mask> serializer = session_json_serializer <mask> session_class = SecureCookieSession <mask> <mask> def get_signing_serializer(self, app): <mask> if not app.secret_key: <mask> return None <mask> signer_kwargs = dict( <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def open_session( self, app: "Flask", request: "Request" ) -> t.Optional[SecureCookieSession]:
<mask> serializer=self.serializer, <mask> signer_kwargs=signer_kwargs, <mask> ) <mask> <mask> def open_session(self, app, request): <mask> s = self.get_signing_serializer(app) <mask> if s is None: <mask> return None <mask> val = request.c...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
def save_session( self, app: "Flask", session: SessionMixin, response: "Response" ) -> None:
<mask> return self.session_class(data) <mask> except BadSignature: <mask> return self.session_class() <mask> <mask> def save_session(self, app, session, response): <mask> name = self.get_cookie_name(app) <mask> domain = self.get_cookie_domain(app) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
val = self.get_signing_serializer(app).dumps(dict(session)) # type: ignore
<mask> return <mask> <mask> httponly = self.get_cookie_httponly(app) <mask> expires = self.get_expiration_time(app, session) <mask> val = self.get_signing_serializer(app).dumps(dict(session)) <mask> response.set_cookie( <mask> name, <mask> val...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
val, # type: ignore
<mask> expires = self.get_expiration_time(app, session) <mask> val = self.get_signing_serializer(app).dumps(dict(session)) <mask> response.set_cookie( <mask> name, <mask> val, <mask> expires=expires, <mask> httponly=httponly, <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/sessions.py
class Namespace: # type: ignore def signal(self, name: str, doc: t.Optional[str] = None) -> "_FakeSignal":
<mask> signals_available = True <mask> except ImportError: <mask> signals_available = False <mask> <mask> class Namespace: <mask> def signal(self, name, doc=None): <mask> return _FakeSignal(name, doc) <mask> <mask> class _FakeSignal: <mask> """If blinker is unavai...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/signals.py
def __init__(self, name: str, doc: t.Optional[str] = None) -> None:
<mask> error on anything else. Instead of doing anything on send, it <mask> will just ignore the arguments and do nothing instead. <mask> """ <mask> <mask> def __init__(self, name, doc=None): <mask> self.name = name <mask> self.__doc__ = doc <mask> <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/signals.py
def send(self, *args: t.Any, **kwargs: t.Any) -> t.Any:
<mask> def __init__(self, name, doc=None): <mask> self.name = name <mask> self.__doc__ = doc <mask> <mask> def send(self, *args, **kwargs): <mask> pass <mask> <mask> def _fail(self, *args, **kwargs): <mask> raise RuntimeError( <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/signals.py
def _fail(self, *args: t.Any, **kwargs: t.Any) -> t.Any:
<mask> <mask> def send(self, *args, **kwargs): <mask> pass <mask> <mask> def _fail(self, *args, **kwargs): <mask> raise RuntimeError( <mask> "Signalling support is unavailable because the blinker" <mask> " library is not installed." <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/signals.py
from jinja2 import Template
<mask> from jinja2 import BaseLoader <mask> from jinja2 import Environment as BaseEnvironment <mask> from jinja2 import TemplateNotFound <mask> <mask> from .globals import _app_ctx_stack <mask> from .globals import _request_ctx_stack </s> Add initial type hints This should make it easier for users to correctly...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
if t.TYPE_CHECKING: from .app import Flask from .scaffold import Scaffold
<mask> from .signals import template_rendered <mask> <mask> <mask> def _default_template_ctx_processor() -> t.Dict[str, t.Any]: <mask> """Default template context processor. Injects `request`, <mask> `session` and `g`. <mask> """ <mask> reqctx = _request_ctx_stack.top </s> Add initial type h...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
def _default_template_ctx_processor() -> t.Dict[str, t.Any]:
<mask> from .signals import before_render_template <mask> from .signals import template_rendered <mask> <mask> <mask> def _default_template_ctx_processor(): <mask> """Default template context processor. Injects `request`, <mask> `session` and `g`. <mask> """ <mask> reqctx = _request_ctx_stac...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
def __init__(self, app: "Flask", **options: t.Any) -> None:
<mask> knowledge of how Flask's blueprint works so that it can prepend the <mask> name of the blueprint to referenced templates if necessary. <mask> """ <mask> <mask> def __init__(self, app, **options): <mask> if "loader" not in options: <mask> options["loader"] = app.create_...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
def __init__(self, app: "Flask") -> None:
<mask> """A loader that looks for templates in the application and all <mask> the blueprint folders. <mask> """ <mask> <mask> def __init__(self, app): <mask> self.app = app <mask> <mask> def get_source(self, environment, template): <mask> if self.app.config["EXPLAIN_TEMPLA...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
def get_source( self, environment: Environment, template: str ) -> t.Tuple[str, t.Optional[str], t.Callable]:
<mask> <mask> def __init__(self, app): <mask> self.app = app <mask> <mask> def get_source(self, environment, template): <mask> if self.app.config["EXPLAIN_TEMPLATE_LOADING"]: <mask> return self._get_source_explained(environment, template) <mask> return self._get_sou...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
def _get_source_explained( self, environment: Environment, template: str ) -> t.Tuple[str, t.Optional[str], t.Callable]:
<mask> if self.app.config["EXPLAIN_TEMPLATE_LOADING"]: <mask> return self._get_source_explained(environment, template) <mask> return self._get_source_fast(environment, template) <mask> <mask> def _get_source_explained(self, environment, template): <mask> attempts = [] <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
def _get_source_fast( self, environment: Environment, template: str ) -> t.Tuple[str, t.Optional[str], t.Callable]:
<mask> if trv is not None: <mask> return trv <mask> raise TemplateNotFound(template) <mask> <mask> def _get_source_fast(self, environment, template): <mask> for _srcobj, loader in self._iter_loaders(template): <mask> try: <mask> return loader....
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
def _iter_loaders( self, template: str ) -> t.Generator[t.Tuple["Scaffold", BaseLoader], None, None]:
<mask> except TemplateNotFound: <mask> continue <mask> raise TemplateNotFound(template) <mask> <mask> def _iter_loaders(self, template): <mask> loader = self.app.jinja_loader <mask> if loader is not None: <mask> yield self.app, loader <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
def list_templates(self) -> t.List[str]:
<mask> loader = blueprint.jinja_loader <mask> if loader is not None: <mask> yield blueprint, loader <mask> <mask> def list_templates(self): <mask> result = set() <mask> loader = self.app.jinja_loader <mask> if loader is not None: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
def _render(template: Template, context: dict, app: "Flask") -> str:
<mask> <mask> return list(result) <mask> <mask> <mask> def _render(template, context, app): <mask> """Renders the template and fires the signal""" <mask> <mask> before_render_template.send(app, template=template, context=context) <mask> rv = template.render(context) <mask> template...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
def render_template( template_name_or_list: t.Union[str, t.List[str]], **context: t.Any ) -> str:
<mask> template_rendered.send(app, template=template, context=context) <mask> return rv <mask> <mask> <mask> def render_template(template_name_or_list, **context): <mask> """Renders a template from the template folder with the given <mask> context. <mask> <mask> :param template_name_or_l...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
def render_template_string(source: str, **context: t.Any) -> str:
<mask> ctx.app, <mask> ) <mask> <mask> <mask> def render_template_string(source, **context): <mask> """Renders a template from the given template source string <mask> with the given context. Template variables will be autoescaped. <mask> <mask> :param source: the source code of the t...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/templating.py
from types import TracebackType
<mask> import typing as t <mask> from contextlib import contextmanager <mask> from copy import copy <mask> <mask> import werkzeug.test <mask> from click.testing import CliRunner <mask> from werkzeug.test import Client <mask> from werkzeug.urls import url_parse </s> Add initial type hints This should make it ...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
from .sessions import SessionMixin if t.TYPE_CHECKING: from .app import Flask from .wrappers import Response
<mask> from .cli import ScriptInfo <mask> from .json import dumps as json_dumps <mask> <mask> <mask> class EnvironBuilder(werkzeug.test.EnvironBuilder): <mask> """An :class:`~werkzeug.test.EnvironBuilder`, that takes defaults from the <mask> application. </s> Add initial type hints This should make i...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
app: "Flask", path: str = "/", base_url: t.Optional[str] = None, subdomain: t.Optional[str] = None, url_scheme: t.Optional[str] = None, *args: t.Any, **kwargs: t.Any, ) -> None:
<mask> """ <mask> <mask> def __init__( <mask> self, <mask> app, <mask> path="/", <mask> base_url=None, <mask> subdomain=None, <mask> url_scheme=None, <mask> *args, <mask> **kwargs, <mask> ): <mask> assert not (base_url or ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
def json_dumps(self, obj: t.Any, **kwargs: t.Any) -> str: # type: ignore
<mask> <mask> self.app = app <mask> super().__init__(path, base_url, *args, **kwargs) <mask> <mask> def json_dumps(self, obj, **kwargs): <mask> """Serialize ``obj`` to a JSON-formatted string. <mask> <mask> The serialization will be configured according to the config assoc...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
application: "Flask"
<mask> """ <mask> <mask> preserve_context = False <mask> <mask> def __init__(self, *args: t.Any, **kwargs: t.Any) -> None: <mask> super().__init__(*args, **kwargs) </s> Add initial type hints This should make it easier for users to correctly use Flask. The hints are from Quart. </s> remove...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
<mask> """ <mask> <mask> preserve_context = False <mask> <mask> def __init__(self, *args, **kwargs): <mask> super().__init__(*args, **kwargs) <mask> self.environ_base = { <mask> "REMOTE_ADDR": "127.0.0.1", <mask> "HTTP_USER_AGENT": f"werkzeug/{werkzeug.__ve...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
def session_transaction( self, *args: t.Any, **kwargs: t.Any ) -> t.Generator[SessionMixin, None, None]:
<mask> "HTTP_USER_AGENT": f"werkzeug/{werkzeug.__version__}", <mask> } <mask> <mask> @contextmanager <mask> def session_transaction(self, *args, **kwargs): <mask> """When used in combination with a ``with`` statement this opens a <mask> session transaction. This can ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
def open( # type: ignore self, *args: t.Any, as_tuple: bool = False, buffered: bool = False, follow_redirects: bool = False, **kwargs: t.Any, ) -> "Response":
<mask> session_interface.save_session(app, sess, resp) <mask> headers = resp.get_wsgi_headers(c.request.environ) <mask> self.cookie_jar.extract_wsgi(c.request.environ, headers) <mask> <mask> def open( <mask> self, *args, as_tuple=False, buffered=False, follow_r...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
return super().open( # type: ignore
<mask> request = builder.get_request() <mask> finally: <mask> builder.close() <mask> <mask> return super().open( <mask> request, <mask> as_tuple=as_tuple, <mask> buffered=buffered, <mask> follow_redirects=follo...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
def __enter__(self) -> "FlaskClient":
<mask> buffered=buffered, <mask> follow_redirects=follow_redirects, <mask> ) <mask> <mask> def __enter__(self): <mask> if self.preserve_context: <mask> raise RuntimeError("Cannot nest client invocations") <mask> self.preserve_context = True <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
def __exit__( self, exc_type: type, exc_value: BaseException, tb: TracebackType ) -> None:
<mask> raise RuntimeError("Cannot nest client invocations") <mask> self.preserve_context = True <mask> return self <mask> <mask> def __exit__(self, exc_type, exc_value, tb): <mask> self.preserve_context = False <mask> <mask> # Normally the request context is pre...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
def __init__(self, app: "Flask", **kwargs: t.Any) -> None:
<mask> CLI commands. Typically created using <mask> :meth:`~flask.Flask.test_cli_runner`. See :ref:`testing-cli`. <mask> """ <mask> <mask> def __init__(self, app, **kwargs): <mask> self.app = app <mask> super().__init__(**kwargs) <mask> <mask> def invoke(self, cli=None, ar...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
def invoke( # type: ignore self, cli: t.Any = None, args: t.Any = None, **kwargs: t.Any ) -> t.Any:
<mask> def __init__(self, app, **kwargs): <mask> self.app = app <mask> super().__init__(**kwargs) <mask> <mask> def invoke(self, cli=None, args=None, **kwargs): <mask> """Invokes a CLI command in an isolated environment. See <mask> :meth:`CliRunner.invoke <click.testing.C...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/testing.py
from .typing import ResponseReturnValue
<mask> import typing as t <mask> <mask> from .globals import request <mask> <mask> <mask> http_method_funcs = frozenset( <mask> ["get", "post", "head", "options", "delete", "put", "trace", "patch"] <mask> ) <mask> </s> Add initial type hints This should make it easier for users to correctly use Flask...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/views.py
methods: t.Optional[t.List[str]] = None
<mask> generated view function! <mask> """ <mask> <mask> #: A list of methods this view can handle. <mask> methods = None <mask> <mask> #: Setting this disables or force-enables the automatic options handling. <mask> provide_automatic_options = None <mask> <mask> #: The canonica...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/views.py
provide_automatic_options: t.Optional[bool] = None
<mask> #: A list of methods this view can handle. <mask> methods = None <mask> <mask> #: Setting this disables or force-enables the automatic options handling. <mask> provide_automatic_options = None <mask> <mask> #: The canonical way to decorate class-based views is to decorate the <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/views.py
decorators: t.List[t.Callable] = []
<mask> #: You can place one or more decorators in this list and whenever the <mask> #: view function is created the result is automatically decorated. <mask> #: <mask> #: .. versionadded:: 0.8 <mask> decorators = () <mask> <mask> def dispatch_request(self): <mask> """Subclasses ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/views.py
def dispatch_request(self) -> ResponseReturnValue:
<mask> #: <mask> #: .. versionadded:: 0.8 <mask> decorators = () <mask> <mask> def dispatch_request(self): <mask> """Subclasses have to override this method to implement the <mask> actual view function code. This method is called with all <mask> the arguments from the U...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/views.py
def as_view( cls, name: str, *class_args: t.Any, **class_kwargs: t.Any ) -> t.Callable:
<mask> """ <mask> raise NotImplementedError() <mask> <mask> @classmethod <mask> def as_view(cls, name, *class_args, **class_kwargs): <mask> """Converts the class into an actual view function that can be used <mask> with the routing system. Internally this generates a fun...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/views.py
def view(*args: t.Any, **kwargs: t.Any) -> ResponseReturnValue: self = view.view_class(*class_args, **class_kwargs) # type: ignore
<mask> The arguments passed to :meth:`as_view` are forwarded to the <mask> constructor of the class. <mask> """ <mask> <mask> def view(*args, **kwargs): <mask> self = view.view_class(*class_args, **class_kwargs) <mask> return self.dispatch_request(*args, *...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/views.py
view.view_class = cls # type: ignore
<mask> # first of all it allows us to easily figure out what class-based <mask> # view this thing came from, secondly it's also used for instantiating <mask> # the view class so you can actually replace it with something else <mask> # for testing purposes and debugging. <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/views.py
view.methods = cls.methods # type: ignore view.provide_automatic_options = cls.provide_automatic_options # type: ignore
<mask> view.view_class = cls <mask> view.__name__ = name <mask> view.__doc__ = cls.__doc__ <mask> view.__module__ = cls.__module__ <mask> view.methods = cls.methods <mask> view.provide_automatic_options = cls.provide_automatic_options <mask> return view <m...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/views.py
def dispatch_request(self, *args: t.Any, **kwargs: t.Any) -> ResponseReturnValue:
<mask> <mask> app.add_url_rule('/counter', view_func=CounterAPI.as_view('counter')) <mask> """ <mask> <mask> def dispatch_request(self, *args, **kwargs): <mask> meth = getattr(self, request.method.lower(), None) <mask> <mask> # If the request method is HEAD and we don't have a...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/views.py
if t.TYPE_CHECKING: from werkzeug.routing import Rule
<mask> <mask> from . import json <mask> from .globals import current_app <mask> <mask> <mask> class Request(RequestBase): <mask> """The request object used by default in Flask. Remembers the <mask> matched endpoint and view arguments. </s> Add initial type hints This should make it easier for user...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
url_rule: t.Optional["Rule"] = None
<mask> #: :exc:`~werkzeug.exceptions.MethodNotAllowed`) <mask> #: because the request was never internally bound. <mask> #: <mask> #: .. versionadded:: 0.6 <mask> url_rule = None <mask> <mask> #: A dict of view arguments that matched the request. If an exception <mask> #: happened ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
view_args: t.Optional[t.Dict[str, t.Any]] = None
<mask> url_rule = None <mask> <mask> #: A dict of view arguments that matched the request. If an exception <mask> #: happened when matching, this will be ``None``. <mask> view_args = None <mask> <mask> #: If matching the URL failed, this is the exception that will be <mask> #: raised ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
routing_exception: t.Optional[Exception] = None
<mask> #: If matching the URL failed, this is the exception that will be <mask> #: raised / was raised as part of the request handling. This is <mask> #: usually a :exc:`~werkzeug.exceptions.NotFound` exception or <mask> #: something similar. <mask> routing_exception = None <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
def max_content_length(self) -> t.Optional[int]: # type: ignore
<mask> #: something similar. <mask> routing_exception = None <mask> <mask> @property <mask> def max_content_length(self): <mask> """Read-only view of the ``MAX_CONTENT_LENGTH`` config key.""" <mask> if current_app: <mask> return current_app.config["MAX_CONTENT_LENGTH...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
else: return None
<mask> def max_content_length(self) -> t.Optional[int]: # type: ignore <mask> """Read-only view of the ``MAX_CONTENT_LENGTH`` config key.""" <mask> if current_app: <mask> return current_app.config["MAX_CONTENT_LENGTH"] <mask> <mask> @property <mask> def endpoint(self) ->...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
def endpoint(self) -> t.Optional[str]:
<mask> if current_app: <mask> return current_app.config["MAX_CONTENT_LENGTH"] <mask> <mask> @property <mask> def endpoint(self): <mask> """The endpoint that matched the request. This in combination with <mask> :attr:`view_args` can be used to reconstruct the same or ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
else: return None
<mask> be ``None``. <mask> """ <mask> if self.url_rule is not None: <mask> return self.url_rule.endpoint <mask> <mask> @property <mask> def blueprint(self) -> t.Optional[str]: <mask> """The name of the current blueprint""" <mask> if self.url_rule and...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
def blueprint(self) -> t.Optional[str]:
<mask> if self.url_rule is not None: <mask> return self.url_rule.endpoint <mask> <mask> @property <mask> def blueprint(self): <mask> """The name of the current blueprint""" <mask> if self.url_rule and "." in self.url_rule.endpoint: <mask> return self.url_...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
else: return None
<mask> if self.url_rule and "." in self.url_rule.endpoint: <mask> return self.url_rule.endpoint.rsplit(".", 1)[0] <mask> <mask> def _load_form_data(self) -> None: <mask> RequestBase._load_form_data(self) <mask> <mask> # In debug mode we're replacing the files multidict w...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
def _load_form_data(self) -> None:
<mask> """The name of the current blueprint""" <mask> if self.url_rule and "." in self.url_rule.endpoint: <mask> return self.url_rule.endpoint.rsplit(".", 1)[0] <mask> <mask> def _load_form_data(self): <mask> RequestBase._load_form_data(self) <mask> <mask> # In ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
def on_json_loading_failed(self, e: Exception) -> t.NoReturn:
<mask> from .debughelpers import attach_enctype_error_multidict <mask> <mask> attach_enctype_error_multidict(self) <mask> <mask> def on_json_loading_failed(self, e): <mask> if current_app and current_app.debug: <mask> raise BadRequest(f"Failed to decode JSON obje...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
def max_cookie_size(self) -> int: # type: ignore
<mask> <mask> json_module = json <mask> <mask> @property <mask> def max_cookie_size(self): <mask> """Read-only view of the :data:`MAX_COOKIE_SIZE` config key. <mask> <mask> See :attr:`~werkzeug.wrappers.Response.max_cookie_size` in <mask> Werkzeug's docs. <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77237093da25438c88b0a74c374a397d4bf823eb
src/flask/wrappers.py
# This was the only thing that Flask used to export at one point and it had
<mask> # We're not exposing the actual json module but a convenient wrapper around <mask> # it. <mask> from . import json <mask> <mask> # This was the only thing that flask used to export at one point and it had <mask> # a more generic name. <mask> jsonify = json.jsonify <mask> <mask> # backwards compat, goe...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77af942b982a3b07669362cc6bc223026bf039cd
flask/__init__.py
"""Special application that dispatches to a Flask application which
<mask> callback=get_version, <mask> is_flag=True, is_eager=True) <mask> <mask> class DispatchingApp(object): <mask> """Special application that dispatches to a flask application which <mask> is imported by name in a background thread. If an err...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77af942b982a3b07669362cc6bc223026bf039cd
flask/cli.py
it is recorded and shown as part of the WSGI handling which in case
<mask> <mask> class DispatchingApp(object): <mask> """Special application that dispatches to a flask application which <mask> is imported by name in a background thread. If an error happens <mask> it is is recorded and shows as part of the WSGI handling which in case <mask> of the Werkzeug debug...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77af942b982a3b07669362cc6bc223026bf039cd
flask/cli.py
#: This can be used by Flask extensions to make a decision in regards
<mask> #: this type. <mask> null_session_class = NullSession <mask> <mask> #: A flag that indicates if the session interface is pickle based. <mask> #: This can be used by flask extensions to make a decision in regards <mask> #: to how to deal with the session object. <mask> #: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77af942b982a3b07669362cc6bc223026bf039cd
flask/sessions.py
# The namespace for code signals. If you are not Flask code, do
<mask> connect = disconnect = has_receivers_for = receivers_for = \ <mask> temporarily_connected_to = connected_to = _fail <mask> del _fail <mask> <mask> # The namespace for code signals. If you are not flask code, do <mask> # not put signals in here. Create your own namespace inste...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77af942b982a3b07669362cc6bc223026bf039cd
flask/signals.py
- Flask now orders JSON keys by default to not trash HTTP caches due to different hash seeds between different workers.
<mask> more reliable in case something handles an exception halfway through <mask> the error handling process. <mask> - Added the ``JSONIFY_PRETTYPRINT_REGULAR`` configuration variable. <mask> <mask> Version 0.9 <mask> ----------- <mask> <mask> Released on July 1st 2012, codename Campari. </s> Order JSON...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77d293cf49e586f03fbea96d0bae237bc7ed230f
CHANGES
``JSON_SORT_KEYS`` By default Flask will serialize JSON objects in a way that the keys are ordered. This is done in order to ensure that independent of the hash seed of...
<mask> automatically encode it in ``utf-8`` <mask> then for transport for instance. <mask> ``JSONIFY_PRETTYPRINT_REGULAR`` If this is set to ``True`` (the default) <mask> jsonify responses will be pretty printed ...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77d293cf49e586f03fbea96d0bae237bc7ed230f
docs/config.rst
``JSON_AS_ASCII``, ``JSON_SORT_KEYS``, ``JSONIFY_PRETTYPRINT_REGULAR``
<mask> .. versionadded:: 0.9 <mask> ``PREFERRED_URL_SCHEME`` <mask> <mask> .. versionadded:: 0.10 <mask> ``JSON_AS_ASCII``, ``JSONIFY_PRETTYPRINT_REGULAR`` <mask> <mask> Configuring from Files <mask> ---------------------- <mask> <mask> Configuration becomes more useful if you can store it in a separ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77d293cf49e586f03fbea96d0bae237bc7ed230f
docs/config.rst
'JSON_SORT_KEYS': True,
<mask> 'TRAP_HTTP_EXCEPTIONS': False, <mask> 'PREFERRED_URL_SCHEME': 'http', <mask> 'JSON_AS_ASCII': True, <mask> 'JSONIFY_PRETTYPRINT_REGULAR': True, <mask> }) <mask> <mask> #: The rule object to use for URL...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77d293cf49e586f03fbea96d0bae237bc7ed230f
flask/app.py
kwargs.setdefault('sort_keys', True)
<mask> <mask> <mask> def _dump_arg_defaults(kwargs): <mask> """Inject default arguments for dump functions.""" <mask> if current_app: <mask> kwargs.setdefault('cls', current_app.json_encoder) <mask> if not current_app.config['JSON_AS_ASCII']: <mask> kwargs.setdefault('ensur...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77d293cf49e586f03fbea96d0bae237bc7ed230f
flask/json.py
kwargs.setdefault('sort_keys', current_app.config['JSON_SORT_KEYS'])
<mask> if current_app: <mask> kwargs.setdefault('cls', current_app.json_encoder) <mask> if not current_app.config['JSON_AS_ASCII']: <mask> kwargs.setdefault('ensure_ascii', False) <mask> <mask> <mask> def _load_arg_defaults(kwargs): <mask> """Inject default arguments for lo...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/77d293cf49e586f03fbea96d0bae237bc7ed230f
flask/json.py
- Fix encoding behavior of ``app.config.from_pyfile`` for Python 3. Fix ``#2118``.
<mask> Bugfix release, unreleased <mask> <mask> Version 0.12 <mask> ------------ <mask> <mask> Released on December 21st 2016, codename Punsch. <mask> <mask> - the cli command now responds to `--version`. </s> Fix config.from_pyfile on Python 3 (#2123) * Fix config.from_pyfile on Python 3 Fix #2118 *...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/789715adb9949f58b7b0272bed1a58d7cd0fad30
CHANGES
with open(filename, mode='rb') as config_file:
<mask> filename = os.path.join(self.root_path, filename) <mask> d = types.ModuleType('config') <mask> d.__file__ = filename <mask> try: <mask> with open(filename) as config_file: <mask> exec(compile(config_file.read(), filename, 'exec'), d.__dict__) <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/789715adb9949f58b7b0272bed1a58d7cd0fad30
flask/config.py
<mask> :copyright: (c) 2015 by the Flask Team, see AUTHORS for more details. <mask> :license: BSD, see LICENSE for more details. <mask> """ <mask> <mask> import pytest <mask> <mask> import os <mask> from datetime import timedelta <mask> import flask <mask> </s> Fix config.from_pyfile on Python 3 (...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/789715adb9949f58b7b0272bed1a58d7cd0fad30
tests/test_config.py
<mask> """ <mask> <mask> import pytest <mask> <mask> import os <mask> from datetime import timedelta <mask> import flask <mask> <mask> <mask> # config keys used for the TestConfig </s> Fix config.from_pyfile on Python 3 (#2123) * Fix config.from_pyfile on Python 3 Fix #2118 * Support Python 2.6 ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/789715adb9949f58b7b0272bed1a58d7cd0fad30
tests/test_config.py
import os import textwrap
<mask> <mask> <mask> from datetime import timedelta <mask> import flask <mask> from flask._compat import PY2 <mask> import pytest <mask> <mask> </s> Fix config.from_pyfile on Python 3 (#2123) * Fix config.from_pyfile on Python 3 Fix #2118 * Support Python 2.6 * Fix tests on Python 2 </s> remove i...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/789715adb9949f58b7b0272bed1a58d7cd0fad30
tests/test_config.py
from flask._compat import PY2 import pytest
<mask> import textwrap <mask> <mask> import flask <mask> <mask> <mask> # config keys used for the TestConfig <mask> TEST_KEY = 'foo' <mask> SECRET_KEY = 'devkey' <mask> </s> Fix config.from_pyfile on Python 3 (#2123) * Fix config.from_pyfile on Python 3 Fix #2118 * Support Python 2.6 * Fix tests...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/789715adb9949f58b7b0272bed1a58d7cd0fad30
tests/test_config.py