Skip to content
Myr

Merge branch '2.2.x'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parents cb4ee20, 85f79e1 · Browse files · 11 files+186 added−57 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+186 added−57 removed

  • other:+186 added−57 removed

11 files+186 added−57 removed

modified:requirements/dev.txt+6 added-8 removed
14 unmodified lines
15click==8.1.316 # via17 # pip-compile-multi18 # pip-tools19distlib==0.3.419distlib==0.3.520 # via virtualenv21filelock==3.7.122 # via23 # tox24 # virtualenv25greenlet==1.1.2 ; python_version < "3.11"26 # via -r requirements/tests.in27identify==2.5.127identify==2.5.328 # via pre-commit29nodeenv==1.7.030 # via pre-commit31pep517==0.12.031pep517==0.13.032 # via build33pip-compile-multi==2.4.533pip-compile-multi==2.4.634 # via -r requirements/dev.in35pip-tools==6.8.036 # via pip-compile-multi37platformdirs==2.5.2
2 unmodified lines
40 # via -r requirements/dev.in41pyyaml==6.042 # via pre-commit43six==1.16.044 # via45 # tox46 # virtualenv44 # via tox45toml==0.10.246 # via47 # pre-commit48 # tox49toposort==1.750 # via pip-compile-multi51tox==3.25.152 # via -r requirements/dev.in55virtualenv==20.15.153virtualenv==20.16.254 # via55 # pre-commit56 # tox57wheel==0.37.1
5 unmodified lines
modified:requirements/docs.txt+1 added-1 removed
66 unmodified lines
67sphinxcontrib-qthelp==1.0.368 # via sphinx69sphinxcontrib-serializinghtml==1.1.570 # via sphinx71urllib3==1.26.1071urllib3==1.26.1172 # via requests
modified:requirements/tests.txt+2 added-2 removed
5 unmodified lines
6# pip-compile-multi7#8asgiref==3.5.29 # via -r requirements/tests.in10attrs==21.4.010attrs==22.1.011 # via pytest12blinker==1.412blinker==1.513 # via -r requirements/tests.in14greenlet==1.1.2 ; python_version < "3.11"15 # via -r requirements/tests.in16iniconfig==1.1.1
15 unmodified lines
modified:requirements/typing.txt+2 added-2 removed
7 unmodified lines
8cffi==1.15.19 # via cryptography10cryptography==37.0.411 # via -r requirements/typing.in12mypy==0.96112mypy==0.97113 # via -r requirements/typing.in14mypy-extensions==0.4.315 # via mypy16pycparser==2.21
3 unmodified lines
20types-contextvars==2.4.721 # via -r requirements/typing.in22types-dataclasses==0.6.623 # via -r requirements/typing.in24types-setuptools==62.6.124types-setuptools==63.2.325 # via -r requirements/typing.in26typing-extensions==4.3.027 # via mypy
modified:src/flask/json/provider.py+6 added-6 removed
174 unmodified lines
175176 :param obj: The data to serialize.177 :param kwargs: Passed to :func:`json.dumps`.178 """179 cls = self._app.json_encoder179 cls = self._app._json_encoder180 bp = self._app.blueprints.get(request.blueprint) if request else None181182 if bp is not None and bp.json_encoder is not None:183 cls = bp.json_encoder182 if bp is not None and bp._json_encoder is not None:183 cls = bp._json_encoder184185 if cls is not None:186 import warnings187
46 unmodified lines
234235 :param s: Text or UTF-8 bytes.236 :param kwargs: Passed to :func:`json.loads`.237 """238 cls = self._app.json_decoder238 cls = self._app._json_decoder239 bp = self._app.blueprints.get(request.blueprint) if request else None240241 if bp is not None and bp.json_decoder is not None:242 cls = bp.json_decoder241 if bp is not None and bp._json_decoder is not None:242 cls = bp._json_decoder243244 if cls is not None:245 import warnings246
64 unmodified lines
modified:src/flask/__init__.py+1 added-1 removed
40 unmodified lines
41from .templating import render_template_string as render_template_string42from .templating import stream_template as stream_template43from .templating import stream_template_string as stream_template_string4445__version__ = "2.2.0"45__version__ = "2.2.1"464748def __getattr__(name):49 if name == "_app_ctx_stack":
22 unmodified lines
modified:src/flask/app.py+80 added-18 removed
1import functools2import inspect3import json4import logging5import os6import sys7import typing as t
371 unmodified lines
379 stacklevel=2,380 )381 self.config["USE_X_SENDFILE"] = value382382 #: The JSON encoder class to use. Defaults to383 #: :class:`~flask.json.JSONEncoder`.384 #:385 #: .. deprecated:: 2.2386 #: Will be removed in Flask 2.3. Customize387 #: :attr:`json_provider_class` instead.388 #:389 #: .. versionadded:: 0.10390 json_encoder: None = None383 _json_encoder: t.Union[t.Type[json.JSONEncoder], None] = None384 _json_decoder: t.Union[t.Type[json.JSONDecoder], None] = None385392 #: The JSON decoder class to use. Defaults to393 #: :class:`~flask.json.JSONDecoder`.394 #:395 #: .. deprecated:: 2.2396 #: Will be removed in Flask 2.3. Customize397 #: :attr:`json_provider_class` instead.398 #:399 #: .. versionadded:: 0.10400 json_decoder: None = None386 @property # type: ignore[override]387 def json_encoder(self) -> t.Type[json.JSONEncoder]: # type: ignore[override]388 """The JSON encoder class to use. Defaults to389 :class:`~flask.json.JSONEncoder`.390391 .. deprecated:: 2.2392 Will be removed in Flask 2.3. Customize393 :attr:`json_provider_class` instead.394395 .. versionadded:: 0.10396 """397 import warnings398399 warnings.warn(400 "'app.json_encoder' is deprecated and will be removed in Flask 2.3."401 " Customize 'app.json_provider_class' or 'app.json' instead.",402 DeprecationWarning,403 stacklevel=2,404 )405406 if self._json_encoder is None:407 from . import json408409 return json.JSONEncoder410411 return self._json_encoder412413 @json_encoder.setter414 def json_encoder(self, value: t.Type[json.JSONEncoder]) -> None:415 import warnings416417 warnings.warn(418 "'app.json_encoder' is deprecated and will be removed in Flask 2.3."419 " Customize 'app.json_provider_class' or 'app.json' instead.",420 DeprecationWarning,421 stacklevel=2,422 )423 self._json_encoder = value424425 @property # type: ignore[override]426 def json_decoder(self) -> t.Type[json.JSONDecoder]: # type: ignore[override]427 """The JSON decoder class to use. Defaults to428 :class:`~flask.json.JSONDecoder`.429430 .. deprecated:: 2.2431 Will be removed in Flask 2.3. Customize432 :attr:`json_provider_class` instead.433434 .. versionadded:: 0.10435 """436 import warnings437438 warnings.warn(439 "'app.json_decoder' is deprecated and will be removed in Flask 2.3."440 " Customize 'app.json_provider_class' or 'app.json' instead.",441 DeprecationWarning,442 stacklevel=2,443 )444445 if self._json_decoder is None:446 from . import json447448 return json.JSONDecoder449450 return self._json_decoder451452 @json_decoder.setter453 def json_decoder(self, value: t.Type[json.JSONDecoder]) -> None:454 import warnings455456 warnings.warn(457 "'app.json_decoder' is deprecated and will be removed in Flask 2.3."458 " Customize 'app.json_provider_class' or 'app.json' instead.",459 DeprecationWarning,460 stacklevel=2,461 )462 self._json_decoder = value463464 json_provider_class: t.Type[JSONProvider] = DefaultJSONProvider465 """A subclass of :class:`~flask.json.provider.JSONProvider`. An466 instance is created and assigned to :attr:`app.json` when creating467 the app.
2081 unmodified lines
modified:src/flask/blueprints.py+71 added-12 removed
1import json2import os3import typing as t4from collections import defaultdict5from functools import update_wrapper
166 unmodified lines
172 """173174 _got_registered_once = False175175 #: Blueprint local JSON encoder class to use. Set to ``None`` to use176 #: the app's :class:`~flask.Flask.json_encoder`.177 #:178 #: .. deprecated:: 2.2179 #: Will be removed in Flask 2.3.180 json_encoder: None = None181 #: Blueprint local JSON decoder class to use. Set to ``None`` to use182 #: the app's :class:`~flask.Flask.json_decoder`.183 #:184 #: .. deprecated:: 2.2185 #: Will be removed in Flask 2.3.186 json_decoder: None = None176 _json_encoder: t.Union[t.Type[json.JSONEncoder], None] = None177 _json_decoder: t.Union[t.Type[json.JSONDecoder], None] = None178179 @property # type: ignore[override]180 def json_encoder( # type: ignore[override]181 self,182 ) -> t.Union[t.Type[json.JSONEncoder], None]:183 """Blueprint-local JSON encoder class to use. Set to ``None`` to use the app's.184185 .. deprecated:: 2.2186 Will be removed in Flask 2.3. Customize187 :attr:`json_provider_class` instead.188189 .. versionadded:: 0.10190 """191 import warnings192193 warnings.warn(194 "'bp.json_encoder' is deprecated and will be removed in Flask 2.3."195 " Customize 'app.json_provider_class' or 'app.json' instead.",196 DeprecationWarning,197 stacklevel=2,198 )199 return self._json_encoder200201 @json_encoder.setter202 def json_encoder(self, value: t.Union[t.Type[json.JSONEncoder], None]) -> None:203 import warnings204205 warnings.warn(206 "'bp.json_encoder' is deprecated and will be removed in Flask 2.3."207 " Customize 'app.json_provider_class' or 'app.json' instead.",208 DeprecationWarning,209 stacklevel=2,210 )211 self._json_encoder = value212213 @property # type: ignore[override]214 def json_decoder( # type: ignore[override]215 self,216 ) -> t.Union[t.Type[json.JSONDecoder], None]:217 """Blueprint-local JSON decoder class to use. Set to ``None`` to use the app's.218219 .. deprecated:: 2.2220 Will be removed in Flask 2.3. Customize221 :attr:`json_provider_class` instead.222223 .. versionadded:: 0.10224 """225 import warnings226227 warnings.warn(228 "'bp.json_decoder' is deprecated and will be removed in Flask 2.3."229 " Customize 'app.json_provider_class' or 'app.json' instead.",230 DeprecationWarning,231 stacklevel=2,232 )233 return self._json_decoder234235 @json_decoder.setter236 def json_decoder(self, value: t.Union[t.Type[json.JSONDecoder], None]) -> None:237 import warnings238239 warnings.warn(240 "'bp.json_decoder' is deprecated and will be removed in Flask 2.3."241 " Customize 'app.json_provider_class' or 'app.json' instead.",242 DeprecationWarning,243 stacklevel=2,244 )245 self._json_decoder = value246247 def __init__(248 self,249 name: str,250 import_name: str,
456 unmodified lines
modified:src/flask/scaffold.py+3 added-2 removed
1import importlib.util2import json3import os4import pathlib5import pkgutil6import sys
71 unmodified lines
78 #: blueprint sets this, it will be used instead of the app's value.79 #:80 #: .. deprecated:: 2.281 #: Will be removed in Flask 2.3.81 json_encoder: None = None82 json_encoder: t.Union[t.Type[json.JSONEncoder], None] = None8384 #: JSON decoder class used by :func:`flask.json.loads`. If a85 #: blueprint sets this, it will be used instead of the app's value.86 #:87 #: .. deprecated:: 2.288 #: Will be removed in Flask 2.3.88 json_decoder: None = None89 json_decoder: t.Union[t.Type[json.JSONDecoder], None] = None9091 def __init__(92 self,93 import_name: str,
805 unmodified lines
modified:.pre-commit-config.yaml+1 added-1 removed
18 unmodified lines
19 rev: 22.6.020 hooks:21 - id: black22 - repo: https://github.com/PyCQA/flake823 rev: 5.0.223 rev: 5.0.424 hooks:25 - id: flake826 additional_dependencies:27 - flake8-bugbear
11 unmodified lines
modified:CHANGES.rst+13 added-4 removed
2 unmodified lines
34Unreleased567Version 2.2.18-------------910Released 2022-08-031112- Setting or accessing ``json_encoder`` or ``json_decoder`` raises a13 deprecation warning. :issue:`4732`141516Version 2.2.017-------------1819Released 2022-08-01
38 unmodified lines
58 - ``flask.json`` is an instance of ``JSONProvider``. A different59 provider can be set to use a different JSON library.60 ``flask.jsonify`` will call ``app.json.response``, other61 functions in ``flask.json`` will call corresponding functions in53 ``app.json``. :pr:`4688`62 ``app.json``. :pr:`4692`6364- JSON configuration is moved to attributes on the default65 ``app.json`` provider. ``JSON_AS_ASCII``, ``JSON_SORT_KEYS``,66 ``JSONIFY_MIMETYPE``, and ``JSONIFY_PRETTYPRINT_REGULAR`` are58 deprecated. :pr:`4688`67 deprecated. :pr:`4692`68- Setting custom ``json_encoder`` and ``json_decoder`` classes on the69 app or a blueprint, and the corresponding ``json.JSONEncoder`` and70 ``JSONDecoder`` classes, are deprecated. JSON behavior can now be62 overridden using the ``app.json`` provider interface. :pr:`4688`71 overridden using the ``app.json`` provider interface. :pr:`4692`72- ``json.htmlsafe_dumps`` and ``json.htmlsafe_dump`` are deprecated,64 the function is built-in to Jinja now. :pr:`4688`73 the function is built-in to Jinja now. :pr:`4692`74- Refactor ``register_error_handler`` to consolidate error checking.75 Rewrite some error messages to be more consistent. :issue:`4559`76- Use Blueprint decorators and functions intended for setup after77 registering the blueprint will show a warning. In the next version,
1324 unmodified lines