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
Provenance
- Commit
21aaf0e- Tree
40e6962- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
cb4ee20- Parent 2
85f79e1
11 files changed+186 added−57 removed
modified:requirements/dev.txt+6 added-8 removed
14 unmodified lines15 click==8.1.316 # via17 # pip-compile-multi18 # pip-tools19-distlib==0.3.419+distlib==0.3.520 # via virtualenv21 filelock==3.7.122 # via23 # tox24 # virtualenv25 greenlet==1.1.2 ; python_version < "3.11"26 # via -r requirements/tests.in27-identify==2.5.127+identify==2.5.328 # via pre-commit29 nodeenv==1.7.030 # via pre-commit31-pep517==0.12.031+pep517==0.13.032 # via build33-pip-compile-multi==2.4.533+pip-compile-multi==2.4.634 # via -r requirements/dev.in35 pip-tools==6.8.036 # via pip-compile-multi37 platformdirs==2.5.22 unmodified lines40 # via -r requirements/dev.in41 pyyaml==6.042 # via pre-commit43 six==1.16.044- # via45- # tox46- # virtualenv44+ # via tox45 toml==0.10.246 # via47 # pre-commit48 # tox49 toposort==1.750 # via pip-compile-multi51 tox==3.25.152 # via -r requirements/dev.in55-virtualenv==20.15.153+virtualenv==20.16.254 # via55 # pre-commit56 # tox57 wheel==0.37.15 unmodified linesmodified:requirements/docs.txt+1 added-1 removed
66 unmodified lines67 sphinxcontrib-qthelp==1.0.368 # via sphinx69 sphinxcontrib-serializinghtml==1.1.570 # via sphinx71-urllib3==1.26.1071+urllib3==1.26.1172 # via requestsmodified:requirements/tests.txt+2 added-2 removed
5 unmodified lines6 # pip-compile-multi7 #8 asgiref==3.5.29 # via -r requirements/tests.in10-attrs==21.4.010+attrs==22.1.011 # via pytest12-blinker==1.412+blinker==1.513 # via -r requirements/tests.in14 greenlet==1.1.2 ; python_version < "3.11"15 # via -r requirements/tests.in16 iniconfig==1.1.115 unmodified linesmodified:requirements/typing.txt+2 added-2 removed
7 unmodified lines8 cffi==1.15.19 # via cryptography10 cryptography==37.0.411 # via -r requirements/typing.in12-mypy==0.96112+mypy==0.97113 # via -r requirements/typing.in14 mypy-extensions==0.4.315 # via mypy16 pycparser==2.213 unmodified lines20 types-contextvars==2.4.721 # via -r requirements/typing.in22 types-dataclasses==0.6.623 # via -r requirements/typing.in24-types-setuptools==62.6.124+types-setuptools==63.2.325 # via -r requirements/typing.in26 typing-extensions==4.3.027 # via mypymodified:src/flask/json/provider.py+6 added-6 removed
174 unmodified lines175 176 :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 None181 182- 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_encoder184 185 if cls is not None:186 import warnings187 46 unmodified lines234 235 :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 None240 241- 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_decoder243 244 if cls is not None:245 import warnings246 64 unmodified linesmodified:src/flask/__init__.py+1 added-1 removed
40 unmodified lines41 from .templating import render_template_string as render_template_string42 from .templating import stream_template as stream_template43 from .templating import stream_template_string as stream_template_string44 45-__version__ = "2.2.0"45+__version__ = "2.2.1"46 47 48 def __getattr__(name):49 if name == "_app_ctx_stack":22 unmodified linesmodified:src/flask/app.py+80 added-18 removed
1 import functools2 import inspect3+import json4 import logging5 import os6 import sys7 import typing as t371 unmodified lines379 stacklevel=2,380 )381 self.config["USE_X_SENDFILE"] = value382 382- #: 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] = None385 392- #: 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`.390 391+ .. deprecated:: 2.2392+ Will be removed in Flask 2.3. Customize393+ :attr:`json_provider_class` instead.394+395+ .. versionadded:: 0.10396+ """397+ import warnings398+399+ 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+ )405+406+ if self._json_encoder is None:407+ from . import json408+409+ return json.JSONEncoder410+411+ return self._json_encoder412+413+ @json_encoder.setter414+ def json_encoder(self, value: t.Type[json.JSONEncoder]) -> None:415+ import warnings416+417+ 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 = value424+425+ @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`.429+430+ .. deprecated:: 2.2431+ Will be removed in Flask 2.3. Customize432+ :attr:`json_provider_class` instead.433+434+ .. versionadded:: 0.10435+ """436+ import warnings437+438+ 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+ )444+445+ if self._json_decoder is None:446+ from . import json447+448+ return json.JSONDecoder449+450+ return self._json_decoder451+452+ @json_decoder.setter453+ def json_decoder(self, value: t.Type[json.JSONDecoder]) -> None:454+ import warnings455+456+ 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 = value463+464 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 linesmodified:src/flask/blueprints.py+71 added-12 removed
1+import json2 import os3 import typing as t4 from collections import defaultdict5 from functools import update_wrapper166 unmodified lines172 """173 174 _got_registered_once = False175 175- #: 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] = None178 179+ @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.184+185+ .. deprecated:: 2.2186+ Will be removed in Flask 2.3. Customize187+ :attr:`json_provider_class` instead.188+189+ .. versionadded:: 0.10190+ """191+ import warnings192+193+ 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_encoder200+201+ @json_encoder.setter202+ def json_encoder(self, value: t.Union[t.Type[json.JSONEncoder], None]) -> None:203+ import warnings204+205+ 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 = value212+213+ @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.218+219+ .. deprecated:: 2.2220+ Will be removed in Flask 2.3. Customize221+ :attr:`json_provider_class` instead.222+223+ .. versionadded:: 0.10224+ """225+ import warnings226+227+ 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_decoder234+235+ @json_decoder.setter236+ def json_decoder(self, value: t.Union[t.Type[json.JSONDecoder], None]) -> None:237+ import warnings238+239+ 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 = value246+247 def __init__(248 self,249 name: str,250 import_name: str,456 unmodified linesmodified:src/flask/scaffold.py+3 added-2 removed
1 import importlib.util2+import json3 import os4 import pathlib5 import pkgutil6 import sys71 unmodified lines78 #: 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] = None83 84 #: 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] = None90 91 def __init__(92 self,93 import_name: str,805 unmodified linesmodified:.pre-commit-config.yaml+1 added-1 removed
18 unmodified lines19 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-bugbear11 unmodified linesmodified:CHANGES.rst+13 added-4 removed
2 unmodified lines3 4 Unreleased5 6 7+Version 2.2.18+-------------9+10+Released 2022-08-0311+12+- Setting or accessing ``json_encoder`` or ``json_decoder`` raises a13+ deprecation warning. :issue:`4732`14+15+16 Version 2.2.017 -------------18 19 Released 2022-08-0138 unmodified lines58 - ``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`63 64 - 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