Skip to content
Myr

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

9 files+0 added−198 removed

modified:src/flask/__init__.py-1 removed
15 unmodified lines
16from werkzeug.exceptions import abort17from werkzeug.utils import redirect1819from . import json20from ._compat import json_available20from .app import Flask21from .app import Request22from .app import Response23from .blueprints import Blueprint
36 unmodified lines
modified:src/flask/_compat.py-30 removed
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)
modified:src/flask/app.py-65 removed
8 unmodified lines
9 :license: BSD-3-Clause10"""11import os12import sys13import warnings13from datetime import timedelta14from functools import update_wrapper15from itertools import chain16from threading import Lock
1047 unmodified lines
1064 from .testing import FlaskCliRunner as cls10651066 return cls(self, **kwargs)10671069 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`.10741075 .. deprecated: 1.01076 Will be removed in 2.0. Use1077 ``session_interface.open_session`` instead.10781079 :param request: an instance of :attr:`request_class`.1080 """10811082 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)10891090 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`.10941095 .. deprecated: 1.01096 Will be removed in 2.0. Use1097 ``session_interface.save_session`` instead.10981099 :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 """11041105 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)11121113 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`.11161117 .. deprecated: 1.01118 Will be removed in 2.0. Use1119 ``session_interface.make_null_session`` instead.11201121 .. versionadded:: 0.71122 """11231124 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)11321068 @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 the
1320 unmodified lines
modified:src/flask/config.py-24 removed
9 unmodified lines
10"""11import errno12import os13import types14import warnings1415from werkzeug.utils import import_string1617from ._compat import iteritems
190 unmodified lines
208 raise209210 return self.from_mapping(obj)211213 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.216217 :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.220221 .. deprecated:: 2.0222 Use :meth:`from_file` with :meth:`json.load` instead.223224 .. 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 load233234 return self.from_file(filename, load, silent=silent)235212 def from_mapping(self, *mapping, **kwargs):213 """Updates the config like :meth:`update` ignoring items with non-upper214 keys.215
62 unmodified lines
modified:src/flask/logging.py-29 removed
8 unmodified lines
9from __future__ import absolute_import1011import logging12import sys13import warnings1314from werkzeug.local import LocalProxy1516from .globals import request
38 unmodified lines
55 logging.Formatter("[%(asctime)s] %(levelname)s in %(module)s: %(message)s")56)575860def _has_config(logger):61 """Decide if a logger has direct configuration applied by checking62 its properties against the defaults.6364 :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 )727359def create_logger(app):60 """Get the Flask app's logger and configure it if needed.6162 The logger name will be the same as
7 unmodified lines
70 :func:`~flask.logging.wsgi_errors_stream` with a basic format.71 """72 logger = logging.getLogger(app.name)7389 # 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)9394 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 break10274 if app.debug and not logger.level:75 logger.setLevel(logging.DEBUG)7677 if not has_level_handler(logger):
3 unmodified lines
modified:src/flask/testing.py-18 removed
7 unmodified lines
89 :copyright: 2010 Pallets10 :license: BSD-3-Clause11"""12import warnings12from contextlib import contextmanager1314import werkzeug.test15from click.testing import CliRunner
77 unmodified lines
93 kwargs.setdefault("app", self.app)94 return json_dumps(obj, **kwargs)959698def make_test_environ_builder(*args, **kwargs):99 """Create a :class:`flask.testing.EnvironBuilder`.100101 .. 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)11311497class 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 general
165 unmodified lines
deleted:tests/test_deprecations.py-12 removed
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:tests/test_logging.py-9 removed
102 unmodified lines
103 assert rv.data104 err = stream.getvalue()105 assert "Exception on / [GET]" in err106 assert "Exception: test" in err107108109def 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))113114 with pytest.warns(UserWarning):115 assert app.logger.getEffectiveLevel() == logging.WARNING
modified:tests/test_testing.py-10 removed
17 unmodified lines
18from flask.cli import ScriptInfo19from flask.json import jsonify20from flask.testing import EnvironBuilder21from flask.testing import FlaskCliRunner22from flask.testing import make_test_environ_builder2223try:24 import blinker25except ImportError:
93 unmodified lines
119 assert eb.script_root == ""120 assert eb.path == "/"121122124def 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 == "/"131132123def 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