diff --git a/CHANGES.rst b/CHANGES.rst index 32dfdd65..dddddbdc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,5 +1,15 @@ .. currentmodule:: flask +Version 1.1.1 +------------- + +Released 2019-07-08 + +- The ``flask.json_available`` flag was added back for compatibility + with some extensions. It will raise a deprecation warning when used, + and will be removed in version 2.0.0. :issue:`3288` + + Version 1.1.0 ------------- diff --git a/README.rst b/README.rst index 6e574323..ecfccedb 100644 --- a/README.rst +++ b/README.rst @@ -66,8 +66,8 @@ donate today`_. Links ----- -* Website: https://www.palletsprojects.com/p/flask/ -* Documentation: http://flask.pocoo.org/docs/ +* Website: https://palletsprojects.com/p/flask/ +* Documentation: https://flask.palletsprojects.com/ * Releases: https://pypi.org/project/Flask/ * Code: https://github.com/pallets/flask * Issue tracker: https://github.com/pallets/flask/issues diff --git a/setup.py b/setup.py index fa680a75..8a0b8ad4 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ setup( version=version, url="https://palletsprojects.com/p/flask/", project_urls={ - "Documentation": "http://flask.palletsprojects.com/", + "Documentation": "https://flask.palletsprojects.com/", "Code": "https://github.com/pallets/flask", "Issue tracker": "https://github.com/pallets/flask/issues", }, diff --git a/src/flask/__init__.py b/src/flask/__init__.py index 7f5013e5..687475bc 100644 --- a/src/flask/__init__.py +++ b/src/flask/__init__.py @@ -17,6 +17,7 @@ from werkzeug.exceptions import abort from werkzeug.utils import redirect from . import json +from ._compat import json_available from .app import Flask from .app import Request from .app import Response @@ -56,4 +57,4 @@ from .signals import template_rendered from .templating import render_template from .templating import render_template_string -__version__ = "1.1.0" +__version__ = "1.1.1" diff --git a/src/flask/_compat.py b/src/flask/_compat.py index ee47d821..76c442ca 100644 --- a/src/flask/_compat.py +++ b/src/flask/_compat.py @@ -113,3 +113,33 @@ except ImportError: # https://www.python.org/dev/peps/pep-0519/#backwards-compatibility def fspath(path): return path.__fspath__() if hasattr(path, "__fspath__") else path + + +class _DeprecatedBool(object): + def __init__(self, name, version, value): + self.message = "'{}' is deprecated and will be removed in version {}.".format( + name, version + ) + self.value = value + + def _warn(self): + import warnings + + warnings.warn(self.message, DeprecationWarning, stacklevel=2) + + def __eq__(self, other): + self._warn() + return other == self.value + + def __ne__(self, other): + self._warn() + return other != self.value + + def __bool__(self): + self._warn() + return self.value + + __nonzero__ = __bool__ + + +json_available = _DeprecatedBool("flask.json_available", "2.0.0", True) diff --git a/tests/test_deprecations.py b/tests/test_deprecations.py new file mode 100644 index 00000000..523ec109 --- /dev/null +++ b/tests/test_deprecations.py @@ -0,0 +1,12 @@ +import pytest + +from flask import json_available + + +def test_json_available(): + with pytest.deprecated_call() as rec: + assert json_available + assert json_available == True # noqa E712 + assert json_available != False # noqa E712 + + assert len(rec.list) == 3