Skip to content
Myr

Merge pull request #3292 from pallets/deprecate-json-available

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

restore and deprecate json_available

authored by David Lord · committed by GitHub · parents 1b4ace9, 1617202 · Browse files · 4 files+54 added−1 removed
This commit

State

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

Diff stats

4 files+54 added−1 removed

  • tests:+12 added−0 removed
  • other:+42 added−1 removed

4 files+54 added−1 removed

modified:src/flask/__init__.py+2 added-1 removed
15 unmodified lines
16from werkzeug.exceptions import abort17from werkzeug.utils import redirect1819from . import json20from ._compat import json_available21from .app import Flask22from .app import Request23from .app import Response24from .blueprints import Blueprint
31 unmodified lines
56from .signals import template_rendered57from .templating import render_template58from .templating import render_template_string5959__version__ = "1.1.0"60__version__ = "1.1.1.dev"
modified:src/flask/_compat.py+30 added
111 unmodified lines
112 # Backwards compatibility as proposed in PEP 0519:113 # https://www.python.org/dev/peps/pep-0519/#backwards-compatibility114 def fspath(path):115 return path.__fspath__() if hasattr(path, "__fspath__") else path116117118class _DeprecatedBool(object):119 def __init__(self, name, version, value):120 self.message = "'{}' is deprecated and will be removed in version {}.".format(121 name, version122 )123 self.value = value124125 def _warn(self):126 import warnings127128 warnings.warn(self.message, DeprecationWarning, stacklevel=2)129130 def __eq__(self, other):131 self._warn()132 return other == self.value133134 def __ne__(self, other):135 self._warn()136 return other != self.value137138 def __bool__(self):139 self._warn()140 return self.value141142 __nonzero__ = __bool__143144145json_available = _DeprecatedBool("flask.json_available", "2.0.0", True)
added:tests/test_deprecations.py+12 added
1import pytest23from flask import json_available456def test_json_available():7 with pytest.deprecated_call() as rec:8 assert json_available9 assert json_available == True # noqa E71210 assert json_available != False # noqa E7121112 assert len(rec.list) == 3
modified:CHANGES.rst+10 added
1.. currentmodule:: flask23Version 1.1.14-------------56Unreleased78- The ``flask.json_available`` flag was added back for compatibility9 with some extensions. It will raise a deprecation warning when used,10 and will be removed in version 2.0.0. :issue:`3288`111213Version 1.1.014-------------1516Released 2019-07-04
983 unmodified lines