remove deprecated code
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 · parent a0a61ac · Browse files · 9 files·+0 added−198 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+0 added−198 removed
- tests:+0 added−31 removed
- other:+0 added−167 removed
Provenance
- Commit
1263d3b- Tree
7b86d74- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
a0a61ac
9 files changed+0 added−198 removed
modified:src/flask/__init__.py-1 removed
15 unmodified lines16 from werkzeug.exceptions import abort17 from werkzeug.utils import redirect18 19 from . import json20-from ._compat import json_available20 from .app import Flask21 from .app import Request22 from .app import Response23 from .blueprints import Blueprint36 unmodified linesmodified:src/flask/_compat.py-30 removed
111 unmodified lines112 # 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 path116-117-118-class _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 = value124-125- def _warn(self):126- import warnings127-128- warnings.warn(self.message, DeprecationWarning, stacklevel=2)129-130- def __eq__(self, other):131- self._warn()132- return other == self.value133-134- def __ne__(self, other):135- self._warn()136- return other != self.value137-138- def __bool__(self):139- self._warn()140- return self.value141-142- __nonzero__ = __bool__143-144-145-json_available = _DeprecatedBool("flask.json_available", "2.0.0", True)modified:src/flask/app.py-65 removed
8 unmodified lines9 :license: BSD-3-Clause10 """11 import os12 import sys13-import warnings13 from datetime import timedelta14 from functools import update_wrapper15 from itertools import chain16 from threading import Lock1047 unmodified lines1064 from .testing import FlaskCliRunner as cls1065 1066 return cls(self, **kwargs)1067 1069- def open_session(self, request):1070- """Creates or opens a new session. Default implementation stores all1071- session data in a signed cookie. This requires that the1072- :attr:`secret_key` is set. Instead of overriding this method1073- we recommend replacing the :class:`session_interface`.1074-1075- .. deprecated: 1.01076- Will be removed in 2.0. Use1077- ``session_interface.open_session`` instead.1078-1079- :param request: an instance of :attr:`request_class`.1080- """1081-1082- warnings.warn(1083- DeprecationWarning(1084- '"open_session" is deprecated and will be removed in'1085- ' 2.0. Use "session_interface.open_session" instead.'1086- )1087- )1088- return self.session_interface.open_session(self, request)1089-1090- def save_session(self, session, response):1091- """Saves the session if it needs updates. For the default1092- implementation, check :meth:`open_session`. Instead of overriding this1093- method we recommend replacing the :class:`session_interface`.1094-1095- .. deprecated: 1.01096- Will be removed in 2.0. Use1097- ``session_interface.save_session`` instead.1098-1099- :param session: the session to be saved (a1100- :class:`~werkzeug.contrib.securecookie.SecureCookie`1101- object)1102- :param response: an instance of :attr:`response_class`1103- """1104-1105- warnings.warn(1106- DeprecationWarning(1107- '"save_session" is deprecated and will be removed in'1108- ' 2.0. Use "session_interface.save_session" instead.'1109- )1110- )1111- return self.session_interface.save_session(self, session, response)1112-1113- def make_null_session(self):1114- """Creates a new instance of a missing session. Instead of overriding1115- this method we recommend replacing the :class:`session_interface`.1116-1117- .. deprecated: 1.01118- Will be removed in 2.0. Use1119- ``session_interface.make_null_session`` instead.1120-1121- .. versionadded:: 0.71122- """1123-1124- warnings.warn(1125- DeprecationWarning(1126- '"make_null_session" is deprecated and will be removed'1127- ' in 2.0. Use "session_interface.make_null_session"'1128- " instead."1129- )1130- )1131- return self.session_interface.make_null_session(self)1132-1068 @setupmethod1069 def register_blueprint(self, blueprint, **options):1070 """Register a :class:`~flask.Blueprint` on the application. Keyword1071 arguments passed to this method will override the defaults set on the1320 unmodified linesmodified:src/flask/config.py-24 removed
9 unmodified lines10 """11 import errno12 import os13 import types14-import warnings14 15 from werkzeug.utils import import_string16 17 from ._compat import iteritems190 unmodified lines208 raise209 210 return self.from_mapping(obj)211 213- def from_json(self, filename, silent=False):214- """Update the values in the config from a JSON file. The loaded215- data is passed to the :meth:`from_mapping` method.216-217- :param filename: The path to the JSON file. This can be an218- absolute path or relative to the config root path.219- :param silent: Ignore the file if it doesn't exist.220-221- .. deprecated:: 2.0222- Use :meth:`from_file` with :meth:`json.load` instead.223-224- .. versionadded:: 0.11225- """226- warnings.warn(227- "'from_json' is deprecated and will be removed in 2.0."228- " Use 'from_file(filename, load=json.load)' instead.",229- DeprecationWarning,230- stacklevel=2,231- )232- from .json import load233-234- return self.from_file(filename, load, silent=silent)235-212 def from_mapping(self, *mapping, **kwargs):213 """Updates the config like :meth:`update` ignoring items with non-upper214 keys.215 62 unmodified linesmodified:src/flask/logging.py-29 removed
8 unmodified lines9 from __future__ import absolute_import10 11 import logging12 import sys13-import warnings13 14 from werkzeug.local import LocalProxy15 16 from .globals import request38 unmodified lines55 logging.Formatter("[%(asctime)s] %(levelname)s in %(module)s: %(message)s")56 )57 58 60-def _has_config(logger):61- """Decide if a logger has direct configuration applied by checking62- its properties against the defaults.63-64- :param logger: The :class:`~logging.Logger` to inspect.65- """66- return (67- logger.level != logging.NOTSET68- or logger.handlers69- or logger.filters70- or not logger.propagate71- )72-73-59 def create_logger(app):60 """Get the Flask app's logger and configure it if needed.61 62 The logger name will be the same as7 unmodified lines70 :func:`~flask.logging.wsgi_errors_stream` with a basic format.71 """72 logger = logging.getLogger(app.name)73 89- # 1.1.0 changes name of logger, warn if config is detected for old90- # name and not new name91- for old_name in ("flask.app", "flask"):92- old_logger = logging.getLogger(old_name)93-94- if _has_config(old_logger) and not _has_config(logger):95- warnings.warn(96- "'app.logger' is named '{name}' for this application,"97- " but configuration was found for '{old_name}', which"98- " no longer has an effect. The logging configuration"99- " should be moved to '{name}'.".format(name=app.name, old_name=old_name)100- )101- break102-74 if app.debug and not logger.level:75 logger.setLevel(logging.DEBUG)76 77 if not has_level_handler(logger):3 unmodified linesmodified:src/flask/testing.py-18 removed
7 unmodified lines8 9 :copyright: 2010 Pallets10 :license: BSD-3-Clause11 """12-import warnings12 from contextlib import contextmanager13 14 import werkzeug.test15 from click.testing import CliRunner77 unmodified lines93 kwargs.setdefault("app", self.app)94 return json_dumps(obj, **kwargs)95 96 98-def make_test_environ_builder(*args, **kwargs):99- """Create a :class:`flask.testing.EnvironBuilder`.100-101- .. deprecated: 1.1102- Will be removed in 2.0. Construct103- ``flask.testing.EnvironBuilder`` directly instead.104- """105- warnings.warn(106- DeprecationWarning(107- '"make_test_environ_builder()" is deprecated and will be'108- ' removed in 2.0. Construct "flask.testing.EnvironBuilder"'109- " directly instead."110- )111- )112- return EnvironBuilder(*args, **kwargs)113-114-97 class FlaskClient(Client):98 """Works like a regular Werkzeug test client but has some knowledge about99 how Flask works to defer the cleanup of the request context stack to the100 end of a ``with`` body when used in a ``with`` statement. For general165 unmodified linesdeleted:tests/test_deprecations.py-12 removed
1-import pytest2-3-from flask import json_available4-5-6-def 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 E71211-12- assert len(rec.list) == 3modified:tests/test_logging.py-9 removed
102 unmodified lines103 assert rv.data104 err = stream.getvalue()105 assert "Exception on / [GET]" in err106 assert "Exception: test" in err107-108-109-def test_warn_old_config(app, request):110- old_logger = logging.getLogger("flask.app")111- old_logger.setLevel(logging.DEBUG)112- request.addfinalizer(lambda: old_logger.setLevel(logging.NOTSET))113-114- with pytest.warns(UserWarning):115- assert app.logger.getEffectiveLevel() == logging.WARNINGmodified:tests/test_testing.py-10 removed
17 unmodified lines18 from flask.cli import ScriptInfo19 from flask.json import jsonify20 from flask.testing import EnvironBuilder21 from flask.testing import FlaskCliRunner22-from flask.testing import make_test_environ_builder22 23 try:24 import blinker25 except ImportError:93 unmodified lines119 assert eb.script_root == ""120 assert eb.path == "/"121 122 124-def test_make_test_environ_builder(app):125- with pytest.deprecated_call():126- eb = make_test_environ_builder(app, "https://example.com/")127- assert eb.url_scheme == "https"128- assert eb.host == "example.com"129- assert eb.script_root == ""130- assert eb.path == "/"131-132-123 def test_environbuilder_json_dumps(app):124 """EnvironBuilder.json_dumps() takes settings from the app."""125 app.config["JSON_AS_ASCII"] = False126 eb = EnvironBuilder(app, json=u"\u20ac")311 unmodified lines